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.
Related
We've implemented the Paypal Express API through Authorize.Net in PHP (https://developer.authorize.net/api/reference/features/paypal.html). It was finished over a year ago, and has been working fine. What we realized recently, is that the when the Paypal authorization is updated in step 2 "Authorization Only, Continued", it is not updated in Authorize.Net . When a capture takes place, it only captures the original amount, despite Paypal having the correct, updated amount.
Here is our flow (following the Authorize.Net/Paypal API instructions):
We send a request to Authorize.Net/Paypal to create a transaction. Inside is the total cost of goods.
Paypal returns a secure link, onto which we redirect the user
Paypal redirects the user back to us with a token. We use the token to get shipping data for the user and to get the authorization/transaction ID.
We calculate tax based on shipping data and send the user to a confirm page for review.
When the user submits, we send the second authorization request (Authorization Only, Continued), as documented, using the gateway transaction ID to update the transaction with the new amount, etc.
Now the problem is, Authorize.Net still has the original amount (without the tax). When we run a capture on this transaction via the same API, for some reason it only captures the original amount, not the amount with the tax. We're making tons of transactions now, and not receiving the tax dollars for any of them.
Here is the same transaction in Paypal and Authorize.Net. Paypal's screen shows the authorization at $120, and the update at $130.xx with shipping.
And Authorize.Net shows it successfully captured at $120.
These are the same transaction, and we're only using the Authorize.Net Paypal Express API. How is Authorize.Net not getting the update? Why is it not capturing the full amount?
When we run a capture on this transaction via the same API, for some reason it only captures the original amount, not the amount with the tax.
You need to either:
Capture the second authorization, not the original transaction. This should be the correct solution.
Send a capture request that includes the details of the new amounts you are capturing.
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 have written and successfully processed paypal functions on my clients site. They just want to be able to finalize the bill after they have shipped the product as the cost is very hard to calculate as products vary in size, quantity, ect. I currently have it set up so that they authorize a payment after using express checkout API as I have set $paymentType = "Authorization"; in stead of sale as the paymentType. All orders are tracked and logged in the database of the clients site they get a list of what the customer ordered, shipping info, ect on the admin side of the site. Only problem is once they have completed the order they mark it done on their site they must log into paypal and finalize the order by capturing the funds. How would I go about to capture funds using the classic API? I have found how to do it using the rest api, but I'm not going to rewrite my site to do it.
From the research I have done I have found that you can do it as I stated with the rest api and nvp or merchant api, but I'm using Express Checkout in PHP. I haven't been able to find how to use PHP and capture the funds.
My current code set up looks like this
//Orders are listed out using an array of mysql databases
......
**Where I need assistance**
//Capture funds from Paypal here
//return status of successful via self posting form
....
//And then I have
//a get function that marks the order as completed in the database
To summarize my question is how would(if possible) using the classic api and express checkout capture funds from paypal? As you can see I have given some thought to this I'm just stuck and can't figure it out.
The DoCapture API is what you're looking for. You'll pass in the transaction ID you got back from the Express Checkout Authorization along with the amount you're capturing.
The Problem i am facing is whenever I place order lets suppose payment method is PayPal I am redirected to PayPal website . When i press back from browser my stock gets deducted and i cant see order in My Account also my Cart goes empty . At admin side order is listed as Pending Payment I have to cancel that in order to restore my payment.
Its magento's basic functionality in order to convert such customers into potential ordering ones though calling or emailing.
Below listed plugin would help you :
http://www.magentocommerce.com/magento-connect/magento-pending-orders-automatic-cancelation-with-stockreleaser-by-soon.html
Try PayPal Express instead. The order only will get created in Magento once paid in PayPal. Very easy to implement and saves a big headache of trying to deal with all the side effects of the PayPal Standard setup.
I have successfully posted my custom shopping cart to PayPal -- it processes the order just beautifully, and when the payment is received, it posts data back to the URL I specified in the config. The code is based on the library found here: http://www.phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/
So I'm successfully verifying the IPN by posting data back to PayPal -- that is all great. Here's my dilemma -- how do I know what order the IPN is confirming?
I am not making use of PayPals shopping cart, I have my own. It has it's own cart ID in my database, and when I receive an IPN for that cart, I'd like to "close" the cart and save it as an order to be looked up at a later date.
I've tried passing an additional custom field along with the redirect to PayPal that populates the cart, but that value isn't returned back to me in the IPN. The documentation on x.com is just plain lacking so I've found no help there.
Does anyone have any experience with PayPal and IPN? Doesn't necessarily have to be with PHP -- I can interpret code -- but if you have a way to send a value to PayPal with an order and then have that value returned with the IPN, that is AWESOME!
If this isn't possible with PayPal's API (which I would find hard to believe) -- any other suggestions on how to handle this?
I do not know if this is a good idea or not, but here are a couple different options:
A: Use the first set of on1 / os1 for the item 1 and add the order id to that.
B: In the custom field, I am not sure what you have in there, but you can make it something like orderidhere41|otheritems here and then just parse this out by exploding at the | to get them separated.
Paypal does limit this, and I do not know why, but both of those should work. Doing it as an on / os will put it on the paypal receipt for the user, so that is my preferred method.
If someone else has a better solution, I would be interested in it as well!
EDIT:
Clarifying on1 os1. These are "options" generally used for Size / color etc. See IPN PDT Paypal variables under option_name1 option_selection(sp) for more information on them. The name of course is the title which would be "Order ID" the os would be the actual id.
EDIT:
Looking through that documentation $my2CO->addField('cart_order_id', rand(1, 100)); is where I would put my own cart order id. That should be the correct field. Sorry for the confusion :)
EDIT:
In the end there is a custom field for the paypal IPN, called "custom" adding data to this will pass through, this will transfer the orderid for you to and from. It must be called custom on both sides.
(this may be different for the other API's).
My experience has been with the Express checkout via C#, but the process should be the same even in PHP. If you're using the Name-Value Pair (NVP) interface right before you redirect the user to PayPal you hit the PayPal site to retrieve the redirection URL. As part of their response they pass back a token to you. You save this token along with your order. When the IPN postback occurs you get this same token back which lets you look up the original order.
The process flow looks like this ("You" being your site):
User fills cart, clicks button/link to check out
Request is sent to your site
Your site receives request, sends data to PayPal
You get an initial response from PayPal which contains a token
You save this token along with this user's shopping cart.
You redirect the user to the link returned by PayPal
User is redirected to PayPal and enters payment info
Payment info is validated by PayPal
User is redirected back to your site
PayPal sends IPN response back to your site
You grab the token included in the response
You look up the token you previously saved to find the shopping cart (they are the same value)
You close out the initial order/shopping cart.
You might want to try out the PHP SDK - scroll down to the Name-Value Pair Interface.
I very much doubt this will help the original poster, but PayPal have either added, or finally documented the option "invoice" which allows you to post the OrderID, and have it posted back via the IPN.
I am currently using this and it seems to work as expected.
For further info see the Website Payments Standard Integration Guide (PDF): Appendix A, Table A.4
You can create and post a custom pass-through variable that's 255 characters long that could hold any data. More info on page 44 in the official Paypal IPN Guide.