Categories
Internet PHP

Pay directly to paypal account – Adaptive Payments

We all know how chaotic is the Paypal documentation, links that do not exists, code samples that dont work, bugs on the SDKs and long ETC.

I wanted to be able to pay our customers directly to their paypal account without the receiver interfering, like a bank transfer let’s say but to paypal.

This can be achieved using Paypal Adaptive Payments and an implicit payment.

Implicit approval payments, in which your application is both the sender of a payment and the caller of the Adaptive Payments Pay API. In this case, PayPal makes the payment from your own account, which eliminates the need for approval.

We have a nice code sample in their site, you can find it here. https://devtools-paypal.com/guide/ap_implicit_payment/php?interactive=ON&env=sandbox

You can even test it directly there which is really nice and you will see that it works….

Nice, no? ahaaaaaaaaa don’t go too fast. In this same site they point you to the SDK they use, but the link is not working….not big deal you can find it on github here PHP SDK for integrating with PayPal’s AdaptivePayments API.

Well you can use this package with composer or you can use an optional loader which doesnt work….

It does not work because they forget to mention to execute an installer at /samples/install.php , this will download the core SDK of paypal too and create a PPAutoloader.php specially for your installation.

Then just with the loader should work the example…but still doesn’t….

Here the final code that at least did work to me.

The payment is completed without redirecting to PayPal. A JSON response will be returned containing paymentExecStatus (“CREATED” means that all went good).

Also and last do not forget that you need to apply to get an application ID. Get application API access register new app here. May take some days…patience…

Obviously paypal is doing things really bad for developers and potential new customers by having huge barriers to implement their solutions lack of documentation etc. That’s why they bought braintree a couple of years ago, still lame…