File tree Expand file tree Collapse file tree 4 files changed +61
-13
lines changed Expand file tree Collapse file tree 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();
6969```
7070You 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
Original file line number Diff line number Diff line change @@ -13,12 +13,12 @@ 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 ;
18+ $ options = $ this ->parameters ->get ('paymentMethodOptions ' );
19+
20+ if (null !== $ options ) {
21+ $ data ['options ' ] = $ options ;
2222 }
2323
2424 return $ data ;
@@ -32,8 +32,28 @@ public function getData()
3232 */
3333 public function sendData ($ data )
3434 {
35- $ response = $ this ->braintree ->paymentMethod ()->update ($ data ['token ' ], $ data ['parameters ' ]);
35+ $ response = $ this ->braintree ->paymentMethod ()->update ($ data ['token ' ], $ data ['options ' ]);
3636
3737 return $ this ->createResponse ($ response );
3838 }
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+ }
3959}
Original file line number Diff line number Diff line change @@ -20,16 +20,16 @@ public function testGetData()
2020 {
2121 $ this ->request ->initialize (
2222 array (
23- 'token ' => 'abcd1234 ' ,
24- 'makeDefault ' => true ,
23+ 'paymentMethodToken ' => 'abcd1234 ' ,
24+ 'options ' => array (
25+ 'makeDefault ' => true ,
26+ )
2527 )
2628 );
2729 $ expected = array (
2830 'token ' => 'abcd1234 ' ,
29- 'parameters ' => array (
30- 'options ' => array (
31- 'makeDefault ' => true ,
32- ),
31+ 'options ' => array (
32+ 'makeDefault ' => true ,
3333 ),
3434 );
3535 $ this ->assertSame ($ expected , $ this ->request ->getData ());
@@ -39,7 +39,7 @@ public function testGetDataNoParameters()
3939 {
4040 $ this ->request ->initialize (
4141 array (
42- 'token ' => 'abcd1234 ' ,
42+ 'paymentMethodToken ' => 'abcd1234 ' ,
4343 )
4444 );
4545 $ expected = array (
You can’t perform that action at this time.
0 commit comments