1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

[bug] unable to process stripe payments

This commit is contained in:
Sylvain 2021-06-09 19:24:56 +02:00
parent 2b6bbbd7b8
commit f82adc8133
3 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# Changelog Fab-manager
## next release
- Fix a bug: unable to process stripe payments
## v4.7.11 2021 May 26
- Updated ffi to 1.15.1

View File

@ -3,7 +3,7 @@ import { AxiosResponse } from 'axios';
import { CartItems, IntentConfirmation, PaymentConfirmation, UpdateCardResponse } from '../models/payment';
export default class PaymentAPI {
static async confirm (stp_payment_method_id: string, cart_items: CartItems): Promise<PaymentConfirmation> {
static async confirmMethod (stp_payment_method_id: string, cart_items: CartItems): Promise<PaymentConfirmation> {
const res: AxiosResponse = await apiClient.post(`/api/payments/confirm_payment`, {
payment_method_id: stp_payment_method_id,
cart_items
@ -11,6 +11,14 @@ export default class PaymentAPI {
return res?.data;
}
static async confirmIntent (stp_payment_intent_id: string, cart_items: CartItems): Promise<PaymentConfirmation> {
const res: AxiosResponse = await apiClient.post(`/api/payments/confirm_payment`, {
payment_intent_id: stp_payment_intent_id,
cart_items
});
return res?.data;
}
static async setupIntent (user_id: number): Promise<IntentConfirmation> {
const res: AxiosResponse = await apiClient.get(`/api/payments/setup_intent/${user_id}`);
return res?.data;

View File

@ -52,7 +52,7 @@ export const StripeForm: React.FC<StripeFormProps> = ({ onSubmit, onSuccess, onE
try {
if (!paymentSchedule) {
// process the normal payment pipeline, including SCA validation
const res = await PaymentAPI.confirm(paymentMethod.id, cartItems);
const res = await PaymentAPI.confirmMethod(paymentMethod.id, cartItems);
await handleServerConfirmation(res);
} else {
// we start by associating the payment method with the user
@ -107,7 +107,7 @@ export const StripeForm: React.FC<StripeFormProps> = ({ onSubmit, onSuccess, onE
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
try {
const confirmation = await PaymentAPI.confirm(result.paymentIntent.id, cartItems);
const confirmation = await PaymentAPI.confirmIntent(result.paymentIntent.id, cartItems);
await handleServerConfirmation(confirmation);
} catch (e) {
onError(e);