関数
Get::get( string $chargeId )
Gets a Charge
説明 説明
- $chargeId
(文字列) (必須) Charge ID
ファイル: src/API/Charge/Get.php
public function get($chargeId) { try { $client = $this->module->getAmazonClient(); $result = $client->getCharge($chargeId); if ($this->module->errors->hasError($result)) { return $this->module->errors->getAmzErrorResponse($result); } } catch (\Exception $e) { return $this->module->errors->getErrorResponse( GenericErrorStore::AMAZON_PAY_SDK_CLIENT_EXCEPTION, [$e->getMessage()] ); } if ($this->order instanceof OrderMeta) { $oldChargeState = $this->order->getChargeState(); $response = json_decode($result['response'], true); $details = $response['statusDetails']; $this->order->updateChargeState( new State( $details['state'], $details['reasonCode'], $details['reasonDescription'] ) ); if ($details['state'] !== $oldChargeState->getState()) { $amount = null; if ($details['state'] === State::CAPTURED || $details['state'] === State::AUTHORIZED) { $amount = $this->order->getMostRecentTransactionAmount(); } if (!empty(State::STATE_TO_LOG_ACTION[$details['state']])) { (new Logger())->logApiResponse(new Log( $this->order->getChargePermissionId(), State::STATE_TO_LOG_ACTION[$details['state']], Log::RESPONSE_OK, $amount )); } } } return $result; }