These are the reasons why I have decided to work on a new client:
- Using the official SDKÂ felt a bit awkward: a lot of setters, a lot of static methods and a lot of coupling between classes.
- I tried to contribute to the official SDK and I failed: I gave myself a week (after work hours)Â to get a better understanding of the SDK, and to come upÂ with a PR to make the SDK tests run without calling the actual paypal sandbox endpoints. At the end of 6/7 hours of work,Â I didn’t submit a PR: it would have broken a lot of interfaces and there were stillÂ tests calling the sandbox endpoints.
- No way of mocking the class making the calls: I was using the official SDK on a side project, and it was not possible to mock onlyÂ the class that made the real calls – because it was alwaysÂ instantiated with a “new”. I had to implement a class that contained all the logic for using the SDK and mock that.
- I didn’t need to call all the endpoints: I only needed to get direct payment working with “paypal” payment method.
So these are the reasons why I delved into the PayPal REST API reference. IÂ played around to make calls and see if I could come up with an OO library that did only what I needed.
WhitÂ PHP PayPal REST API ClientÂ you can:
- make direct payments using “paypal” method
- make direct payments using “credit_card” method (only in some countries)
- authorize and capture payments using “paypal” method
- authorize and capture payments using “credit_card” methodÂ (only in someÂ countries)
To start using the library just addÂ the following line to your composer.json
and then run
composer update p16/paypal-rest-api-client
Giving back to the community much less thanÂ what I’ve taken!
Feedback, PR and suggestions are more than welcome!