1 | <?php |
||
11 | class CreateTransactionAction extends BaseApiAwareAction |
||
12 | { |
||
13 | /** |
||
14 | * {@inheritdoc} |
||
15 | * |
||
16 | * @param $request CreateTransaction |
||
17 | */ |
||
18 | 3 | public function execute($request) |
|
19 | { |
||
20 | 3 | RequestNotSupportedException::assertSupports($this, $request); |
|
21 | |||
22 | 3 | $details = ArrayObject::ensureArrayObject($request->getModel()); |
|
23 | |||
24 | 3 | if ($this->api instanceof EcpayLogisticsApi && empty($details['GoodsAmount']) === true) { |
|
25 | 1 | $params = $this->api->createCvsMapTransaction((array) $details); |
|
26 | 1 | $endpoint = $this->api->getApiEndpoint(); |
|
27 | |||
28 | 1 | throw new HttpPostRedirect( |
|
29 | 1 | $endpoint, $params |
|
30 | 1 | ); |
|
31 | } |
||
32 | |||
33 | 2 | $params = $this->api->createTransaction((array) $details); |
|
34 | |||
35 | 2 | if (isset($params['RtnCode']) === true || |
|
36 | 2 | isset($params['ResCode']) === true || |
|
37 | 2 | isset($params['RtnMerchantTradeNo']) === true && isset($params['RtnOrderNo']) === true || |
|
38 | 2 | isset($params['CVSStoreID']) === true || |
|
39 | 2 | isset($params['ErrorMessage']) === true |
|
40 | 2 | ) { |
|
41 | 1 | $details->replace($params); |
|
42 | 1 | } else { |
|
43 | 1 | $endpoint = $this->api->getApiEndpoint(); |
|
44 | |||
45 | 1 | throw new HttpPostRedirect( |
|
46 | 1 | $endpoint, $params |
|
47 | 1 | ); |
|
48 | } |
||
49 | 1 | } |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 3 | public function supports($request) |
|
60 | } |
||
61 |