braintree / braintree_php

Braintree PHP library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
547 stars 224 forks source link

PHP create payment methid fails on invalid keys: options[makeDefault] #303

Closed camohub closed 2 years ago

camohub commented 2 years ago

I have a nonce from javascript dropin. Then I would like to create/update payment method and set it as default. So according documentation I send the makeDefualt option to the paymentMthod->create(). But it throws me an error:

Payment failed. Invalid keys: options[makeDefault]

$braintree_request = [
        'customerId' => $braintree_id,
        'paymentMethodNonce' => $payment_method_nonce,
        'options' => [
          'verifyCard' => true,
          'makeDefault' => true,
        ]
      ];

      $result = $this->braintree->paymentMethod()->create($braintree_request);

What is wrong with this code? I need it cause I hope the front end dropIn will be able to preselect the default card on load. Now the default is the first one stored in the vault.

Also I dont understand how to update payment method if I dont have token but the nonce. Did not find any documentation to that.

Thanks for help.

camohub commented 2 years ago

My fault. I used this in sale().