Proper way to create dynamic automatic billing method with paypal API? - php

I know this maybe a duplicate but due to the overwhelming amount of paypal APIs I am having a hard time finding a GOOD answer to my question.
I need to create variable monthly billing per user in PHP. The idea is that a user could sell a number of items with a total sum of sales at the end of the month p. So the billing would be something of the extent MY_PERCENTAGE_FEE * p. The user would then be sent an invoice, and a would be automatically billed via paypal for that amount.
Now, it would be SUPER great if this could be done by creating reoccurring billing and updating the amount at the end of the month. Is that possible? If not what would be the next best way to go?

If you're creating recurring profiles with Payments Pro you can adjust those without any limits. Unfortunately, with Express Checkout you're limited to raising the amount by only 20% every 180 days, so that doesn't normally work out very well. You have a few options of how to get around that.
1) Utilize billing agreements with Express Checkout and Reference Transactions. This would allow you to run an authorization (or an original sale of some sort) for a payer and then from that point on you can use that transaction ID from the original transaction along with a new amount in the DoReferenceTransaction API. Reference Transactions area available with Payments Pro by default, but if you want to use them with Express Checkout you'll need to get that specifically enabled on your account.
2) Use the Preapproval API, which is part of the Adaptive Payments platform. This is similar to reference transactions except that you can create preapproved rules by which you can bill your payers at any time without further approval. This would allow you to process payments for them at any time you need to and pull variable amounts accordingly.
3) Use the Pay API, which is also part of Adaptive Payments, with a split payment (parallel or chained) which would allow you to take your cut in real-time without the need to track balances and submit variable recurring payments. Each time one of your customers is paid for their product/service, you would immediately be paid your share.

Related

PHP - Best way of taking percentage of transaction

I'm building a website in PHP where users place bids on items. Once bidding has ended, a payment needs to be paid from the winning bidder to the listing owner. But, as the website owner, I also want to take a small percentage - say 5%.
So the process would be the winning bidder pays £100 to the listing owner, and I take 5% as that transaction takes place.
What's the best way of doing this?
I've read about PayPal MassPay, but I'm not sure whether it's what I need or not.
I'm in the UK too, not US - if that effects anything.
You can use Stripe Connect to do this if you're in the UK. You would ask your users to connect their Stripe account to your Connect Application first. You would get some data back, especially a publishable_key and an access_token which you would store on your end.
The you would use those this way:
On the front-end along with Stripe.js or Stripe Checkout you need to use the publishable_key you got from the connected user when going through the Connect flow. You should not use your API key.
Once you get a card token you send it to your server where you will create a charge. There, you should not set your API key but you should pass the access_token of the connected user as a second parameter to the Create Charge API. You can see some example code in the documentation showing how to collect fees.
This would automatically deposit the funds in the connected user's Stripe account minus the Stripe fee and the application_fee you chose. The fee would need to be a specific amount and not a percentage but you can calculate this on your end when creating the charge.
Based on your question, the solution would be as following:
Seller adds a listing on your website.
Bidding starts.
Buyer bids and win. E.g. for $10
Buyer pays using PayPal to your website, where money goes to your account (website owner).
You cut 5% of it, ($0.50) and do a Payout to seller's PayPal account of $9.50.
Optionally/Generally, website owners hold the money till the end of the month, and pay the seller the final amount, (if he is selling more than one thing, or he is a big merchant.)
However, the flow should help you setup a website based on your preferences. Many websites like eBay, Free lancing, apply the similar flow.
As a PayPal Employee, I would recommend using PayPal PHP SDK for developing. All the instructions are provided here and here

PayPal recurring payment "add-ons"

Requirement:
We want to have a base subscription which is X/month, done via recurring payments, and give clients the ability to choose extra "add-ons" as they please. An "add-on" will be Y/Month and should last the remainder of the base subscription. For example, the base subscription is 10/month and feature X is extra 5/month and feature Y is an extra 7/month. I choose to have the base subscription with feature X and Y so my total monthly payment for a year will be 22/month. Now, if I chose only the base subscription for the first 6 months and want to start using feature X for the final 6 months of my subscription, the final 6 months should be 15/month opposed to the previous 10/month. In further terms, add-on features subscription should last the duration of the base subscription.
Is there a simple way to do this via the PayPal API?
Actual recurring payments profiles (setup with Standard or Express Checkout) have a limit on how much you can raise the amount of a profile. You can only raise it by 20% every 180 days. If you create a recurring payments profile with Payments Pro, though, then there is no such limit and you can change the amount at any time to whatever you need. I wouldn't recommend going without EC, though, as lots of people prefer to pay with PayPal.
What you could do, though, instead of using the recurring payments APIs would be to use billing agreements / reference transactions. This way you'd save the billing agreement / auth ID in your database and then you can use the DoReferenceTransaction API to process any variable amount you need to at any time.
So in that case you would basically be building your own recurring payments system where you'll save the "next payment date" in your database, and then you'll have an automated script run each day to process all of the payments that are due that day via a reference transaction.
Reference transactions work with Payments Pro, too, so if you're using that everything would still work the same.
Since you're working with PHP I'd recommend taking a look at my class library for PayPal. It will make all of these API calls very simple for you.

