Newer
Older
<?php
use QUI\ERP\Order\Handler;
use QUI\Utils\Security\Orthos;
use QUI\ERP\Payments\Stripe\StripeException;
use QUI\ERP\Payments\Stripe\PaymentMethods\Recurring\Subscriptions;
use QUI\ERP\Payments\Stripe\AbstractBasePayment;

Patrick Müller
committed
use Stripe\Exception\CardException;
/**
* Confirm a Stripe Subscription
*
* @param int $basketId - Basket ID
* @return array - Subscription confirmation data
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_payment-stripe_ajax_confirmSubscription',
function ($orderHash) {
try {
$orderHash = Orthos::clear($orderHash);
$Order = Handler::getInstance()->getOrderByHash($orderHash);
return Subscriptions::confirmSubscription(
$Order->getPaymentDataEntry(AbstractBasePayment::ATTR_STRIPE_SUBSCRIPTION_ID)

Patrick Müller
committed
if ($Exception instanceof CardException) {
QUI\System\Log::writeDebugException($Exception);
} else {
QUI\System\Log::writeException($Exception);
}
throw new StripeException([
'quiqqer/payment-stripe',
'exception.ajax.createPaymentIntent.general_error'
]);
}
},