Skip to content

Commit 116d5f1

Browse files
author
Konstantinos Christofilos
committed
Fix update payment method
1 parent a0c8b21 commit 116d5f1

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ $customer = $gateway->findCustomer(1)->send();
6969
```
7070
You can find full list of options [here](https://developers.braintreepayments.com/reference/request/customer/find/php)
7171

72+
### Create payment method
73+
74+
```php
75+
$method = $gateway->createPaymentMethod([
76+
'customerId' => $user->getId(),
77+
'paymentMethodNonce' => 'paymentnonce',
78+
'options' => [
79+
'verifyCard' => true
80+
]
81+
]);
82+
```
83+
You can find full list of options [here](https://developers.braintreepayments.com/reference/request/payment-method/create/php).
84+
85+
### Update payment method
86+
87+
```php
88+
$method = $gateway->updatePaymentMethod([
89+
'paymentMethodToken' => 'token123',
90+
'options' => [
91+
'paymentMethodNonce' => 'paymentnonce'
92+
]
93+
]);
94+
```
95+
You can find full list of options [here](https://developers.braintreepayments.com/reference/request/payment-method/update/php).
96+
7297
###Create subscription
7398

7499
```php

src/Message/UpdatePaymentMethodRequest.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ class UpdatePaymentMethodRequest extends AbstractRequest
1313
{
1414
public function getData()
1515
{
16-
$parameters = array();
17-
$parameters += $this->getOptionData();
18-
16+
$data = array();
1917
$data['token'] = $this->getToken();
20-
if (!empty($parameters)) {
21-
$data['parameters'] = $parameters;
22-
}
18+
$data['parameters'] = $this->parameters->get('paymentMethodOptions');
2319

2420
return $data;
2521
}
@@ -36,4 +32,24 @@ public function sendData($data)
3632

3733
return $this->createResponse($response);
3834
}
35+
36+
/**
37+
* @param string $value
38+
*
39+
* @return \Omnipay\Common\Message\AbstractRequest
40+
*/
41+
public function setPaymentMethodToken($value)
42+
{
43+
return $this->setParameter('token', $value);
44+
}
45+
46+
/**
47+
* @param array $options
48+
*
49+
* @return \Omnipay\Common\Message\AbstractRequest
50+
*/
51+
public function setOptions(array $options = array())
52+
{
53+
return $this->setParameter('paymentMethodOptions', $options);
54+
}
3955
}

0 commit comments

Comments
 (0)