クラス
Get
Amazon Pay V2 SDK Get Checkout Session.
ソース ソース
ファイル: src/API/CheckoutSession/Get.php
class Get extends ErrorStore { const RESOURCE_NOT_FOUND = 'ResourceNotFound'; /** * AmazonPay module object * * @var AmazonPay */ private $module; /** * Sets `$module` member var with dependency injection. * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param AmazonPay $module * @return void */ public function __construct(AmazonPay $module) { $this->module = $module; $this->populate(); } /** * Gets a checkout session * * @see https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/checkout-session.html#get-checkout-session * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $id checkout session ID * @return array * @throws InvalidArgumentException Thrown by `getAmazonClient`. */ public function get($id) { $headers = (new SandboxSimulation($this->module))->getCheckoutSessionSetSimCodeIfSandbox(null); try { $client = $this->module->getAmazonClient(); $result = $client->getCheckoutSession($id, $headers); if ($this->module->errors->hasError($result)) { return $this->module->errors->getAmzErrorResponse($result, $this); } } catch (\Exception $e) { return $this->module->errors->getErrorResponse( GenericErrorStore::AMAZON_PAY_SDK_CLIENT_EXCEPTION, [$e->getMessage()] ); } return $result; } /** * Populates error store * * @see https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/checkout-session.html#error-codes-1 * @author Evan D Shaw <evandanielshaw@gmail.com> * @return void * @throws InvalidArgumentException Thrown if duplicate errorcodes exist. */ public function populate() { $this->addError(new GenericError( self::RESOURCE_NOT_FOUND, $this->getConstantNameByValue(self::RESOURCE_NOT_FOUND), 404, function ($message) { return $message; }, __('Youre checkout session has expired or is not available', 'wcexaap') )); } }
- __construct — Sets $module member var with dependency injection.
- get — Gets a checkout session
- populate — Populates error store