Kris Bonev Kris Bonev - 2 months ago 20x
C# Question

How to use PayPal Payment Preapproval

I need to integrate PayPal Payment Preapproval in my already working Adaptive Payments app. I found this .NET sample, which explains a lot of things, but I still don't get the whole picture. I have a few questions, if anyone can explain.

I make a call to set up the preapproval. Then I make a call to set up the first payment, or to set up the payment plan and it will automatically charge the client on the spacified basis?

I make the two calls separetely(in different methods), or I have to make them in a single method, one after the other? If they are seperate methods, Paypal will return some of the information, or I have to put the approved key in the url and then store locally some info with this key(so I can retrieve it)?

Do I get IPN for both calls? Is there an IPN sample, so I can see what does the call include?

I read the integration guid on the PayPal site, but it does not explain these things.


The Preapproval API gives you a preapproval key for the buyer that allows your app to make payments on their behalf at any time in the future without further approval.

You would simply pass the preapproval key into the Pay API along with the amount you're paying and other payment details, and the payment happens right away upon that Pay request completing successfully. No redirect to PayPal or anything at that point. It just processes the payment instantly because you have a preapproval key.

So with a database full of preapproval keys you could build your own subscription system (I'm assuming that's what you're doing..??)

So if you want to charge somebody once per month, or per week, per day, per minute, or whatever, you would build that logic into your own system, and just use the preapproval keys to process payments when necessary via the Pay API.

You will get IPNs for each step in the process.

Here's an example of an IPN you'd get when a preapproval profile is created:

[max_number_of_payments] => null
[starting_date] => 2016-07-19T00:00:51.000-07:00
[pin_type] => NOT_REQUIRED
[currency_code] => USD
[sender_email] =>
[verify_sign] => ApPqhQzUdN-1AdXqLkHRLMacdubFA00qBz08sedMIOkLAaOPPyc726Fs
[test_ipn] => 1
[date_of_month] => 0
[current_number_of_payments] => 0
[preapproval_key] => PA-3A023836LS390262L
[ending_date] => 2016-10-18T23:59:51.000-07:00
[approved] => true
[transaction_type] => Adaptive Payment PREAPPROVAL
[day_of_week] => NO_DAY_SPECIFIED
[status] => ACTIVE
[current_total_amount_of_all_payments] => 0.00
[current_period_attempts] => 0
[charset] => windows-1252
[payment_period] => 0
[notify_version] => UNVERSIONED

You'll get different IPNs when the Pay requests take place, too. One important thing to remember with IPN when using Adaptive Payments is that the URL you set in ipnNotificationUrl is "app specific" and will contain details related to the app itself. The PayPal account that receives the payment would need IPN configured to get an IPN with more payment specific details.

So if you have an app setup using ipnNotificationUrl and the payment is going to your own PayPal account which also has IPN configured with it, you would get 2 separate IPNs for that transaction. One for the preapproval profile being created (app specific from the API request) and another for the payment being made (transaction specific from the PayPal account profile).

Hope that helps.