robmcvey / cakephp-paypal

CakePHP 2.0 plugin for PayPal Website Payment Pro
60 stars 44 forks source link

storeCreditCard Response #42

Closed kriskd closed 9 years ago

kriskd commented 9 years ago

The responseArray for the storeCreditCard method looks for a code key, which doesn't appear to exist according to the API documentation: https://developer.paypal.com/docs/integration/direct/rest-vault-overview/#store-a-credit-card. Rather should the check be for an id or perhaps a value for state although I'm unsure what the other values besides "ok" might be. Also, the URL reference to the Paypal API is incorrect.

Let me know if you agree and I can submit a PR.

robmcvey commented 9 years ago

Hi Kris,

I think you're referring to this line, the response->code is the HTTP status code returned from HttpSocket, then as long as we get a HTTP 200 we decode the JSON from PayPal (in response->body) and check the state key.

I managed to find the docs for the credit_card object and they read as follows;

string State of the credit card funding instrument: `expired` or `ok`. Value assigned by PayPal

...so I think we're good to just check for a 200 response, then ensure the state is ok, we can then assume the card is stored.

Good spot on the dead link! I'll update this.

Thank you! :+1: