How to set up a PayPal monthly payment with varying amounts - flutter

I'm currently building a Flutter application with an unusual subscription model. The idea is that depending on how the user uses the app, they would seamlessly be charged a different amount of money each month. I plan to use PayPal, and I've looked into their REST API, this is what I found: https://developer.paypal.com/docs/api/payments.billing-agreements/v1/#definition-agreement_details
In this API endpoint, I'm assuming I can setup a Billing Agreement for each user of a specific amount_range, where once the user agrees to the payment, I'd be allowed to seamlessly charge each user a varying amount, within that range.
Am I correct in my conclusion?
Would this be the best approach?
if not, can you point me in the right direction for how to achieve what I'm trying to do?
I do not want to use the deprecated API. it's very important to be using REST API.
Thank you very much.

The Billing Agreement API you link to is deprecated.
Using the current PayPal Subscriptions, if you create a unique Plan for each subscriber, you can update that Plan > 10 days before their next billing date, and they will receive an email notification of the new amount.
You can use webhooks to keep track of active subscriptions and the last time you've been successfully paid for one.
If you need an internal ID for reconciliation, set the parameter custom_id when you first create the subscription; its value will be returned in webhook events for that subscription.

Related

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.

Which PayPal API for variable billing

I have a site that bills variable monthly amounts based on the subscriber's usage (typically $3 to $60). Currently, the 200 or so subscribers set up a monthly PP subscription that may or may not match their usage. I would probably use IPN to collect that info, but currently do it by hand.
I would like to use an API to request and receive the exact monthly amount. Which API? I have read elsewhere that Adaptive Payments may be the one to use, but is that appropriate/accessible to my business size?
Additionally, where would I post a request for a programmer for such?
You would need to utilize Reference Transactions for that.
Basically, you setup a billing agreement with the user an then you can use the Billing Agreement ID that you get back with the DoReferenceTransaction API any time in the future to process any amount necessary without further approval.
So you'll need to create your own system to automatically process payments on a daily basis as necessary, but this method will allow you to handle variable amounts.
If you're using Payments Pro you can do the same thing, but you don't do a "billing agreement". What you can do instead is run a $0 authorization, and then you would use the transaction ID you get back from that in the DoReferenceTransaction request instead of a Billing Agreement ID.

Do I need to execute my PayPal BillingAgreement one time only or every time the bill is due

I am trying to incorporate a member subscription on my website using the paypalrestsdk with python in a django application. I understand that I need to do the following:
Set up a BillingPlan for each type of subscription (ie. a monthly plan for $10 a month and a yearly plan for $100 a month)
Create a BillingAgreement, which (based on the user choice of billing plan) redirects the user to approve the agreement and which returns the agreement object which will give me the ability to access the plan information in order to update, suspend, reactivate the agreement.
Finally, in order to get started, I need to execute the BillingAgreement. This is the part that confuses me. Do I execute the agreement each month (for my users who have agreed to monthly subscription) or do I execute the agreement one time in order to tell PayPal to automatically process the monthly payment? If the latter case is the answer then how would I know if a payment failed for some reason? (Or do I need to check every time the user logs in by retrieving their BillingAgreement and searching for transactions within a particular date range for that agreement to make sure they are up to date and none of them failed?)
I have looked at the PayPal developer docs as well as GitHub samples. I have also successfully written code to create and execute one-time payments using the sandbox and all seems to be working just fine. I am just confused by how the recurring payments in the REST api work - specifically see #3 above.
You do not need to execute the billing agreement each month but only once to start the agreement i.e. tell PayPal to automatically process the monthly payment.
You can use the search for transactions feature to check that none of the payments of a user failed, but you might only need to do that at the start of every monthly payment cycle for a particular user. As opposed to everytime they log in. In the future, we will try to provide better notification mechanisms to inform the merchant that a payment on a billing agreement has failed/changed status.

Using Facebook subscriptions for onetime payment

I want to use subscriptions as a business model (https://developers.facebook.com/docs/payments/subscriptions/) but for onetime payment (Upgrading from lite to full version). The problem is that the metadata“fbpayment:billing_period” in fbpayment:subscription object takes "1 month" as default while the user in my app need to pay one time only to upgrade his version .
Also the subscription dialog shows the price of subscription per month which is not real in my case.
My aim for using subscriptions is to use Graph API for querying the subscription status and know who is already subscriber to give him access for specific materials . The regular payment follow in this tutorial: https://developers.facebook.com/docs/howtos/payments/paymentflow, doesn't tell how to retrieval these records .
My question is that how to use subscriptions for onetime payment ?

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.