Sample Sandbox Buyer Credentials: | |
Buyer Email | Password |
---|---|
emily_doe@buyer.com | qwer1234 |
bill_bong@buyer.com | qwer1234 |
jack_potter@buyer.com | 123456789 |
harry_doe@buyer.com | 123456789 |
ron_brown@buyer.com | qwer1234 |
bella_brown@buyer.com | qwer1234 |
1) Click on 'PayPal Checkout’ button and see the experience.
2) If you get any Firewall warning, add rule to the Firewall to allow incoming connections for your application.
3) Checkout with PayPal using a buyer sandbox account provided on this page. And you're done!
4) The sample code uses default sandbox REST App credentials which are set in index.php PayPal button section. You can get your own REST app credentials by creating a REST app with the steps outlined here.
5) Make following changes in paypal_config.php:
- If using your own Sandbox seller account, update 'client'->'sandbox' parameter in Checkout.js v4 script (in index.php and shipping.php) with your Sandbox REST app Client ID.
- env parameter oin Checkout.js v4 script: Kept 'sandbox' for working with Sandbox, it will be 'production' for LIVE.
<script type="text/javascript">
paypal.Button.render({
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: '',
production: ''
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
meta: {
partner_attribution_id: ''
},
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');
</script>
<script src="//www.paypalobjects.com/api/checkout.js" async></script>