Мы используем элементы «платеж» полосовых элементов для подписки, которая является отличным для обычных случаев. Но автоматическое продление не работает для карт с поддержкой 3DS. Пожалуйста, найдите мой код ниже. Мы не уверены, что мы пропустили.setup_future_usage: 'off_session',
automatic_payment_methods: { enabled: true },
Ниже приведен код, используемый во время автоматического виностроения
php-код
public function stripeElementAutoRenewPayment($user_id, $brand_data, $card_src, $final_price, $secretKey) {
$response = [];
$output = null;
$stripe = new \Stripe\StripeClient($secretKey);
$return_url = "https://" . $brand_data->domain_name . "/subscriptions/payment-subscription.html";
$error = '';
// Create PaymentIntent with amount, currency and description.
$paymentIntent = $stripe->paymentIntents->create([
'amount' => $final_price,
'currency' => 'USD',
'description' => $brand_data->brand_name . "-AUTORENEW-" . $user_id,
'payment_method' => 'pm_card_threeDSecure2Required',
'customer' => $card_src['customer_id'],
'confirm' => true,
'off_session' => true
]);
js code:
let obj = CheckoutModule.getCheckoutData();
Helpers.CommonUtils.commonGateway('POST', '/v1/orders/createpaymentintent', obj, stripeInitCallback );
function stripeInitCallback(res) {
if (res.code == 1 && res.status == 1) {
let clientSecret = res.results.client_secret;
elements = stripe.elements({ clientSecret });
const paymentElement = elements.create("payment", {
layout: "tabs",
});
paymentElement.mount("#payment-element");
}
}
$("#pay-now-button").on('click', async function (event) {
event.preventDefault();
//payNowButton.disabled = true;
if (payForm.valid()) {
payNowButton.prop('disabled', true);
console.log('payForm.valid', payForm.valid())
const { error, paymentIntent } = await stripe.confirmPayment({
elements,
redirect: 'if_required' // Optional
});
console.log("----paymentIntent---"+JSON.stringify(paymentIntent));
if (error) {
$("#order-resp-msg").addClass("alert-danger").removeClass("hide").text(error.message);
console.log('error', error);
payNowButton.prop('disabled', false);
$("#submitOrder, #pay-now-button").text('Confirm and Pay');
} else {
payNowButton.prop('disabled', true);
console.log("----paymentIntent---"+JSON.stringify(paymentIntent)+"----"+paymentIntent.id)
const payment_id = paymentIntent.id;
$("#submitOrder, #pay-now-button").text('PROCESSING ORDER...');
if (localStorage.getItem('l4-utoken')) {
let obj = {};
obj.email = localStorage.getItem('l4-uemail') || $('form#userLoginForm input#emailAddress').val();
obj.log = "Add Order from page";
obj.data = "";
obj.domain = CheckoutModule.brandDomain;
obj.type = "ADD_ORDER";
Helpers.CommonUtils.commonGateway('POST', '/v1/orders/stripepaymentlog', obj, CheckoutModule.createOrderCallback);
CheckoutModule.submitOrder(payment_id);
} else {
let obj = {};
obj.email = localStorage.getItem('l4-uemail') || $('form#userLoginForm input#emailAddress').val();
obj.log = "Add Anonymous Order from page";
obj.data = "";
obj.domain = CheckoutModule.brandDomain;
obj.type = "ADD_ANON_ORDER";
Helpers.CommonUtils.commonGateway('POST', '/v1/orders/stripepaymentlog', obj, CheckoutModule.createOrderCallback);
CheckoutModule.submitAnonOrder(payment_id);
}
// handler(paymentIntent);
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -3ds-cards
Автопродление не работает с картами 3DS Elements. ⇐ Jquery
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Карта начальной загрузки не схлопывается с другими картами и не сливается с картами
Anonymous » » в форуме CSS - 0 Ответы
- 37 Просмотры
-
Последнее сообщение Anonymous
-