Paypal API : PAYEE_ACCOUNT_INVALID
Housni BENABID
Tech Lead Full-stack Software Engineer | Former Prestashop Ambassador | Passionate about Golf & Chess
I spent my weekend figuring out why I’m facing this issue while integrating?#PayPal?sandbox mode in the company payment processor. So I think my modest discovery is worth sharing with you guys; maybe it can help someone out in the future. As I couldn’t find any solution on the web.
First of all, let me list the steps you should follow to capture a transaction through PayPal briefly.
1- You get the access token. If you wish to process all the upcoming steps with a Bearer auth, you can skip this step. If you wish to use Basic Auth, you can skip this step.
2- You ask for “Billing Agreement Token” (BA).
3- Once the BA is approved, you get the BA details based on the token you got from step 2.
4- You create the order. In this request, you specify the merchant_id (merchant_email is not optional).
5- You capture the order.
If you check the?#PayPal?documentation, it says that this error PAYEE_ACCOUNT_INVALID can be faced ONLY in the order creation step, which is step 4. And it wasn't the case. It was on step 5.
领英推荐
The?#PayPal?documentation says that the error means there’s a mismatch in the merchant_id or merchant_email, which also wasn't the case.
So, after many tests and many failed transactions, I noticed one small detail. In step 3, you get a response from the PayPal API with some details of the BA. The important detail for me was the merchant email. The merchant email was completely different than the merchant account I integrated in the app. How is it impossible? How will the PayPal API provide a different merchant email even though the Bearer token was provided?
Finally, the funny issue was… Normally, in the sandbox mode, PayPal offers two default accounts for testing: a personal and business account. And you can create more accounts if you wish. So, for testing, I created a new business account and integrated it into my profile for payment processing.
But the PayPal API always considers the default business account as the merchant of the transaction. So the merchant email I was getting in step 3 was the default business email of the sandbox mode.
In conclusion, it was found that the PAYEE_ACCOUNT_INVALID error occurred during the capture order step (step 5) instead of the order creation step (step 4) as stated in the PayPal documentation. Further investigation revealed that the error was not caused by a mismatch in the merchant_id or merchant_email, but rather by the fact that the PayPal API was using the default business account as the merchant for the transaction, despite a different business account being integrated into the app for payment processing. This issue was resolved by using the default business account for testing purposes. It is hoped that this information will be useful for others who may encounter similar issues while integrating PayPal sandbox mode in their payment processors.