когда вызывается функция «confirm_pay()», я получаю этот ответ в своем терминале, я пробовал все, но ничего не получается работаю на меня.
error : -
{"code": "Failed", "declineCode": null, "localizedMessage": "There was an
unexpected error -- try again in a few seconds", "message": "There was an
unexpected error -- try again in a few seconds", "stripeErrorCode": null,
"type": null}
const { initPaymentSheet, presentPaymentSheet, confirmPaymentSheetPayment } = useStripe();
useEffect(() => {
initStripe({ publishableKey: "pk_test_51JUm2TSHumMvEDNY3mFcrddvlTqUIzxoHqyIuCT2x8ExzZcbcTLB9kAZWY1eT9ZJnIeBSHtxtkNCq5QjcDf2e2ge00knO9Qx1R" })
}, [])
async function booknow(item) {
if (item.sm_booking_type == 1) {
navigation.navigate('DriverServicesScreen', { user_data: user_data_1, item: item })
} else {
const additional_data = await AsyncStorage.getItem( 'additional_data');
var num = JSON.parse(additional_data);
var dataOk = new FormData();
dataOk.append('amount', item.sm_price * 100);
await axios(API_URL, {
method: 'POST',
headers: { Accept: 'application/x-www-form-urlencoded', 'Content-type': 'multipart/form-data', timeout: 180000 },
data: dataOk,
}).then((result) => {
if (result['data'].code == 200) {
paymentInitializeFunction(result['data'].client_secret, result['data'].ephemeralKey, result['data'].customer)
console.log("
} else {
console.log("
}
}).catch((err) => {
console.log("
})
}
}
const paymentInitializeFunction = async (client_secret, ephemeralKey, customer) => {
await initPaymentSheet({
merchantDisplayName: "Example, Inc.",
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: client_secret,
customFlow: true,
style: 'automatic',
// allowsDelayedPaymentMethods: true,
defaultBillingDetails: {
name: 'Jane Doe',
email: '[email protected]',
phone: '555-555-555',
}
}).then((res) => {
console.log("
}).catch((res) => {
console.log("
})
await presentPaymentSheet({
paymentIntentClientSecret: client_secret,
clientSecret: client_secret,
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
customFlow: true,
style: 'automatic',
// allowsDelayedPaymentMethods: true,
defaultBillingDetails: {
name: 'Jane Doe',
email: '[email protected]',
phone: '555-555-555',
}
}).then((res) => {
console.log("
if (res.hasOwnProperty('error')) {
Error_Alert('The payment has been cancelled.');
}
else {
confirm_payment()
}
}).catch((err) => {
console.log("
Error_Alert('Something went wrong, Please try again later.');
})
}
async function confirm_payment() {
const { error } = await confirmPaymentSheetPayment();
console.log("
if (error) {
Alert.alert(`Error code: ${error.code}`, error.message);
} else {
Alert.alert('Success', 'The payment was confirmed successfully!');
}
}
Подробнее здесь: https://stackoverflow.com/questions/760 ... nds-how-to