PayPal : Authorize once, capture in multiple parts - paypal

I know that PayPal supports generic authorization/capture and I know that they support capturing an amount less than the authorized amount. But is there some way to capture multiple, separate small amounts that add up to the authorized amount?
My use case roughly as follows: Orders can have multiple items. They may not ship at the same time. We would like to defer the billing for each item until it ships so that people can cancel the item before then and we don't have to pay processing fees on the refund. We don't want to have to do separate orders with separate authorizations because that would be really annoying for the user. We just want to have a cart that is authorized at one time from the user's side and captured per-item from our side.

When you use the Payments v2 API, there is a final_capture parameter to indicate whether there will be more captures, or not.
See the documentation: https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture

Related

Is it possible to block an amount in Paypal like a credit card

I am starting a business and I would like to offer Paypal as a payment option, but for my business it is essential to be able to block an amount of money, just like a car rental or a hotel does on a credit card. Would it be possible to block an amount from my users PayPal account and release it or book it for good later?
My business is of course an online service, and I want to do this pragmatically in a Spring based application.
I think what you are looking for is Authorization and capture.
I haven't used that feature from Paypal, but have used it elsewhere. What you are looking for is usually called card authorization, preauthorization, or preauth.
Yes it's possible
PayPal's REST API offer 3 primary ways to ensure you paid for product/services that you give to your customers
sale. Makes an immediate payment so you get paid immediately
authorize. Authorizes a payment for capture later.(this is what you see in a car rental or hotel)
https://developer.paypal.com/docs/integration/direct/payments/authorize-and-capture-payments/
order. Creates an order. - which gives you the flexibility to
multiple to do multiple authorizations and captures (these are for
complex use cases such as when you buy a computer from Dell you would
be authorized for the desktop, monitor, keyboard at different points
of time based on availability and then the funds captured when they
are shipped)

Paypal how to differentiate between multiple subscriptions for a same user

I'm currently programming a small basket app and I was wondering what was the variable that would be used to differentiate between subcriptions for one user.
Let say my user has 4 subscriptions, and it is now the time to receive its recurring payment. I receive the payment message from Paypal, parse it and do my DB update. How do I know which recurring I need to process?
From what I read, its probably the subscr_id=I-HPDM8GP... that I need to check but I'm not sure?
Thanks
This is a pretty broad question so I'm going to have to make a couple of assumptions...
1) You're using standard subscription buttons..??
2) You have a users table in your database already, and it relates to an orders/invoices table in your database by customer ID..??
If those assumptions are accurate, then what I would recommend is that you include the order ID from your system in the "invoice" parameter with the subscription button code.
If you're not already using it then it would be wise to setup an IPN solution to process subscription payments, and within the IPN data you would get the same order ID back in that "invoice" parameter, so within that solution you could update your system accordingly using that order ID which then relates back to your customer IDs in your own system.
With all of this data included and related correctly in your system you could easily pull reports for different users that include all of their subscriptions and payment history.

Using PayPal subscription IPN fields to manage user accounts

