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

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.

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/

Payment and billing plan in one transaction

This is my first time using the PayPal API so go easy on me.
The case I am trying to handle is as follows:
My customers can purchase software licenses that can either be one time payments, or yearly payments.
They can multiple products to the cart, and each product can have either one of the pricing plans mentioned above.
If I understand correctly, "payments" in the API handle one time transactions, and "billing plans" are used for recurring payments.
Is it possible to processes both in one call to the API? If not, is there a different way to achieve this?
Any suggestions would be greatly appreciated! TIA!
Not one API call, but you can do it in one checkout flow with multiple API calls.
For PayPal wallet payments (logging in to PayPal and paying) I would recommend using Express Checkout w/ Recurring Payments.
With that you would be using SetExpressCheckout, GetExpressCheckoutDetails, and then either DoExpressCheckoutPayment, CreateRecurringPaymentsProfile, or a combination of both of those depending on the products in the card and whether they need one-time payment or recurring.
The CRPP call will allow you to setup a recurring profile and include an "initial payment" which would be charged when the profile is created. This could be used as the one time payment if you want, and then you wouldn't need the DECP call.
Alternatively, you could use DECP to process the one time payment and then follow that up with CRPP to create the profile. There are advantages and disadvantages to the different methods depending on your business needs.
For setting up profiles with direct credit cards you'll need PayPal Payments Pro. In this case you would either use the same CRPP call mentioned above, but it would be used by itself and include the credit card details. Or, depending on the version of Pro they put you on, which depends on the version of PayPal account you have, you might end up using PayFlow instead.
If you're working with PHP this PayPal PHP SDK will make all of those API calls very quick and easy for you.
I know that's a pretty broad answer, but that's because it's a pretty broad question. :)

Per-user / per-quantity recurring billing. What are alternatives to Stripe?

I am looking for alternatives to stripe's per-user pricing subscription : I need :
to charge my user a recurring payment which depends on the number of user accounts he has
to be able to change the number of users via an API, with customer validation is ok, but ideally without changing a plan nor creating a new type of plan. Check status, cancel, etc. via the API too.
Ideally with no up-front charge = fee + percentage of transaction
I found out that stripe might be a good option (see per-user pricing here https://stripe.com/docs/subscriptions) and unfortunately Paypal does not seem to offer this kind of feature (plans can only be increased by 20% each 180 days or you need to cancel previous profile and create a new one). Or am I mistaking about Paypal ?
What alternatives would exist for such needs?
What you want are Reference Transactions, in which case you run an original authorization or sale transaction, and then in the future you'd run DoReferenceTransaction with the original transaction ID and any new amount you need to process. It will process immediately without any redirection or additional authorization required at that point.
If you use reference transactions with Payments Pro (direct credit cards) then all you need to do is save the original auth or sale transaction ID to your database so that you can pull it out for the user when you need to process a future payment using DoReferenceTransaction.
For PayPal payments you'll use Express Checkout w/ Billing Agreements, which will give you back a billing agreement ID. In that case, the billing agreement ID is what you'd pass into future calls to DoReferenceTransaction.
In either case you'll need to build your own system to lookup payments that need to be processed each day and loop through them making a call to DoReferenceTransaction for each one.

What functions for recurring payments with different amount?

I need someone to point me in the right direction of what is the best Paypal product to use and the associated functions I need to accomplish my project.
I have a site where a user can signup for a internet phone service with a set monthly fee, lets say $200 for 1000 minutes.
The problem I have is that:
1. The first month is pro-rated so the amount may change.
2. If a user of my site goes over their allotted minutes I will charge them an overage fee in their next billing cycle, so the recurring payment may be different also.
From what I read I need to use adaptive payments is this correct, what functions should I use for creating, capturing and receiving payments.
Please help, I'm really in a bind.
There are many products that will do this. Avoid searching for "Recurring Payments" as that is generally used to refer to specific, relatively fixed payment schedules (like subscriptions) that you set up once with the payment partner (PayPal) and they execute the payments on that schedule for you. These schedules can be configured somewhat flexibly (e.g. free or reduced initial payment) but require that you can state the schedule & amounts in advance.
If you have more variable needs to collect payments from your users then you generally manage the timing and amount of the payments yourself; then you just need a mechanism for billing the user, ie a billing agreement.
PayPal products that support some form of billing agreements include PayPal Reference Transactions, PayPal Adaptive Payments, and the PayPal RESTful Payments suite.
Getting into opinion territory here, but of these three I would recommend either Reference Transaction (as the longest-standing, most mature and widely used solution) or the RESTful payments suite (as the latest and greatest solution) over Adaptive.

Paypal Recurring Payment API CALL when taking money

I am writing a subscription where I need to provide users a month trial and charge $5.00 after trial is finished. I just found an amazing code to do that for me.
I also have setup paypalpro plus recurring payments
This is the link
https://github.com/krio/paypal-recurring-subscriptions
Questions:
1- How to make first month Free Trial?
2- I need to update users billing and update their payment in my database so it can calculate their subscription, how would i get to call from paypal to my files to update?
If you are using subscriptions and you are wanting to make the first month a free trial, you would need to pass over the following variables and values.
a1=0
p1=1
t1=M
You can find a description of all of the variables for subscriptions here.
If you are wanting to get updates back to your system/database to update your profiles and etc, you can use IPN to do this. Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use it to automate back-office and administrative functions, such as fulfilling orders, tracking customers, and providing status and other information related to a transaction.