クラス
SandboxSimulation
Simulations for sandbox testing
説明 説明
ファイル: src/API/SandboxSimulation.php
class SandboxSimulation { const GET_CHECKOUT_SESSION_SIMCODE = 'WCEXAAPGetCheckoutSessionSimCode'; const UPDATE_CHECKOUT_SESSION_SIMCODE = 'WCEXAAPUpdateCheckoutSessionSimCode'; const CREATE_CHARGE_SIMCODE = 'WCEXAAPCreateChargeSimCode'; const CAPTURE_CHARGE_SIMCODE = 'WCEXAAPCaptureChargeSimCode'; const CREATE_REFUND_SIMCODE = 'WCEXAAPCreateRefundSimCode'; /** * 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; } /** * Appends sim code to `GetCheckoutSession` request headers if applicable * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @return array|null */ public function getCheckoutSessionSetSimCodeIfSandbox($requestheaders = null) { return $this->setSimCode($requestheaders, self::GET_CHECKOUT_SESSION_SIMCODE); } /** * Appends sim code to `UpdateCheckoutSession` request headers if applicable * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @return array|null */ public function updateCheckoutSessionSetSimCodeIfSandbox($requestheaders = null) { return $this->setSimCode($requestheaders, self::UPDATE_CHECKOUT_SESSION_SIMCODE); } /** * Appends sim code to `CreateCharge` request headers if applicable * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @return array|null */ public function createChargeSetSimCodeIfSandbox($requestheaders = null) { return $this->setSimCode($requestheaders, self::CREATE_CHARGE_SIMCODE); } /** * Appends sim code to `CaptureCharge` request headers if applicable * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @return array|null */ public function captureChargeSetSimCodeIfSandbox($requestheaders = null) { return $this->setSimCode($requestheaders, self::CAPTURE_CHARGE_SIMCODE); } /** * Appends sim code to `CreateRefund` request headers if applicable * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @return array|null */ public function createRefundSetSimCodeIfSandbox($requestheaders = null) { return $this->setSimCode($requestheaders, self::CREATE_REFUND_SIMCODE); } /** * Appends simulation code key value pair to `$requestheaders` if in sandbox mode * and the given `$_ENV` key is set. * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array|null $requestheaders Default: `null` * @param string $envkey * @return array|null */ private function setSimCode($requestheaders, $envkey) { if ($this->module->isSandboxMode() && isset($_ENV[$envkey])) { if ($requestheaders === null) { $requestheaders = []; } $requestheaders['x-amz-pay-simulation-code'] = $_ENV[$envkey]; } return $requestheaders; } }
- __construct — Sets $module member var with dependency injection.
- captureChargeSetSimCodeIfSandbox — Appends sim code to CaptureCharge request headers if applicable
- createChargeSetSimCodeIfSandbox — Appends sim code to CreateCharge request headers if applicable
- createRefundSetSimCodeIfSandbox — Appends sim code to CreateRefund request headers if applicable
- getCheckoutSessionSetSimCodeIfSandbox — Appends sim code to GetCheckoutSession request headers if applicable
- setSimCode — Appends simulation code key value pair to $requestheaders if in sandbox mode and the given $_ENV key is set.
- updateCheckoutSessionSetSimCodeIfSandbox — Appends sim code to UpdateCheckoutSession request headers if applicable