Last active
August 31, 2017 17:24
-
-
Save bluepnume/1685b53be2546adaaa1208424042c4b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<script src="https://www.paypalobjects.com/api/checkout.js"></script> | |
<script src="https://js.braintreegateway.com/web/3.11.0/js/client.min.js"></script> | |
<script src="https://js.braintreegateway.com/web/3.11.0/js/paypal-checkout.min.js"></script> | |
</head> | |
<body> | |
<div id="paypal-button-container"></div> | |
<script> | |
var BRAINTREE_SANDBOX_AUTH = 'xxxx'; | |
// Render the PayPal button | |
paypal.Button.render({ | |
// Pass in the Braintree SDK | |
braintree: braintree, | |
// Pass in your Braintree authorization key | |
client: { | |
sandbox: BRAINTREE_SANDBOX_AUTH, | |
production: '<insert production auth key>' | |
}, | |
// Set your environment | |
env: 'sandbox', // sandbox | production | |
// Wait for the PayPal button to be clicked | |
payment: function(data, actions) { | |
// Call Braintree to create the payment | |
return actions.braintree.create({ | |
flow: 'checkout', | |
amount: '0.01', | |
currency: 'USD', | |
intent: 'sale' | |
}); | |
}, | |
// Wait for the payment to be authorized by the customer | |
onAuthorize: function(data, actions) { | |
return actions.payment.get().then(function(data) { | |
console.log('Payment data:', data) | |
}); | |
} | |
}, '#paypal-button-container'); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment