関数
Update::patch( array $args )
チェックアウトセッションを更新する
説明 説明
- $args
(配列) (必須) URLパラメーター
- 'id'
(数値)チェックアウトセッションID
- 'id'
ファイル: src/API/CheckoutSession/Update.php
public function patch(array $args) {
$formExtras = !empty($_POST['formExtras']) ? $_POST['formExtras'] : [];
/**
* Fires **before** calling Amazon Pay's `Update Checkout Session` API
*
* @param array $formExtras
* @param array $args See {@see \Aivec\Welcart\SettlementModules\AmazonPay\API\CheckoutSession\Update::patch()}
* @param string $settlementType `payonly` or `payandship`
* @param string $paymentIntent `Authorize`, `AuthorizeWithCapture` or `Confirm`
*/
do_action(
'wcexaap_on_before_update_checkout_session',
$formExtras,
$args,
$this->settlementType,
$this->paymentIntent
);
if (!empty($this->settlementType)) {
/**
* Fires **before** calling Amazon Pay's `Update Checkout Session` API
*
* @param array $formExtras
* @param array $args See {@see \Aivec\Welcart\SettlementModules\AmazonPay\API\CheckoutSession\Update::patch()}
* @param string $settlementType `payonly` or `payandship`
* @param string $paymentIntent `Authorize`, `AuthorizeWithCapture` or `Confirm`
*/
do_action(
"wcexaap_on_before_update_checkout_session_{$this->settlementType}",
$formExtras,
$args,
$this->settlementType,
$this->paymentIntent
);
}
$id = $args['id'];
$order = (new API\WelcartEntries())->getOrder();
$payload = [
'webCheckoutDetails' => [
'checkoutResultReturnUrl' => $this->checkoutResultUrl,
],
'paymentDetails' => [
'paymentIntent' => $this->paymentIntent,
'canHandlePendingAuthorization' => $this->canHandlePendingAuthorization,
'chargeAmount' => [
'amount' => $order['total_full_price'],
'currencyCode' => usces_crcode('return'),
],
],
'platformId' => Constants::PLATFORM_ID,
];
$headers = (new SandboxSimulation($this->module))->updateCheckoutSessionSetSimCodeIfSandbox();
try {
$client = $this->module->getAmazonClient();
$result = $client->updateCheckoutSession($id, $payload, $headers);
if ($this->module->errors->hasError($result)) {
return $this->module->errors->getAmzErrorResponse($result, $this);
}
if ($this->hasConstraints($result)) {
return $this->getConstraintsResponse($result);
}
} catch (\Exception $e) {
return $this->module->errors->getErrorResponse(
GenericErrorStore::AMAZON_PAY_SDK_CLIENT_EXCEPTION,
[$e->getMessage()]
);
}
/**
* Fires **after** calling Amazon Pay's `Update Checkout Session` API
*
* This hook will not be called if an error occured
*
* @param array $result
* @param array $formExtras
* @param array $args See {@see \Aivec\Welcart\SettlementModules\AmazonPay\API\CheckoutSession\Update::patch()}
* @param string $settlementType `payonly` or `payandship`
* @param string $paymentIntent `Authorize`, `AuthorizeWithCapture` or `Confirm`
*/
do_action(
'wcexaap_on_after_update_checkout_session',
$result,
$formExtras,
$args,
$this->settlementType,
$this->paymentIntent
);
if (!empty($this->settlementType)) {
/**
* Fires **after** calling Amazon Pay's `Update Checkout Session` API
*
* This hook will not be called if an error occured
*
* @param array $result
* @param array $formExtras
* @param array $args See {@see \Aivec\Welcart\SettlementModules\AmazonPay\API\CheckoutSession\Update::patch()}
* @param string $settlementType `payonly` or `payandship`
* @param string $paymentIntent `Authorize`, `AuthorizeWithCapture` or `Confirm`
*/
do_action(
"wcexaap_on_after_update_checkout_session_{$this->settlementType}",
$result,
$formExtras,
$args,
$this->settlementType,
$this->paymentIntent
);
}
return $result;
}