Conditions | 2 |
Paths | 2 |
Total Lines | 34 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 2 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | 9 | public function getData() |
|
10 | { |
||
11 | 9 | $data = null; |
|
|
|||
12 | |||
13 | 9 | $this->validate('orderNumber', 'amount', 'paymentMethod'); |
|
14 | |||
15 | 9 | $paymentMethod = $this->getPaymentMethod(); |
|
16 | |||
17 | switch ($paymentMethod) { |
||
18 | 9 | case 'payment_profile': |
|
19 | 6 | $this->validate('cardReference'); |
|
20 | |||
21 | 6 | $request = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><request></request>'); |
|
22 | 6 | $request->addChild('store_id', $this->getMerchantId()); |
|
23 | 6 | $request->addChild('api_token', $this->getMerchantKey()); |
|
24 | |||
25 | 6 | $res_purchase_cc = $request->addChild('res_preauth_cc'); |
|
26 | 6 | $res_purchase_cc->addChild('data_key', $this->getCardReference()); |
|
27 | 6 | $res_purchase_cc->addChild('order_id', $this->getOrderNumber()); |
|
28 | 6 | $res_purchase_cc->addChild('cust_id', 'Transaction_'.$this->getOrderNumber()); |
|
29 | 6 | $res_purchase_cc->addChild('amount', $this->getAmount()); |
|
30 | 6 | $res_purchase_cc->addChild('crypt_type', $this->getCryptType()); |
|
31 | |||
32 | 6 | $data = $request->asXML(); |
|
33 | 6 | break; |
|
34 | |||
35 | // Todo: card & token payment |
||
36 | |||
37 | default: |
||
38 | 3 | throw new InvalidRequestException('Invalid payment method'); |
|
39 | break; |
||
40 | } |
||
41 | |||
42 | 6 | return preg_replace('/\n/', '', $data); |
|
43 | } |
||
45 |