I'm working on implementation of PayPal recurring payments, but I have some doubts.
The steps to create a recurring payment profile are:
Call SetExpressCheckout (with L_BILLINGTYPE0=RecurringPayments)
Get the TOKEN
Call CreateRecurringPaymentsProfile with the token and the billing frequency
Receive the response with the ID of the active profile.
If I set the notify URL (PAYMENTREQUEST_0_NOTIFYURL) in SetExpressCheckout does PayPal IPN notify about recurring payment?
According to https://www.paypal-community.com/t5/Merchant-services-Archive/Recurring-payments-IPN/td-p/350104?profile.language=en CreateRecurringPaymentsProfile does not accept the notify URL but SetExpressCheckout does!
The SEC call does indeed set your IPN. Remember, you're setting up everything with PayPal to process a payment (setting the stage, so to speak). So it makes sense that it, and it alone, would accept the IPN callback (I wouldn't want conflicting IPN URLs in the various calls afterwards)
I would still specify an IPN URL in your account just to be safe, but yes, if you provide an IPN callback you will get notifications sent to that callback.
Related
Is there any way I can be notified that someone has approved a payment through SetExpressCheckout, if they don't get redirected back to my website?
ie. After they approve the payment I would receive a callback or payment notification.
If so, how would I do it?
Thanks.
Users will always be redirected to your site when using Express Checkout. They have to because the payment isn't final until you call DoExpressCheckoutPayment which can't occur until after they've been redirected back to your site. Maybe I don't understand what you're asking here..??
In any case, take a look at IPN (Instant Payment Notification). It will POST transaction data to a listener script you have on your server so you can automate post-order processing in real-time. Again, though, no IPN would be triggered form SetExpressCheckout alone because no payment has actually been made at that point.
While playing in sandbox and setting up recurring payments via SetExpressCheckout (as suggested in docs) I can successfully create BillingAgreement and recieve a token. Now after user follows a link like https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=[token goes here] , agrees to all terms and conditions etc., he is automatically redirected to returnUrl provided in SetExpressCheckout method, and additionally this token value is appended to the returnUrl.
So far so good. Now the question is - can I rely on the fact that returnUrl will be called at all times? F. e., what happens when for some reason user's browser refuses or fails to be redirected to the specified url?
As far as I can understand from PayPal documentation, you cannot use IPN to notify you of new subscriptions, initiated by user, though clearly IPNs would be an ideal option. I have tried to provide notifyUrl when I compose SetExpressCheckout request, but it is not being hit. Same IPN works fine for "pay" method which I use for one-time purchases.
I think you're missing a step in there. The recurring payments profile doesn't get created while the buyer is on the PayPal website -- you have to wait for the buyer to come back to your return URL, then call CreateRecurringPaymentsProfile to actually create the recurring payment. If you never call CreateRecurringPaymentsProfile, then no recurring payment gets created -- which is probably why you're not getting any IPNs.
After looking through Paypal docs for a solution for this circumstance, I came up blank. What I want is a way to have a shopping cart with a subscription (recurring payment) and an item purchase. Is there a method that would resolve this or would I have to do something custom ( and how would I go about that if I'm using Paypal standard buttons for cart / checkout ).
Thanks in advance.
Yes, you can do this with Express Checkout Recurring Payments.
You would simply need to ensure you include an AMT in your SetExpressCheckout and DoExpressCheckoutPayment API calls.
A general Express Checkout checkout flow is based on three API calls; SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckoutPayment.
SetExpressCheckout sets up the payment and returns a token
You redirect the buyer to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN-HERE, where TOKEN-HERE is the token you received earlier
After the buyer has agreed to the payment, he is returned back to your site.
You can call GetExpressCheckoutDetails and supply the token as a parameter to get the PAYERID of the buyer.
Call DoExpressCheckoutPayment with the token and PAYERID supplied to finalize the payment
If you wish to use Recurring Payments, you would use the following flow:
1. Call SetExpressCheckout and set BILLINGTYPE to 'RecurringPayments' and set 'AMT' to 0 OR to any amount you wish to charge the buyer immediately. .
2. Retrieve the token from the API response for SetExpressCheckout
3. Call DoExpressCheckoutPayment and set the 'AMT' to the amount you'd like to charge immediately.
4. Call CreateRecurringPaymentsProfile and supply the token, specify all other required parameters (billingfrequency, among others).
(Optional) 5. Use UpdateRecurringPaymentsProfile if you wish to update your recurring payments profile..
You can find additional documentation for Express Checkout at https://www.x.com/community/ppx/documentation#ec as well as our SDK's at https://www.x.com/community/ppx/sdks#NVP
You can find an overview with links to the relevant API documentation for SetExpressCheckout, DoExpressCheckoutPayment, CreateRecurringPaymentsProfile and UpdateRecurringPaymentsProfile at https://www.x.com/docs/DOC-1372
I am using PayPal with NVP API (using PHP) for express checkout. I am creating an invoice record in the database before redirecting the user to Paypal. In case the user doesn't return to my site after processing, I am using IPN to confirm the purchase and then update the invoice record that the payment is confirmed. I am still in the sandbox mode and trying to figure out how I will tie the transaction started with NVP to the confirmation I get with IPN.
I need to verify if the "PAYMENTREQUEST_n_INVNUM" sent in the NVP will come back as "invoice" in the IPN post.
It appears I cannot actually test this until I am live since the Sandbox IPN does not seem to be active with NVP initiated sandbox transactions - is this correct?
Thanks for your help.
You can test this in Sandbox. But if you're using "PayPal NVP", I assume you're using PayPal Express Checkout and calling the SetExpressCheckout and DoExpressCheckoutPayment API's.
If that's the case, you don't really need IPN, because a transaction will only be completed as soon as you call DoExpressCheckoutPayment.
In other words, buyers will always be redirected to the RETURNURL you specified in SetExpressCheckout, and the transaction is completed (or not) when you call DoExpressCheckoutPayment on this return page.
To get the invoice number, you could call GetExpressCheckoutDetails and supply the TOKEN you retrieved earlier (it's also appended to the GET of the RETURNURL).
Finally, check PAYMENTSTATUS=Completed in the DoExpressCheckoutPayment API response to see whether the transaction has completed or not.
Thank you Robert for the clarity on the process - especially useraction=commit.
I finally realized that I could turn on IPN in the Sandbox for my test seller and test NVP with IPN together. I was able to verify that PAYMENTREQUEST_0_INVNUM matches the 'INVOICE' parameter in the IPN POST.
I will use the custom field to pass customer email from my system in case they use a different email to log into paypal with, therefore allowing me to have email/invoice number pair for confirmation.
We are using Paypal's Authorisation/Capture. When a user manually captures the payment (on the Paypal website), does Paypal send any notification?
We want our backend to recognise payments that have been captured and authorised versus payments that haven't been captured yet.
We would also like to be notified about payments that were rejected.
Please note we are not using the API.
OK, found out that there is no special variable for this, it is simply stored in the 'payment_status' in the IPN message from Paypal.
The statuses relevant to authorisation/capture are:
Completed (when the payment is captured)
Refunded (when the payment is refunded)
Pending (after the user makes payment but before the payment is manually captured)