p16/paypal-rest-api-client

Mandatory keys missing for PayPalRestApiClient\Builder\PaymentBuilder: update_time

SamanShafigh opened this issue · 4 comments

Hi Filippo,

I dont get any error for credit payment and it works fine. But for PayPal I get the following error when I use your sample in https://github.com/p16/paypal-rest-api-client/blob/master/examples/directPaymentPaypalMethod.md

Mandatory keys missing for PayPalRestApiClient\Builder\PaymentBuilder: update_time

In \PayPalRestApiClient\Service\PaymentService::create() function when I dump the $response data everything is looking fine but there is no update_time

array(7) { ["id"]=> string(28) "PAY-5R545178X5293914PKYS5PIY" ["intent"]=> string(4) "sale" ["state"]=> string(7) "created" ["payer"]=> array(1) { ["payment_method"]=> string(6) "paypal" } ["transactions"]=> array(1) { [0]=> array(4) { ["amount"]=> array(2) { ["total"]=> string(5) "12.35" ["currency"]=> string(3) "EUR" } ["description"]=> string(14) "my transaction" ["item_list"]=> array(1) { ["items"]=> array(1) { [0]=> array(5) { ["name"]=> string(12) "product name" ["sku"]=> string(10) "1233456789" ["price"]=> string(5) "12.35" ["currency"]=> string(3) "EUR" ["quantity"]=> int(1) } } } ["related_resources"]=> array(0) { } } } ["create_time"]=> string(20) "2015-10-20T05:56:51Z" ["links"]=> array(3) { [0]=> array(3) { ["href"]=> string(79) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5R545178X5293914PKYS5PIY" ["rel"]=> string(4) "self" ["method"]=> string(3) "GET" } [1]=> array(3) { ["href"]=> string(94) "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9N0830669R685834U" ["rel"]=> string(12) "approval_url" ["method"]=> string(8) "REDIRECT" } [2]=> array(3) { ["href"]=> string(87) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5R545178X5293914PKYS5PIY/execute" ["rel"]=> string(7) "execute" ["method"]=> string(4) "POST" } } } 

I have tested it with curl and this document: https://developer.paypal.com/docs/integration/web/accept-paypal-payment/

The result is as follow which is exactly same as the above result:

  {"id":"PAY-4ED060449M2129630KYS5KPI","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"7.47","currency":"USD"},"description":"This is the payment transaction description.","related_resources":[]}],"create_time":"2015-10-20T05:46:37Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4ED060449M2129630KYS5KPI","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-28V27846ER6903718","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4ED060449M2129630KYS5KPI/execute","rel":"execute","method":"POST"}]}

Could you please let me know if I miss anything

In PayPalRestApiClient\Builder\PaymentBuilder::build(array $data)
if I do something like this it will solve my problem but I am not sure if it is Ok or not:

    $this->validateArrayKeys(
        //array('id', 'create_time', 'update_time', 'state', 'intent', 'payer', 'transactions', 'links'),
        array('id', 'create_time', 'state', 'intent', 'payer', 'transactions', 'links'),
        $data
    );

    $data['update_time'] = $data['create_time'];
p16 commented

Hi @SamanShafigh,
I'll take a look at it and I'll let you know.

Thanks for reaching out!

Filippo

p16 commented

@SamanShafigh I'm looking into this. The paypal documentation says we should get an update_time in the response https://developer.paypal.com/docs/integration/web/accept-paypal-payment/#specify-payment-information-to-create-a-payment (see Response section).

But given that it is not anymore in the actual api response (I tried it as well) I'll remove it :)

p16 commented

Hi @SamanShafigh , I've released a new version without the update_time and with a couple of other changes

https://github.com/p16/paypal-rest-api-client/releases/tag/v0.1.2
https://packagist.org/packages/p16/paypal-rest-api-client#v0.1.2

Thanks for reaching out