image16.gif

 


 

 

PayPal Smart Button

 

The following is how to implement Paypal v4.

 

NOTES:

 

1. Depending on how your website is set-up, you may edit this javascript to be part of another function. You can change in the javascript how the PayPal button looks, which buttons to load, and what should happen once PayPal returns successfully. You will need to replace '<insert production client id>' with your PayPal client ID.

 

2. It may be necessary to have a COREsense developer assist with the implementation since JavaScript modifications are unique to each client. Contact CORESense Support to request this assistance.

 

 

 

Step

Action

1

Add the following to your website's checkout page:

<script src="https://www.paypalobjects.com/api/checkout.js"></script>

2

Replace the PatPal button with the following:

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

3

Add the following Javascript to the checkout page:

 

$(document).ready(function() {

     paypal.Button.render({

        // Set your environment

        env: 'production',

 

        // Specify the style of the button

        // More information: https://developer.paypal.com/docs/checkout/how-to/customize-button/

        style: {

            layout: 'vertical',  // horizontal | vertical

            size:   'medium',    // medium | large | responsive

            shape:  'rect',      // pill | rect

            color:  'gold'       // gold | blue | silver | black

        },

 

        // Specify allowed and disallowed funding sources

        //

        // Options:

        // - paypal.FUNDING.CARD

        // - paypal.FUNDING.CREDIT

        // - paypal.FUNDING.ELV

        funding: {

            allowed: [ paypal.FUNDING.CARD, paypal.FUNDING.CREDIT ],

            disallowed: [ ]

        },

 

        // PayPal Client IDs - replace with your own

        client: {

            production: '<insert production client id>'

        },

 

        payment: function(data, actions) {

            return actions.payment.create({

                payment: {

                    transactions: [

                        {

                            amount: {total: {/literal}{$order->get_balance(true)}{literal}, currency: 'USD'}

                        }

                    ]

                },

                    meta: {

                               Partner_attribution_id: 'Coresense_SP'

                    }

            });

        },

 

        onAuthorize: function(data, actions) {

            return actions.payment.execute().then(function() {

                $.ajax({

                    url:"ajax_targets/paypal_payment.php",

                    data: {

                        data: data

                    },

                    method: "POST",

                    success: function(response) {

                        window.alert('Payment Complete!');

                    }

                });

            });

        }

    }, '#paypal-button-container');

});

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

© 2015 CORESense · 1-866-229-2804 · info@coresense.com · 125 High Rock Avenue, Saratoga Springs, NY 12866