Closed Kazdan1994 closed 1 year ago
Hi, @Kazdan1994
Currently, webhook URLs are invoked, whenever the stripe redirects to the Success URL page, we are invoking the savePayment() function, with the help custom script file that will be embedded in the HTML header section of the product list, payment success and payment failure pages.
path: src/plugins/strapi-stripe/server/controllers/stripeController.js
async savePayment(ctx) {
const {
txnDate,
transactionId,
isTxnSuccessful,
txnMessage,
txnAmount,
customerName,
customerEmail,
stripeProduct,
} = ctx.request.body;
const savePaymentDetails = await strapi.query('plugin::strapi-stripe.ss-payment').create({
data: {
txnDate,
transactionId,
isTxnSuccessful,
txnMessage: JSON.stringify(txnMessage),
txnAmount,
customerName,
customerEmail,
stripeProduct,
},
populate: true,
});
await strapi.plugin('strapi-stripe').service('stripeService').sendDataToCallbackUrl(txnMessage);
return savePaymentDetails;
},
and the callback URL function is in stripe service
path: src/plugins/strapi-stripe/server/services/stripeService.js
async sendDataToCallbackUrl(session) {
try {
const stripeSettings = await this.initialize();
await axiosInstance.post(stripeSettings.callbackUrl, session);
} catch (error) {
throw new ApplicationError(error.message);
}
},
I hope this will help.
Hey,
Thank you for your answer. Finally I had to reimplement retrieveCheckoutSession to add custom logic.
Have a nice day :)
Hey,
I'm currently working on a mentoring website. I sell offers inside using strapi-stripe
When I'm clicking on the button "Acheter", I'm calling this current fonction reimplement createCheckout
In
src/api/stripe/controllers/stripe.js
And service
src/api/stripe/services/stripe.js
It pretty the same code you have, just change options and get better errors.
After the checkout page, user is redirect but the route I put there
is not called.
Thank you for helping me. I'm trying now to investigate this error.