Skip to content

Commit 2b6cf03

Browse files
committed
Add more fields
1 parent 665bb60 commit 2b6cf03

File tree

3 files changed

+251
-1
lines changed

3 files changed

+251
-1
lines changed

src/Message/AbstractRequest.php

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,223 @@ public function setPrivateKey($value)
7070
return $this->setParameter('privateKey', $value);
7171
}
7272

73+
public function getBillingAddressId()
74+
{
75+
return $this->getParameter('billingAddressId');
76+
}
77+
78+
public function setBillingAddressId($value)
79+
{
80+
return $this->setParameter('billingAddressId', $value);
81+
}
82+
83+
public function getChannel()
84+
{
85+
return $this->getParameter('channel');
86+
}
87+
88+
public function setChannel($value)
89+
{
90+
return $this->setParameter('channel', $value);
91+
}
92+
93+
public function getCustomFields()
94+
{
95+
return $this->getParameter('customFields');
96+
}
97+
98+
public function setCustomFields($value)
99+
{
100+
return $this->setParameter('customFields', $value);
101+
}
102+
103+
public function getCustomerId()
104+
{
105+
return $this->getParameter('customerId');
106+
}
107+
108+
public function setCustomerId($value)
109+
{
110+
return $this->setParameter('customerId', $value);
111+
}
112+
113+
public function getDescriptor()
114+
{
115+
return $this->getParameter('descriptor');
116+
}
117+
118+
public function setDescriptor($value)
119+
{
120+
return $this->setParameter('descriptor', $value);
121+
}
122+
123+
public function getDeviceData()
124+
{
125+
return $this->getParameter('deviceData');
126+
}
127+
128+
public function setDeviceData($value)
129+
{
130+
return $this->setParameter('deviceData', $value);
131+
}
132+
133+
public function getDeviceSessionId()
134+
{
135+
return $this->getParameter('deviceSessionId');
136+
}
137+
138+
public function setDeviceSessionId($value)
139+
{
140+
return $this->setParameter('deviceSessionId', $value);
141+
}
142+
143+
public function getMerchantAccountId()
144+
{
145+
return $this->getParameter('merchantAccountId');
146+
}
147+
148+
public function setMerchantAccountId($value)
149+
{
150+
return $this->setParameter('merchantAccountId', $value);
151+
}
152+
153+
public function getRecurring()
154+
{
155+
return $this->getParameter('recurring');
156+
}
157+
158+
public function setRecurring($value)
159+
{
160+
return $this->setParameter('recurring', (bool) $value);
161+
}
162+
163+
public function getAddBillingAddressToPaymentMethod()
164+
{
165+
return $this->getParameter('addBillingAddressToPaymentMethod');
166+
}
167+
168+
public function setAddBillingAddressToPaymentMethod($value)
169+
{
170+
return $this->setParameter('addBillingAddressToPaymentMethod', (bool) $value);
171+
}
172+
173+
public function getHoldInEscrow()
174+
{
175+
return $this->getParameter('holdInEscrow');
176+
}
177+
178+
public function setHoldInEscrow($value)
179+
{
180+
return $this->setParameter('holdInEscrow', (bool) $value);
181+
}
182+
183+
public function getStoreInVault()
184+
{
185+
return $this->getParameter('storeInVault');
186+
}
187+
188+
public function setStoreInVault($value)
189+
{
190+
return $this->setParameter('storeInVault', (bool) $value);
191+
}
192+
193+
public function getStoreInVaultOnSuccess()
194+
{
195+
return $this->getParameter('storeInVaultOnSuccess');
196+
}
197+
198+
public function setStoreInVaultOnSuccess($value)
199+
{
200+
return $this->setParameter('storeInVaultOnSuccess', (bool) $value);
201+
}
202+
203+
public function getStoreShippingAddressInVault()
204+
{
205+
return $this->getParameter('storeShippingAddressInVault');
206+
}
207+
208+
public function setStoreShippingAddressInVault($value)
209+
{
210+
return $this->setParameter('storeShippingAddressInVault', (bool) $value);
211+
}
212+
213+
public function getShippingAddressId()
214+
{
215+
return $this->getParameter('shippingAddressId');
216+
}
217+
218+
public function setShippingAddressId($value)
219+
{
220+
return $this->setParameter('shippingAddressId', $value);
221+
}
222+
223+
public function getPurchaseOrderNumber()
224+
{
225+
return $this->getParameter('purchaseOrderNumber');
226+
}
227+
228+
public function setPurchaseOrderNumber($value)
229+
{
230+
return $this->setParameter('purchaseOrderNumber', $value);
231+
}
232+
233+
public function getTaxAmount()
234+
{
235+
return $this->getParameter('taxAmount');
236+
}
237+
238+
public function setTaxAmount($value)
239+
{
240+
return $this->setParameter('taxAmount', $value);
241+
}
242+
243+
public function getTaxExempt()
244+
{
245+
return $this->getParameter('taxExempt');
246+
}
247+
248+
public function setTaxExempt($value)
249+
{
250+
return $this->setParameter('taxExempt', (bool) $value);
251+
}
252+
253+
/**
254+
* @return array
255+
*/
256+
protected function getCardData()
257+
{
258+
$card = $this->getCard();
259+
260+
if (!$card) {
261+
return array();
262+
}
263+
264+
return array(
265+
'billing' => array(
266+
'company' => $card->getBillingCompany(),
267+
'firstName' => $card->getBillingFirstName(),
268+
'lastName' => $card->getBillingLastName(),
269+
'streetAddress' => $card->getBillingAddress1(),
270+
'extendedAddress' => $card->getBillingAddress2(),
271+
'locality' => $card->getBillingCity(),
272+
'postalCode' => $card->getBillingPostcode(),
273+
'region' => $card->getBillingState(),
274+
'countryName' => $card->getBillingCountry(),
275+
),
276+
'shipping' => array(
277+
'company' => $card->getShippingCompany(),
278+
'firstName' => $card->getShippingFirstName(),
279+
'lastName' => $card->getShippingLastName(),
280+
'streetAddress' => $card->getShippingAddress1(),
281+
'extendedAddress' => $card->getShippingAddress2(),
282+
'locality' => $card->getShippingCity(),
283+
'postalCode' => $card->getShippingPostcode(),
284+
'region' => $card->getShippingState(),
285+
'countryName' => $card->getShippingCountry(),
286+
)
287+
);
288+
}
289+
73290
protected function createResponse($data)
74291
{
75292
return $this->response = new Response($this, $data);

src/Message/AuthorizeRequest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,33 @@ public function getData()
1717

1818
$data = [
1919
'amount' => $this->getAmount(),
20+
'billingAddressId' => $this->getBillingAddressId(),
21+
'channel' => $this->getChannel(),
22+
'customFields' => $this->getCustomFields(),
23+
'customerId' => $this->getCustomerId(),
24+
'descriptor' => $this->getDescriptor(),
25+
'deviceData' => $this->getDeviceData(),
26+
'deviceSessionId' => $this->getDeviceSessionId(),
27+
'merchantAccountId' => $this->getMerchantAccountId(),
28+
'options' => [
29+
'addBillingAddressToPaymentMethod' => $this->getAddBillingAddressToPaymentMethod(),
30+
'holdInEscrow' => $this->getHoldInEscrow(),
31+
'storeInVault' => $this->getStoreInVault(),
32+
'storeInVaultOnSuccess' => $this->getStoreInVaultOnSuccess(),
33+
'storeShippingAddressInVault' => $this->getStoreShippingAddressInVault(),
34+
'submitForSettlement' => false,
35+
],
36+
'orderId' => $this->getTransactionId(),
2037
'paymentMethodNonce' => $this->getToken(),
21-
'options' => [],
38+
'purchaseOrderNumber' => $this->getPurchaseOrderNumber(),
39+
'recurring' => $this->getRecurring(),
40+
'shippingAddressId' => $this->getShippingAddressId(),
41+
'taxAmount' => $this->getTaxAmount(),
42+
'taxExempt' => $this->getTaxExempt(),
2243
];
2344

45+
$data += $this->getCardData();
46+
2447
return $data;
2548
}
2649

tests/Message/AuthorizeRequestTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ public function setUp()
2020
array(
2121
'amount' => '10.00',
2222
'token' => 'abc123',
23+
'transactionId' => '684',
2324
'testMode' => false,
25+
'card' => [
26+
'firstName' => 'Kayla',
27+
'shippingCompany' => 'League',
28+
]
2429
)
2530
);
2631
}
@@ -31,6 +36,11 @@ public function testGetData()
3136

3237
$this->assertSame('abc123', $data['paymentMethodNonce']);
3338
$this->assertSame('10.00', $data['amount']);
39+
$this->assertSame('684', $data['orderId']);
40+
$this->assertSame('Kayla', $data['billing']['firstName']);
41+
$this->assertSame('League', $data['shipping']['company']);
42+
$this->assertFalse($data['options']['submitForSettlement']);
43+
$this->assertNull($data['billingAddressId']);
3444

3545
$this->request->configure();
3646
$this->assertSame('production', \Braintree_Configuration::environment());

0 commit comments

Comments
 (0)