I'm using PayPal to take subscription payments for access to a website service.
I'm using PayPal's IPN to manage the payments and user accounts.
I'm sending a custom random key to PayPal, unique to each user, when the subscription is first instantiated so the same key is sent back with every IPN. This means I can bind together my users table with my PayPal notifications very positively.
Accordingly I can now generate from my database a list of user_ids and notification details.
So now I need to figure out the best logic to use to calculate each users current payment status and, as a consequence, what to do with their account - whether to continue allowing access, suspend or even delete their user account. This decision will all come down to whether their payments are still coming through or not.
A bunch of interesting an varied data comes through on PayPal's IPN - most looks irrelevant in terms of user account management but a couple of columns look quite useful. Specifically...
Field outstanding_balance appears to contain exactly that - a value to 2dp of money still owing. So far during my testing this figure has only ever been 0.00
Field txn_type shows me any from a selection of different codes: subscr_signup (when the user initially sets up the subscription), subscr_payment (when a payment appears to be successful), subscr_cancel (this seems to appear whether the customer or vendor cancels the subscription), and subscr_eot (end of term - this one crops up shortly after the subscription is cancelled).
My impulse is to search the table for the most recent txn_type="subscr_payment" entry for each user account, and check the date this last notification arrived. If it is date stamped over, say, 28 days ago the account can be suspended... if it's over 56 days the account can be deleted.
Is this a good idea? Or is there better logic I can employ?
I've done this. Quite simple:
Don't grant access until you receive the first payment. You can get the intial signup and payment in either order.
PayPal will notify you if they cancel their subscription or it expires. When you get either of those, deny access as from the effective date.
If the most recent payment status on an account is 'reverse', suspend access until you either get 'cancel reverse' or the situation is sorted out in some other way.
Don't count the days. PayPal counts the days. All you can get from repeating that yourself is a disagreement, and guess who's right? PayPal. And guess who isn't wrong? The customer. You don't want to penalise the customer because PayPal got behind or had a different idea of 28 days from yours. You've handed responsibility for collections and renewals to PayPal: let them do it.
Beware of building policy into this. It should just be a mechanism, and it should be manually overridable. For example, the actual evaluation of whether this user has access to this product now mustn't be a computation over their payment history. Just a simple lookup of another table, which your IPN code can modify, but so can humans. For example: there is a dispute. You lost. You might well as a matter of business want to keep the customer alive for a grace period anyway. Alternatively you might in extremis want to fire the customer immediately, e.g. for usage violations.
You can ignore the balance field. The only important thing is the txn_type.

What happens if I capture less amount than the authorize one(Paypal)?

I have to provide a solution using DoDirectPayment API Operation (Website Payments Pro) wherein the user is authorized for a particular amount and depending upon the service provided to him, the amount will be captured at a later stage but only once. I have following query before I finalized the implementation I am going to have:
Suppose I use the one time Capture method - What happens if I capture only $10 though I authorize the Card for $20? Does it make sense? OR should I go for partial capture feature of the paypal?
Thanks in advance.
Yes, from what I understand that is precisely what you would need to do. Here is more information on PayPal Auth/Capture: https://developer.paypal.com/docs/classic/admin/auth-capture/
From the website:
Once an authorization has been made, you can:
Capture either a partial amount or the full amount of the authorization.
Reauthorize for a different amount — You can reauthorize for up to 115% of the originally authorized amount, not to exceed an increase of $75 USD.
Void the authorization, if you need to cancel the transaction.

Booking system to take a deposit and then final amount at a later date

This is more of a question regarding flow than code.
I'm currently working on a booking website for a holiday home. I've implemented a booking system which currently takes full payment at the time of booking. This uses PayPal REST API. It works fine no problems code-wise.
However my client would like the system to take a deposit when booking (20%) of the total. Then take the remaining amount later on (through the site). This seems strange to me and I've never used a website which does this so I'm not sure what the flow should be.
The only way I can think of achieving this is that the user has to come to the website at some point in the future to pay the remaining amount. I could send them email reminders but it seems a bit awkward to do that.
Has anyone done anything like this in the past?
In order to take the money later, you need to store the credit card data in your system, which is not quite legal unless you are authorized payment service provider (and I'm almost sure you're not).
We have the same case in our reservation system. Generally, you'd allow credit card payment only for deposit, and later final amount is paid via bank transfer or cash, for example, and has to be settled manually by an operator.
Your idea is not bad, however. You could inform the user about the final amount and due date in the booking confirmation email and later on send them reminders.
You can utilize reference transactions to handle this without storing/saving any billing information on your server.
Reference transactions can be used in Express Checkout as well as with Payments Pro.
Basically, the way it'll work is that you can process the original 20% and then you'll save that transaction ID in your database. Once you're ready to process the remaining amount you just make a call to DoReferenceTransaction and supply the original transaction ID along with the new amount to charge. PayPal will then charge this new amount using the billing information that they have saved on their server.