samedi 10 février 2018

Buy with paypal. Paypal API integration in web app

I am working on a crypto currency dashboard. And I am new to the payments gateways integration. What I am going to do is, to sell my tokens on my web app.When a user log in to their accounts and if they have 0 balance in their account, so they will have to buy tokens by depositing money from their paypal, via and master cards. What i came up with is this :

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

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

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

<script>

    // Render the PayPal button

    paypal.Button.render({

        // Set your environment

        env: 'sandbox', // sandbox | production

        // Specify the style of the 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
        // Create a PayPal app: https://developer.paypal.com/developer/applications/create

        client: {
            sandbox:    'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
            production: '<insert production client id>'
        },

        payment: function(data, actions) {
            return actions.payment.create({
                payment: {
                    transactions: [
                        {
                            amount: { total: '0.01', currency: 'USD' }
                        }
                    ]
                }
            });
        },

        onAuthorize: function(data, actions) {
            return actions.payment.execute().then(function() {
                window.alert('Payment Complete!');
            });
        }

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

</script>
    

</body>
</html>

When I open this page in browser, it shows the visa, paypal and master card buttons. it also shows the Billing address etc which i don`t want. I just want the buttons to deposite the specified amount to my account. Thats it, so that user can buy tokens with it.




Aucun commentaire:

Enregistrer un commentaire