PayPal Subscriptions API - how to apply discounts - paypal

At the moment I have a relatively simple PayPal checkout that captures one-time payments using the PayPal Payments API.
As part of this, there is the option for the user to enter a voucher code and receive a discount on their order. I can do this by submitting a POST request with something like:
request_body['purchase_units'][0]['amount'] = {
'currency_code': 'GBP',
'value': str(payment_amount),
'breakdown': {
'item_total': {
'currency_code': 'GBP',
'value': str(membership_type.price)
},
'discount': {
'currency_code': 'GBP',
'value': str(discount)
}
}
}
The purchase is a semi-regular one for customers, so I am in the process of updating the checkout to move towards a subscription based system, where the user is billed automatically at a set interval, rather than manually having to go through the checkout every time as currently.
I am using the paypal Subscriptions API and have set up the Products and Plans, but I cannot see any way to offer any one-time discount when signing up to a subscription. I can see the option for a free trial, but no way to offer fine-grained control on a subscription-by-subscription basis using the API.
What I want to find out is:
How (if at all) can I integrate some kind of voucher/discount system whilst using the Subscription API? I can develop something custom if necessary, but I am wondering what the best approach is here. Creating a new Plan for every voucher code came to mind, but it seems a bit heavy handed.
If the above is not possible, can recurring transactions be processed automatically using the standard Payments API? I wouldn't have thought so otherwise there would be no need for the Subscriptions API.
In general, what is the best way of tackling regular PayPal payments, whilst being able to offer some kind of discount in particular instances?

To my knowledge:
If the pricing scheme is different, you need a new plan. If it does not make sense to pre-create all the plans you will need, you can write your code to create these on-demand as the customer is checking out and entering their selection/voucher and clicking to proceed
You need the PayPal Subscriptions API for automatic recurring transactions

Related

Some questions about billing plans & agreements REST API

I have some questions about subscription functionality using REST API. We have implemented recurring payments using "Express Checkout NVP/SOAP Integration" but for us it isn't optimal, because:
Webhooks easier and more usable then IPN messages;
We can't force customers to pay from PayPal balance.
That's why I want to rewrite it with REST API. I think the flow will be like:
User press button and we make the first request to get auth token;
Create billing plan;
Activate billing plan;
Create billing agreement;
Because of we're using PayPal payments here we redirect the customer to approve payment;
Execute billing agreement.
My questions are:
Is this flow correct?
To redirect customer for approving payment we need to make four requests to PayPal API servers, is it normal?
Should I create and activate a billing plan for every customer or I can use one plan for all customers?
If so can I create the plan in the merchant's profile page or I can do it only programmatically?
Let me see if I can answer your questions and provide some samples.
Yes, that flow is correct for the first request. If you already have a plan that you'd like to subscribe people to created, you can skip those billing plan steps. More on that below.
For the REST APIs, yes that's the normal flow for PayPal. Think of the plan as setting up the architecture of the payment that you'd like to offer (such as a subscription plan for a service). You set this up once and then can subscribe many people to that same subscription plan using a billing agreement.
If the details of the plan are the same for each person, then create one plan and then use a billing agreement for each person to subscribe them all to that same plan.
I haven't seen an integration of this with the profile system, but it's an interesting idea. For the time being, as far as I know you'll need to do this programmatically.
I've also created some new quickstart guides on the site that should help through creating the billing plan and agreements:
Billing plans: https://developer.paypal.com/docs/api/quickstart/create-billing-plan/
Billing agreements: https://developer.paypal.com/docs/api/quickstart/create-billing-agreement/
I have a more practical example of this billing plan / agreement integration in a Slack bot payment sample, if that helps: https://developer.paypal.com/docs/api/service-integrations/slack-bot/subscribe/

PayPal Express Checkout with a mix of one time purchase and recurring payments through the REST API

