File tree 4 files changed +61
-13
lines changed
4 files changed +61
-13
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,31 @@ $customer = $gateway->findCustomer(1)->send();
69
69
```
70
70
You can find full list of options [ here] ( https://developers.braintreepayments.com/reference/request/customer/find/php )
71
71
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
+
72
97
###Create subscription
73
98
74
99
``` php
Original file line number Diff line number Diff line change @@ -13,12 +13,12 @@ class UpdatePaymentMethodRequest extends AbstractRequest
13
13
{
14
14
public function getData ()
15
15
{
16
- $ parameters = array ();
17
- $ parameters += $ this ->getOptionData ();
18
-
16
+ $ data = array ();
19
17
$ data ['token ' ] = $ this ->getToken ();
20
- if (!empty ($ parameters )) {
21
- $ data ['parameters ' ] = $ parameters ;
18
+ $ options = $ this ->parameters ->get ('paymentMethodOptions ' );
19
+
20
+ if (null !== $ options ) {
21
+ $ data ['options ' ] = $ options ;
22
22
}
23
23
24
24
return $ data ;
@@ -32,8 +32,28 @@ public function getData()
32
32
*/
33
33
public function sendData ($ data )
34
34
{
35
- $ response = $ this ->braintree ->paymentMethod ()->update ($ data ['token ' ], $ data ['parameters ' ]);
35
+ $ response = $ this ->braintree ->paymentMethod ()->update ($ data ['token ' ], $ data ['options ' ]);
36
36
37
37
return $ this ->createResponse ($ response );
38
38
}
39
+
40
+ /**
41
+ * @param string $value
42
+ *
43
+ * @return \Omnipay\Common\Message\AbstractRequest
44
+ */
45
+ public function setPaymentMethodToken ($ value )
46
+ {
47
+ return $ this ->setParameter ('token ' , $ value );
48
+ }
49
+
50
+ /**
51
+ * @param array $options
52
+ *
53
+ * @return \Omnipay\Common\Message\AbstractRequest
54
+ */
55
+ public function setOptions (array $ options = array ())
56
+ {
57
+ return $ this ->setParameter ('paymentMethodOptions ' , $ options );
58
+ }
39
59
}
Original file line number Diff line number Diff line change @@ -20,16 +20,16 @@ public function testGetData()
20
20
{
21
21
$ this ->request ->initialize (
22
22
array (
23
- 'token ' => 'abcd1234 ' ,
24
- 'makeDefault ' => true ,
23
+ 'paymentMethodToken ' => 'abcd1234 ' ,
24
+ 'options ' => array (
25
+ 'makeDefault ' => true ,
26
+ )
25
27
)
26
28
);
27
29
$ expected = array (
28
30
'token ' => 'abcd1234 ' ,
29
- 'parameters ' => array (
30
- 'options ' => array (
31
- 'makeDefault ' => true ,
32
- ),
31
+ 'options ' => array (
32
+ 'makeDefault ' => true ,
33
33
),
34
34
);
35
35
$ this ->assertSame ($ expected , $ this ->request ->getData ());
@@ -39,7 +39,7 @@ public function testGetDataNoParameters()
39
39
{
40
40
$ this ->request ->initialize (
41
41
array (
42
- 'token ' => 'abcd1234 ' ,
42
+ 'paymentMethodToken ' => 'abcd1234 ' ,
43
43
)
44
44
);
45
45
$ expected = array (
You can’t perform that action at this time.
0 commit comments