checkout script with live API accepts input, but no result shown
03-09-2017 08:37 AM
Below is the checkout.js script I got from developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/basic-integration/ . Modified it to use "production" rather than "sandbox", and pasted in the LiveAPI key that we created by logging in, going to Dashboard/Rest API Apps.
This site was set up to receive registration fees for a conference. The user enters information on an HTML form, the user is then sent to another page where the total amount owing is displayed. This is the page where I inserted the checkout script.
Result: a paypal button is displayed on the page, and when clicked, connects the user to paypal. The email address of our organization (NOT the user's email) is displayed; the user has to change this, and then can either log into their personal PayPal acct or enter credit card information.
Problem: when the user finishes the transaction, they are returned to the page where checkout is inclued, rather than being passed to the results page that we registered with PayPal. Also, our account shows no record of a transaction having occured (either in Sandbox or Live). (Revision: we see a list of failed transactions in th Dashboard).
We posted this problem to <removed> a couple of days ago, but as yet have received no response/
My guess is that we need to put something into the "onAuthorize" function; the question is WHAT?
Any help would be appreciated!
BEGIN CODE
<div id="paypal-button"></div> <script src="https://www.paypalobjects.com/api/checkout.js"></script> <script> paypal.Button.render({ env: 'production', // Specify 'sandbox' for the test environment // env: 'sandbox', // Specify 'sandbox' for the test environment client: { // sandbox: production: 'xxxxx' // we put our API key for a Live App here }, payment: function() { var env = this.props.env; var client = this.props.client; return paypal.rest.payment.create(env, client, { transactions: [ { amount: { total: <?echo $Fees?>, currency: 'USD' } } ] }); }, // Set up the payment here, when the buyer clicks on the button commit: true, // Optional: show a 'Pay Now' button in the checkout flow onAuthorize: function(data, actions) { // Execute the payment here, when the buyer approves the transaction } }, '#paypal-button'); </script>
END CODE
... View more