関数
Cancel::delete( string $chargeId, string $reason )
Cancels a Charge
説明 説明
- $chargeId
(文字列) (必須) Charge ID
- $reason
(文字列) (必須)
ファイル: src/API/Charge/Cancel.php
public function delete($chargeId, $reason) { $payload = ['cancellationReason' => $reason]; try { $client = $this->module->getAmazonClient(); $result = $client->cancelCharge($chargeId, $payload); if ($this->module->errors->hasError($result)) { $error = $this->module->errors->getAmzErrorResponse($result, $this); (new Logger())->logApiResponse(new Log( $this->order->getChargePermissionId(), Log::ACTION_CANCEL_TRANS, $error->errorcode, null, $error )); return $error; } } catch (\Exception $e) { return $this->module->errors->getErrorResponse( GenericErrorStore::AMAZON_PAY_SDK_CLIENT_EXCEPTION, [$e->getMessage()] ); } $response = json_decode($result['response'], true); $details = $response['statusDetails']; $this->order->updateChargeState( new State( $details['state'], $details['reasonCode'], $details['reasonDescription'] ) ); (new Logger())->logApiResponse(new Log( $this->order->getChargePermissionId(), Log::ACTION_CANCEL_TRANS, Log::RESPONSE_OK )); return $result; }