Subscriptions and recurring payments with preapproved allowance limit

I am working on a site providing software as a service which is billed on a monthly basis.
The software is licensed on a per-user basis and will be extensible via optional standard modules and custom apps that can be subscribed to through an app store.
The customer can alter the number of users, subscribe or unsubscribe modules and apps every month.
Users, modules and apps should be billed along with the base software, thus the billing amount may greatly vary from month to month.
The goal is to minimize PayPal requests for approval and let customers specify an amount that is above the base subscription price so that minor purchases do not require approval by anyone with access to the company's PayPal account (unless the customer limits the amount to the original subscription price).
Which PayPal APIs would you recommend in this scenario ?
As I understood it, UpdateRecurringPaymentsProfile does not allow the amount to be increased by more than 20% within 180 days without explicit approval by the buyer, so it probably would not work if we try to first request e.g. $200, then bill only $100 and later increase back to e.g. $150, right ?
The Adaptive Payments API seems to require the seller to bill rather than have PayPal do it on a regular basis, is this correct ?
I don't know it's help full or not right now, As it is a very old post.
Instead of creating recurring profile on PayPal Server, You can store the customer's credit card on the PayPal using REST API: https://developer.paypal.com/docs/api/#vault then every month you can fetch it and charge it like recurring Payment, Also you no need to worry about how many time customer upgrade the subscription you can manage it on your server end, Or When client is no longer with the services then just remove its card from PayPal.
I suppose Authorize.net SIM method also does the same.
Hope this make sense.

Reference transaction with Recurring PayPal payment profiles

I want to modify my billing cycle of recurring payment with a different amount before the next billing cycle starts, and I was suggested that I should use reference transaction for that. But as we know recurring payment profile call does not respond with transaction id then how is it possible to make a reference transaction ?
Please help me with this subject.
Thank You,
If you're working with a recurring payments profile created via Payments Pro or Express Checkout then you'll need to update it using UpdateRecurringPaymentsProfile. You could also do it manually via the PayPal account.
If the profile was setup using a credit card there aren't any limitations to updating the amount. Unfortunately, if the profile was setup using a PayPal account you can only increase the amount by 20% every 180 days.
That's probably why reference transactions were recommended. Using reference transactions you can build your own recurring payments system and avoid this limitation.

Using Paypal API's to process conditional rental payments using PHP

I am building an eCommerce site which gives a user the ability to rent
an item for a designated amount of time. If the item is not returned
within that time, the customer is billed automatically for another rent
cycle. If the item is returned the customer will stop getting billed
for additional rent cycles. If the item is bought the customer will be
billed and an additional amount different from the rent price will be
billed to the customer and the customer will no longer be billed for
additional rent. Most of the billing is ongoing and has too many
variables going on to just have a simple subscription payment method.
I think the sequence of transactions can be initiated with a simple PayPal button form which sends information about my IPN script location, Cancel Payment script location and recurring payment script location.
I find that there are some limitations of what PayPal's API's can do. It seems that the recurring payments API is set up for an amount of set payments set over a specified billing period over a set number of times a customer would be billed. I am not 100% sure on this but I think PayPal only accesses the recurring payment API for a customer once for the initial transaction and executes the continuous transactions without checking my websites internal database which might give data to influence parts of the recurring payment script to cancel continuous payments. An example of when this condition should occur is when a customer returns a product or purchases a product which was already being rented out. PayPal has been terrible at getting back to me about technical problems like this. Another problem with PayPal's recurring payments API is a recurring payment subscription cannot be longer than a year so if a customer is renting an item for 2 years then they would only be charged for the first year.
Any advice on how I can implement a payment system like this using PayPal, if it is even possible would be greatly appreciated. I don't want to have make my own payment gateway if PayPal can do this.

Categories