I want to implement paypal chained payment (is't one of the adaptive payment methods) within a marketplace iphone app and I want my server to be able to track all the payment steps to avoid multiple concurrent purchases on the same product (it's a physical product and it can't be purchased twice).
I read this docs from paypal about adaptive payment flow, this about mobile integration and this about IPN server side implementation.
Now the only way to achieve this seems doing the following:
- when the user clicks on the pay button, the client calls our server to create a "pending" transaction for that product.
- the client calls the native paypal sdk to present the payment view to the user with all information returned by our server.
- paypal calls our server to notify about the completed payment and here the server completes the pending transaction previously created.
- paypal calls the client to notify about the completed payment and here is shown the "thank-you" screen.
I wouldn't make this kind of things for these reasons:
- I have to put a "lock" on the product to avoid duplicate purchase: the only place I can put this lock is right before calling the paypal UI and then unlock it in case the user cancels the operation. What about if the user stays on the paypal confirmation for long time? I could put a timeout on the server (for 1 hour for example) but this wouldn't avoid the user to complete the purchase after that period!
- I have to set the payment details (like the amount and the receiver email) from the client. As I wrote, I could use the data provided by the server but this would lead me in several security and complexity issues.
- Using the native sdk the user can choose from one of their existing shipping addresses, but he can't create or edit a new one. I have to ask for the shipping address outside paypal and pass this data to my own server.
Any suggestions?