CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: need card payment code

  1. #1
    Join Date
    Jul 2020
    Posts
    1

    need card payment code

    hi, I'm trying to add credit card payments to my website.Is there example code available to use?
    I have code supplied by paypal but cannot get it to work. I've tried several other's but NOT.
    Any help? My code follows:

    PHP Code:
    ------------------------------------------------------------<!-- ---------------------------------------------------------------->
    <form id="fcf-form-id" class="fcf-form-class" method="post" action="contact-form-process.php">
    <!-- -------------------------------------------------------------- -->
    <b><input type="text" STYLE="color: #000000; font-weight: bold; background-color: cyan;" size=45 
    name=intent value="I wish to order a guitarzRus singleneck guitar" onFocus="this.value=''">
    <br>
    <!-- --------------------------------------------------------------------------- -->
    <input type="text" size=35 name="unit-price" value="model - Unit Price" STYLE="color: #000000; font-weight: bold; background-color: #ccffff;">
    <!-- ---------------------------------------------------------------------------------------- -->
        <select name="unitprice">    
    <OPTION value="">Select</OPTION>
    <OPTION value="224.95" style="background-color: Pink;"> Violina_conversion - 224.95</OPTION>
    <OPTION value="235.95" style="background-color: violet;">Pipsqueek_conversion - 235.95</OPTION>
    <OPTION value="247.95" style="background-color: Pink;">Supra_conversion - 247.95</OPTION>
    <OPTION value="259.95" style="background-color: white;">Futura_conversion - 259.95</OPTION>
    <OPTION value="328.95" style="background-color: cyan;">New Violina - 328.95</OPTION>
    <OPTION value="359.95" style="background-color: violet;">New Pipsqueek - 359.95</OPTION>
    <OPTION value="377.95" style="background-color: cyan;">New Supra - 377.95</OPTION>
    <OPTION value="399.95" style="background-color: violet;">New Futura - 399.95</OPTION>
    </select><br>
    <!-- --------------------------------------------------------------------------------------------  --> 
    <b><input type="text" size=55 name="name" value=" &#x2714; Full name " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <b><input type="text" size=35 name="email" value=" &#x2714; Email Address " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <br>
    <b><input type="text" size=95 name="address" value=" &#x2714; Address " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <br>
    <b><input type="text" size=60 name="city" value=" &#x2714; City " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <b><input type="text" size=10 name="state" value=" &#x2714; State " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <b><input type="text" size=15 name="zip" value=" &#x2714; Zip code " STYLE="color: #000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></b>&nbsp;&nbsp;
    <br><br>
    <!-- ------------------------------------------------------------------- --> 

    <script src="https://www.paypal.com/sdk/js?client-id=YOUR_SB_CLIENT_ID"> 
    // Replace YOUR_SB_CLIENT_ID with your sandbox client ID
        </script>

        <div id="paypal-button-container"></div>

        <!-- Add the checkout buttons, set up the order and approve the order -->    <script>
          paypal.Buttons({
            createOrder: function(data, actions) {
              return actions.order.create({
                purchase_units: [{
                  amount: {
                    value: '0.01'
                  }
                }]
              });
            },
            onApprove: function(data, actions) {
              return actions.order.capture().then(function(details) {
                alert('Transaction completed by ' + details.payer.name.given_name);
              });
            }
          }).render('#paypal-button-container'); // Display payment options on your web page
    </script>
    <!-- ------------------------------------------------------------------- -->

    </script>
    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK -->
        

    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons({

                
    // Set up the transaction
                
    createOrder: function(data, actions) {
                    
    return actions.order.create({
                       
     purchase_units: [{
                            
    amount: {
                                
    value: '0.01'
                           
     }
                        
    }]
                    
    });
                
    },

                
    // Finalize the transaction
                
    onApprove: function(data, actions) {
                    
    return actions.order.capture().then(function(details) {
                        
    // Show a success message to the buyer
                        
    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                    
    });
                
    }


            
    }).render('#paypal-button-container');
        
    </script>

    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK -->

        
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons({
                
    style: {
                    
    layout: 'horizontal'
                
    }
            
    }).render('#paypal-button-container');
        
    </script>

    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK --

    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
     
           
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons().render('#paypal-button-container');
        
    </script>
    <BR>

    <!-- Render the radio fields and button containers -->

        
    <label>
            
    <input type="radio" name="payment-option" value="paypal" checked>
            
    <img src="/demo/checkout/static/img/paypal-mark.jpg" alt="Pay with Paypal">
        
    </label>

        
    <label>
            
    <input type="radio" name="payment-option" 
    <img src="/demo/checkout/static/img/card-mark.png" alt="Accepting Visa, 
    Mastercard, Discover and American Express">
        
    </label>

        
    <div id="paypal-button-container"></div>
        
    <div id="card-button-container" class="hidden">
    <button>Continue</button>
    </div>

        
    <!-- Include the PayPal JavaScript SDK -->

        
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Listen for changes to the radio fields
            
    document.querySelectorAll('input[name=payment-option]').forEach(function(el)
     {
                
    el.addEventListener('change', function(event)
     {

                    
    // If PayPal is selected, show the PayPal button
                    
    if (event.target.value === 'paypal')
     {
                        
    document.querySelector('#card-button-container').style.display = 'none';
                        
    document.querySelector('#paypal-button-container').style.display = 'inline-block';
                    
    }

                    // If Card is selected, show the standard continue button
                    
    if (event.target.value === 
    {
                       
     document.querySelector('#card-button-container').style.display = 'inline-block';
                        
    document.querySelector('#paypal-button-container').style.display = 'none';
                    
    }
                
    });
            
    });

            
    // Hide Non-PayPal button by default
            
    document.querySelector('#card-button-container').style.display = 'none';

            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons({
                
    style: {
                    
    layout: 'horizontal'
                
    }
            
    }).render('#paypal-button-container');
        
    </script>
    <!-- ------------------------------------------------------------------- -->
    </script>
    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK -->
        

    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons({

                
    // Set up the transaction
                
    createOrder: function(data, actions) {
                    
    return actions.order.create({
                       
     purchase_units: [{
                            
    amount: {
                                
    value: '0.01'
                           
     }
                        
    }]
                    
    });
                
    },

                
    // Finalize the transaction
                
    onApprove: function(data, actions) {
                    
    return actions.order.capture().then(function(details) {
                        
    // Show a success message to the buyer
                        
    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                    
    });
                
    }


            
    }).render('#paypal-button-container');
        
    </script>

    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK -->

        
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons({
                
    style: {
                    
    layout: 'horizontal'
                
    }
            
    }).render('#paypal-button-container');
        
    </script>

    <!-- Set up a container element for the button -->
        
    <div id="paypal-button-container"></div>

        
    <!-- Include the PayPal JavaScript SDK --

    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

        

    <script>
            
    // Render the PayPal button into #paypal-button-container
            
    paypal.Buttons().render('#paypal-button-container');
        
    </script>
    <BR>
    <div class="fcf-form-group">
                <button type="submit" id="fcf-button" class="fcf-btn fcf-btn-primary fcf-btn-lg fcf-btn-block">Send Message</button>
            </div>     
    <!-- ------------------------------------------------------------------------------------------  --> 
    <a href="index.html"><img src="house.jpg" height=75 width=75 alt="image of home"></a><br>
    <A href="webmain.html">webmaster</A>&nbsp;&nbsp;<a href="privacy.html">[privacy]</a><br>
    <input type="text" readonly size="22" maxlength="30" readonly value="copyright &copy 2000-2020" STYLE="color: #000000; font-weight: bold; background-color: #ccffff;" onFocus="this.value=''"><BR>
    </b></center>

    <script type=”text/javascript”>
    var gaJsHost = ((“https:” == document.location.protocol) ? “[url]https://ssl.”[/url] : “[url]http://www.”);[/url]
    document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
    </script>

    <script type=”text/javascript”>
    try {
    var pageTracker = _gat._getTracker(“UA-10101010-19?);
    pageTracker._trackPageview();
    } catch(err) {}</script>

    </font></form></body></html>
    ==================================================
    <?php
    if (isset($_POST['Email'])) {

        
    // EDIT THE 2 LINES BELOW AS REQUIRED
        
    $email_to "ckguitarz@gmail.com";
        
    $email_subject "guitarzRus order form";

       

        
    // create email headers
        
    $headers 'From: ' $email "\r\n" .
            
    'Reply-To: ' $email "\r\n" .
            
    'X-Mailer: PHP/' phpversion();
        @
    mail($email_to$email_subject$email_message$headers);
    ?>

        <!-- include your success message below -->

        Thank you for your order. We will be in touch with you very soon.

    <?php
    }
    ?>
    Last edited by 2kaud; July 27th, 2020 at 02:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)