I am using the PayPal REST API and would like to create a transaction that includes a combination of recurring and one-time payments in a single transaction.
According to the documentation for the NVP integration, it seems such a transaction is possible. However, I'm not sure how to accomplish the same using the REST API. I have searched the REST API documentation as well as the .NET SDK examples and cannot find an example of a transaction that uses a mix of recurring and one-time payments.
Our use case: We process transactions for downloadable software - most of the products are one-time purchases, but some of the products (such as anti-virus products) have a recurring billing component associated with them. As such, we need to process a single transaction where one of the items is a regular purchase, and the other is a part of a recurring plan. We plan to process these transactions using the "PayPal" payment method (i.e. not direct credit card). Specifically, we'll be using Express Checkout.
Any guidance would be much appreciated. Thank you!
Based on what you're doing about, here's what I think your best course of action might be:
When you have a user checking out that may have some multi-month subscriptions, and some single time subscriptions, you set up a new billing plan with each item to be purchased. For the subscriptions, you set up an entry that is set to multiple months, and for a single payment you set a single month payment (see https://developer.paypal.com/docs/integration/direct/create-billing-plan/ for an example of multiple entries).
Next, you need to execute that plan for the user via a billing agreement (https://developer.paypal.com/docs/integration/direct/create-billing-agreement/). Within the billing agreement you can set the start date to execute immediately, which should complete the checkout process for both billing orders right then.
Let me know if that works out for your scenario.

Paypal subscription to different number of projects

I am trying to create a subscription feature on my site. The users can subscribe to a number of projects (from 1 to 30). The price of a projet: 10$.
For subscribing I use a the Subscription button. I validate the payment using the IPN from paypal. All ok.
Now I want to give to users the possibility to change the number of projects they are subscribed for. But the paypal doesn't allow an increasing of payment more than 20%.
How can I change the user's subscription ? Should I remove his profile (not sure if I understant what it is) and create a new one ?
As you saw in the documentation, PayPal Subscriptions product doesn't seem like a good match for your requirements. You could have someone re-subscribe with new (higher) premium, but you probably would be better off with a product that allowed you to simply change the recurring amount billed.
PayPal has several other products that allow you to do that; hopefully one will meet your needs. In particular look at Recurring Payments & Reference Transactions (within PayPal's classic product suite) or Future Payments (within PayPal's RESTful API suite).

Best practice for integrating a single PayPal subscription?

I'm new to PayPal and overwhelmed by all the possible approaches for integrating with PayPal.
As a start I want to implement one single subscription with monthly recurring payment. When the user returns to the site after fulfilling the payment, he/she will instantly be upgraded to "premium" member (digital product only - no shipping involved).
The first alternative I've looked into is the Express Checkout API, which looks ok, but is there any simpler way to do it?
Can I for example create a standard button (JS button or the form based), but still be able to verify the payment details when the user returns, using either the REST API, IPN or something else?
Any hints on best practices are appreciated.
Yes, there are entirely too many ways to solve this problem by now.
You can probably satisfy your requirements via buttons (aka Standard), Express Checkout (aka Pro) style APIs, or RESTful APIs, but there are a few gotchas to know:
First, PayPal has several products to do recurring payments; these products have functional differences and are tied to different integration styles. So (for example) PayPal's product called "subscriptions" (tied to Website Standard aka buttons) has different (and generally less flexible) capabilities than "recurring payments" (tied to Express Checkout) which in turn differs from "billing agreements" (tied to REST APIs, although the term "billing agreements" is also used in the express checkout recurring payments product). Oh, and there's another similar product tied to the Adaptive Payments suite of APIs.
Confused yet? Sorry. But it is important to determine whether the specific product you want to use will satisfy your requirements first before you do any integration, or you might end up redoing that integration work later (and potentially have to migrate customers, if you have already opened your business) in order to get access to specific features of another product later on. E.g., the subscriptions product has very limited ability for sellers to modify the subscriptions after they are set up. If that is OK, then great, use it -- it's simple to integrate. If I can oversimplify a bit: the Standard subscriptions product is the oldest and most limited; the Pro recurring payments is more flexible and mature; the REST billing agreement product is the newest, very flexible, but not yet as widely used; it may lack a feature you need today, but is the most likely to be continually improved going forward. I would not personally recommend the Adaptive product, although it also has its benefits.
Now, to your integration question: fortunately all these PayPal products can use IPNs. Unfortunately, IPNs are not instant. They generally arrive quickly (1-2 seconds) but delays can happen and it is quite awkward to be unable to process the customer. I would use IPNs only when shipping physical goods, not for immediate access to digital goods or in other cases where customers are waiting for a page from you. Fortunately, each of the other methods has a way to instantly determine the success of a PayPal action without waiting for an IPN:
Website Standard Payments will include GET or POST variables when it posts the user back to your site that will tell you about the outcome. If you use the Payment Data Transfer feature, these variables will include signature information so that you can post them back to PayPal & PayPal will verify their validity (so that a would-be thief could not fool you by engineering a post that looks like a PayPal success redirect).
The two API-based methods are even easier: the APIs themselves return all the information you need in the API response. So wherever in your code you make the call to create the subscription/agreement, if you get back a success then do your work to make your user premium.
There is the odd case of a user successfully paying and then getting "lost", as it were, e.g. the redirect failing/browser closing before they return to your site, or your site choking while trying to turn on the user. For this reason many people advise using IPNs, which PayPal will attempt to redeliver until you verify them back to PayPal. Not a bad idea, depending.
And of course you can call search & get details type APIs to get information about your transactions & agreements at PayPal -- although again, you will need to integrate with the right API that matches the product you are integrated with (e.g. Standard-based subscriptions won't show up if you ask the REST interface for billing agreements).
Hope this helps.

Paypal vault for recurring payments

I'm going to offer my customers a selection of subscriptions to digital content. I want the customer to be able to add or delete subscriptions later, with as little hassle as possible.
It seems that if I use Paypal vault, I can collect the card information on the same subscriptions screen without multiple redirects and later change the monthly total without another checkout process or even customer sending approval to Paypal!
Does Paypal allow this? It seems too easy and also too permissive. Also, do I need to worry about PCI compliance?
Does anyone know a better way to do this (with or without Paypal)? I don't know how to use paypal recurring payments without a lengthy checkout if they ever change their subscriptions. Google wallet does not have subscription cancellation in their API! Several other alternatives only allow preset subscription amounts.
The CSC/CVV is missing from the examples here: https://developer.paypal.com/docs/integration/direct/store-a-credit-card/ which makes me think you cannot use the card at will. The customer is probably going to be asked for authorisation.
Normally your online payment provider needs to support recurring payments (installments, subscriptions). PayPal does, there's a specific API:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/installment_buttons/
For the customer it's one-off, then the card is billed, say, monthly.