Stripe Integration Notes #985
michaelbromley
started this conversation in
General
Replies: 1 comment
-
For my part, I see 2 use cases for the "one time" payment:
I would like to discuss with you the best way to do it I added a const customPaymentProcess: CustomPaymentProcess<"Processing"> = {
transitions: {
Created: {
to: ["Processing"],
mergeStrategy: "replace",
},
Processing: {
to: ["Settled", "Declined", "Cancelled"],
},
},
};
const customOrderProcess: CustomOrderProcess<"ProcessingPayment"> = {
transitions: {
ArrangingPayment: {
to: ["ProcessingPayment"],
mergeStrategy: "replace",
},
ProcessingPayment: {
to: ["PaymentAuthorized", "PaymentSettled", "ArrangingAdditionalPayment"],
},
},
}; Payment Handler :
intent = await gateway.paymentIntents.create({
amount: amount,
currency: "EUR",
});
// if 3D SECURE is required
if (three_d_secure_required) {
return {
amount: amount,
state: "Processing" as any,
transactionId: intent.id,
metadata: {
intent,
public: {
secretKey: intent.client_secret,
},
},
};
}
return {
amount: amount,
state: "Settled" as any,
transactionId: intent.id,
metadata: {
intent,
public: {
secretKey: intent.client_secret,
},
},
};
and the orderPlacedStrategy class MyOrderPlacedStrategy implements OrderPlacedStrategy {
shouldSetAsPlaced(
ctx: RequestContext,
fromState: OrderState,
toState: OrderState
): boolean | Promise<boolean> {
return (
fromState === ("ProcessingPayment" as any) &&
toState === ("PaymentSettled" as any)
);
}
} thx for help 🙌 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a place for community members who are implementing Stripe integrations to share notes.
To do:
Beta Was this translation helpful? Give feedback.
All reactions