I've a problem with the Express Checkout REST API : after that the user has approuved the transaction with the paypal form, I call the "execute" method by passing the payment attributs (token, id, payerId,...). In the returned data, the status of the payment is indicated as "approved".
My trouble is that although the payment is well present of the activity list of the sandbox acount that i use for my tests, it still labelised as "pending".
I've tried to use the REST API with the PHP SDK and without the PHP SDK (I'm calling URL's with Curl), I've the same problem !
I'm using the same currency of the default user currency and the manual approbation is well disabled for the user.
I'm working on this problem since 1 month and I can't solve it !
Please, anyone has a solution or a part of response?
Thankz by advance,
Mickaƫl
Related
I am currently using the current PayPal plugin https://wordpress.org/plugins/woocommerce-paypal-payments/
I have used the PayPal API to render more than one PayPal button on a page as the above plugin does not allow you to do this.
After the PayPal transaction is approved, it runs a PHP function that creates a WooCommerce order and fills in the data from the PayPal transaction such as the refund ID and setting the correct payment gateway etc. This all goes through great, but when it comes to refunding with the above plugin it fails.
I have compared the CSV files from both the API implementation and standard checkout process and both seem to be bringing in the same data.
I have done a bit of research and it seems that if an order is placed through checkout with the plugin, it creates its own order id, which may link back to the correct refund ID from the transaction. I have contacted their plugin support, but they have been unable to tell me.
Any help on this issue would be greatly appreciated!
When that plugin creates an order, an invoice_id and custom_id are set on these lines in the code.
The invoice ID is later used when doing a refund.
If you backtrack through that code doing the refund, it first makes use of a GET API call to the PayPal Order endpoint, which happens within here.
I highlight the particular line where this GET call depends on some meta information with the PayPal Gateway Order ID.
As an aside, this refund process is not well implemented by this WooCommerce plugin. Refunds are ultimately done using a capture ID, and should not rely on the Orders endpoint being accessible to provide a GET response that includes that capture ID. It works well enough so long as the PayPal Orders endpoint retains a record of that Order ID (which is not forever, as it's not an accounting value), but this is wrong to rely on. Instead, the Capture ID (eq. to the PayPal transaction ID) is what should be stored at transaction completion/capture time (as meta), and that stored meta value can then later be directly used to use the v2/payments refund, with no GET API request to the Orders API endpoint. The Orders API endpoint is only meant to be used during checkout approval, it is incorrect to be relying on it for anything once an order capture is successfully completed.
I am implementing PayPal payment to my application.
I am using Laravel Framework and merchant-sdk-php package to handle NVP/SOAP API. I would accually prefer REST API, but i need customers to make Reference Transactions with various amount, in non regular time periods and as far as i know it's possible only with NVP/SOAP API.
The payment flow in shortcut:
1. Payer clicks "connect" button, which is to create billing agreement using "SetExpressCheckout" method. Amount is set to 0 and adding a Billing Agreement field to request. Customer is redirected to PayPal, log in to his account, agreeing to direct debit and finally redirected to my return url.
2. After response is come, return action is fired (the one, which is passed in returnurl field). Next using token from paypal resposne i use CreateBillingAgreement method to get "BillingAgreementID" which i store in database.
3. Using "BillingAgreementID" i make "DoReferenceTransaction" request. No prompt to login is occurring, everything is happening behind the scene. Finally i get response after transaction.
The thinks i want to know are:
1. Is there a way, to get an email address, which consumer used to log in when creating billing agreemenet? I want to show in application which PayPal account (related to mentioned email) is direct debit set to?
2. I want to make some action in databse both after "BillingAgreementID" and "DoReferenceTransaction". Is the response status "Success" and additionally in "DoReferenceTransaction" field "PaymentStatus" set to "Completed" enought to conclude, that transaction is fully completed, and i cant i.e. share some digital goods or should i wait for IPN from this request?
Thanks for all contributions!
Found solution to question 1.
After betting billing agreement id i had to make "GetBillingAgreementCustomerDetails" action. In response i got customer details including email.
Still watching for hint to second question
I am trying to integrate the PayPal REST API into my Symfony 2 web app but I find hard to understand how exactly the complete workflow looks like:
The PayPal docs describe the following steps to accept a payment. One can use the PayPal Playground to simulate these steps:
Get an access token
Create a Payment object by querying the API
Redirect the user to the approval url received in the Payment response
After the user approved the payment on the PayPal page, he is redirected back to my page, using the success-link defined in the Payment object. Use the received information to execute the payment.
Payment is completed with status approved
From the docs: Once a payment is complete, it is referred to as a
sale. You can then look up the sale and refund it.
So far so good. BUT: Where are Webhooks used/fired in this workflow? I have defined a wildcard Webhook (accepting all possible events) in the PayPal Developer Dashboard.
My observation is, that my system receives the Webhook event 1-2 Minutes (!) after the user was redirected back to the success-link and after the payment was executed (Step 4).
Beside this long delay between executing the payment and receiving the Webhook, this workflow means, that I only receive the Webhook AFTER handling the success-link. This means, handling the success-link is absolutly necessary for the payment to be completed. Is this correct?
Do I need to use Webhooks?
I already asked this question a few days before and the answer by nifr is quite reasonable: One cannot trust the user to follow any redirect URL but should only rely on the Webhook events.
However this collides with the observations I described before, since I will never receive the Webhook without handling the redirect URL...
So, handling the PAYMENT.SALE.COMPLETED webhook event does not make a lot of sense, since this should already be done in when handling the redirect URL. Correct?
However, to handle updates on pending payments, handle refunds or reversed payments, etc. are only possible by listening on those events.
So the answer is: Only use Webhooks to get updates on payments made before. Correct?
So, the main questions are:
The 5-step process to accept payments does not say anything about using Webhooks. This does not seem to make a lot of sense, because without Webhooks one would miss update events, etc.? So, is it really possible to implement the complete payment workflow without Webhooks?
If yes, how are updates (refunds, pending, etc) handled in this case?
If no, what is the right strategy/time to fulfill the order since it take quite a long time to completly receive and handle the webhook?
i am still a newbie in PayPal world, but few days ago i integrated PayPal Plus REST API in an online Shop, and from my understanding i can tell that the workflow looks like:
create a Payment
redirect to PayPal
Payer could pay using PayPal account OR (using Bank Direct debit or Credit Card Payment without PayPal Account)
After completing the process on PayPal side, PayPal redirect the user back to your success URL.
till now the user is still not charged(you got no money). At the moment where you (in your success URL) do $payment->execute($paymentExecution,$api); , you ask Paypal to charge the amount from user. BUT also after this, you got no Money. Paypal have first to process the charging and notify you later via WebhookEvents.
the Webhook Notification (with that nasty delay) is especially important when the user pays per direct debit or Credit Card etc. Processing such Payments takes few seconds/minutes.
the redirectUrl ist absolutly necessary for charging/executing the Payment.
here on execution succeed, just to tell the user, that he finished his Job, and you can here save/capture the PaymentID/Transaction id for later usage/update via WebhookEvent Listener.
so i would recommend you to update your Database(Payment completed) only after receiving notofications via WebhookEvent Listener and not in the success RedirectUrl.
Im haing a problem iv been researching for weeks now on the paypal API but i just can't figer how to do this.
I need there to be a button on my website which then it goes to paypal.
Once you have paid the chosen amount it goes to a php page which updates the database though php.
You have to turn on paypal ipn in your paypal preferences. Once paypal has the money it sends you a transaction back to your server. In the script that accepts the transaction you can have it update your tables.
Documentation : https://www.x.com/sites/default/files/ipnguide.pdf
generally you pass a notify_url parameter with the request, and set up a page which handles and validates IPN notifications, and PayPal will send requests to that page to notify you when payments/refunds/etc. go through. That IPN handler page would then be the correct place to update the database to mark orders as having been paid.
i found a tutorial here: http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/
I found more suitable the PayPal NVP API instead of tradional IPN (Instant Payment Method)
You can find several code examples for PHP (including very similar to your problem and more advanced) in the library code for NVP samples
I am working on a PHP website with Google checkout Payment. I need to get the transaction id in the merchant calculation page using API Call back url. What method can I use for this?
Google Checkout offers a service similar to Paypal's IPN where they send all of the transaction information to a URL you specify. This includes the transaction number.