I've use PayPal Express in the past and I've had my fair share of issues and decided it's time to look at something that is not deprecated by PayPal. Smart Payment Buttons seems the way to go. I'm an experienced PHP Developer, but this is doing my head in. I've got a working basket, and then at the checkout I want to use the buttons to initiate a PayPal payment or a credit card payment. I've got it working this far. I'm referencing this : https://developer.paypal.com/docs/checkout/integrate/ All well and good, but I cannot find a good way to (a) detect I've been paid, or (b) there's an error or (c) that the client has cancelled. So from there how do I then take the visitor to a receipt/error/can we help page? I've read through this: https://www.paypal-community.com/t5/REST-APIs/BASIC-Smart-Payment-buttons-integration-help/td-p/1844051 It helps a bit, but when they get to start talking about installing the SDK locally I'm thinking that's overkill, and surely there's an option just to use the Javascript calls? Questions: Is there a better way of getting my PHP value into the Javascript than something like this: return actions.order.create({ purchase_units: [ { amount: { value: <?php echo json_encode($totalOrderValue); ?>; } } ] }); How do I check for a valid and successful payment? How do I check if the shopper clicked "Cancel" at the PayPal end? How do I check if the payment was attempted but failed? I can see I end up with an orderID from PayPal (not sure how I get it out of the OnApprove and into my PHP control)... and yes I can record that on my mysql table... but is that all I need to tie my order with a PayPal transaction (in case of issue)? Are there any security issues to look out for? What I'm trying to achieve is this: Checkout SUCCESSFUL PAYMENT - If the order is successfully paid for (by PayPal or by C/D Card) then create an entry in my order table and flag it as "Paid, awaiting shipment" and show the client a receipt and clear out the shopping cart. CLIENT CANCELLED - Then back out to a page that says, "We're sorry you chose not to cancel, is there anything we can do to help?" ERROR - Then tidily show the error details. I'd dearly love to be able to download a working version, and from there work out how it's doing it and then apply that to my own project, but I've searched high and low without success. Any advice and pointers greatly appreciated.
... View more