I have stripe gateway payments in my application, but after (1.1.2021) EU applied new security restrictions and it doesn't work with 3D secured credit cards. So I tried to add 3Ds auth but I'm receiving server error 500 on my server and declined payments on stripe. My app is based on Cezerin2 repository. I also tried to implement card payments via google pay but I am getting same error. Excuse me but I don't have much experience with server-side applications.
Here is my code:
import stripePackage from 'stripe';
import OrdersService from '../services/orders/orders';
import OrdertTansactionsService from '../services/orders/orderTransactions';
const getPaymentFormSettings = options => {
const { gateway, gatewaySettings, order, amount, currency } = options;
const formSettings = {
order_id: order.id,
amount,
currency,
email: order.email,
public_key: gatewaySettings.public_key
};
return Promise.resolve(formSettings);
};
const processOrderPayment = async ({ order, gatewaySettings, settings }) => {
try {
const stripe = stripePackage(gatewaySettings.secret_key);
const charge = await stripe.charges.create({
amount: order.grand_total * 100,
currency: settings.currency_code,
**type: 'three_d_secure',
three_d_secure: {
card: source_id, #src_xcvxcvxcvc
},
redirect: {
return_url: return_url
},**
description: `Order #${order.number}`,
statement_descriptor: `Order #${order.number}`,
metadata: {
order_id: order.id
},
source: order.payment_token
});
// status: succeeded, pending, failed
const paymentSucceeded =
charge.status === 'succeeded' || charge.paid === true;
if (paymentSucceeded) {
await OrdersService.updateOrder(order.id, {
paid: true,
date_paid: new Date()
});
}
await OrdertTansactionsService.addTransaction(order.id, {
transaction_id: charge.id,
amount: charge.amount / 100,
currency: charge.currency,
status: charge.status,
details: charge.outcome.seller_message,
success: paymentSucceeded
});
return paymentSucceeded;
} catch (err) {
// handle errors
return false;
}
};
export default {
getPaymentFormSettings,
processOrderPayment
};```
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…