I would like to know if I can add some info to transaction AFTER the payment.
My web-app issues tickets but it knows the ticket-id-number only after the payment completion and I want to fill the transaction info with this details in case of contentious to prove that a ticket identified by its number was issued for that transaction.
Can I change or add item details after the payment?
There is no way to update the payment after the /execute call at least when you use intent as "sale"
A possible option would be to use intent as "authorize". when you do that /execute will return you an authorization id. since the payment is authorized you should be able to safely generate a ticket #
then when you are expected to do https://developer.paypal.com/docs/api/payments/#authorization_capture
POST /v1/payments/authorization/{authorization_id}/capture
within this there is an option to pass an invoice_number - you could potentially use it to pass the ticket# ? such that your payment capture always has a reference to the ticket #
Now there is a chance that capture might fail but it should really be negligible as PYPL wouldn't authorize if it doesn't think it can capture especially in your case when you would initiate a capture moments later.
Related
I'm trying to integrate "Paypal smart buttons" in my webpage which was with a deprecated paypal implementation.
On this new integration I'm using server-side SDK and I can create and capture an order and save data in my DB.
The problem I have now is to implement the refund.
On my last implementation I had an IPN Listener and whenever I get a refund I could register it in my BD.
Since now IPN listener is deprecated, how can I implemented the "listener function"? Is the webhooks the new approach to implement the listener? I know that with Webhooks Management API I can list all webhooks events, but then how can I related them with the payment made and registered before in my BD?
I've already read lots of official paypal documentation but this is no clear to me, yet.
Register a webhook listener URL for the events you want, including refunds.
When you receive a refund webhook event at that URL, the body of the webhook will contain information about the capture/payment object (transaction id) that was refunded.
If in addition to the capture/transaction id you need some additional id for reconciliation purposes, there are two pieces of information you can include in the original order creation.
an invoice_id, which is essentially your system's unique order ID. It must be unique, never used before for a successful completed transaction since it is used to block any future duplicate (accidental) payment attempts of the same ID.
a custom_id, which can have any arbitrary value and is not indexed and not visible to the payer.
I get it that Paypal SDK (backed by REST API) has three steps:
Create a payment
payment = Payment({...})
payment.create()
return redirect( redirect_url( payment))
The customer pays and authorizes payment from within Paypal
Redirect to our site where we execute payment, thus transferring money
Should I store the created payments at step 1? I would thus capture all payment attempts, whether successful or not. Or can I create a payment, and not remember it until step 3? That is, record only the successful payments (within their respective Invoices). Is there any reliability or security issue or other harm if I do not store it at step 1?
I suspect not being able to roll back failures.
In Paypal terms, they are of sale intent and are meant for payment of invoices for services rendered. Card data do not touch our servers, I am deferring to Paypal on handling it.
I use paypalrestsdk, Paypal's Python SDK.
Previously, it was tricky to get the PaymentId back when PayPal redirects the page back to your server to authorize you, as there was no way to get PaymentId on 3rd step
However, now, the PaymentId is returned back as a part of the URL as shown here in 3rd step :
http://localhost/Server-SDK/PayPal-PHP-SDK/sample/payments/ExecutePayment.php?success=true&paymentId=PAY-62998961VU1587338KR3AXWQ&token=EC-4YC2489096181311L&PayerID=REABK2UGK7PLW
As you can see it has paymentId which is the Id that you need to store.
So, to answer you dont need to store anything till 3rd step.
Additional Note:
However, if you have some complicated logic/service you want to provide. E.g. send them an email reminder(if you have their emailId), to remind them if they abandoned your card, etc. However, there are many ways to do that besides using these steps.
We have a requirement where we need to run the auto payment for the PayPal payment for next scheduled order's with out user interaction.
We are able to achieve this using Billing AgreementId that we processed during the user first transaction.
My question is We just need "DoReferenceTransactionReq" or after that even we need to do DoAuthorization. Please suggest.
Before this for the First transaction we are following api call:
1.SetExpressCheckoutReq
2.GetExpressCheckoutDetailsReq
3.DoExpressCheckOutPaymentReq
If you've already gone through the Express Checkout flow and created a Sale or Authorization transaction there, then all you need to do is pass that transaction ID into DoReferenceTransaction to process the new amount. DoAuthorization would simply create another fresh authorization and is not needed to run reference transactions.
As recommended by PayPal I am using a combination of the PayPal API and the IPN to create a 'Adaptive Payments' flow.
When my IPN listener receives a new notification from PayPal I have two options (after security checks):
1) Use the received data to make direct actions in my website (for example set a preapproval as approved)
or instead a more secure and clean way (I think):
2) Detect the transaction type variable (or other identifier) and request more details from PayPal accordingly.
For example if the 'transaction_type' is 'Adaptive Payment Preapproval' then I will use the received 'preapproval_key' to request the preapproval details using the PreapprovalDetails API call and then use the received data of that call to set the preapproval as approved.
Is this (option 2) the better way to go?
Thanks.
In general there is probably enough information in the IPN for you to act on, but IPNs are pretty confusing what with all the optional fields and the way that there is no payment_status or txn_id on subscribe events, and no subscription information on payment events, so marrying them up can be interesting. You may well find it easier to understand if you go ahead and get the relevant information from them for each IPN via their API as you suggest.
I want to make payment process in 2 step , in first step paypal should collect fund from user account but not transfer to the merchant account .
when i send another request with sucess action at that type paypal should transfer fund to merchant account or if i pass fail action then paypal should refund to user.
is there any way to do this ?
i reefer following URL but cant find solution .
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_WPECIntegration#id0861K0T0WY4
Express Checkout is what you want, but there's better documentation available.
Basically, what you're after is Authorization and Capture. When you create your Express Checkout API requests you'll set the PAYMENTACTION to Authorization. Then, when you're ready to process the payment you call DoCapture and pass in the transaction ID you get back from Express Checkout.
No money is processed until the DoCapture call is processed. If you don't end up needing to process it you can simply do nothing, but that would strand the authorization on the user's account for the default period of time depending on their bank. Usually 30 days.
It's a better practice to call DoVoid at that point, which would cancel the authorization and release those funds back to the user's account immediately.
If you want to do the same thing with credit cards directly you can use Payments Pro. The process is almost identical, except there are actually fewer calls involved.
If you're using PHP I would recommend taking a look at my PHP class library for PayPal. It'll make all of this very simple for you, and I can provide 30 min of free training to help you get going if you want, too.