0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Added metadata option to stripe checkout session

refs TryGhost/members.js#29

- Allows passing metadata to checkout session API
- Metadata is passed to stripe's checkout session on creation and read back from webhook event
- Allows clients like members.js to pass custom info like member name to Stripe flow
This commit is contained in:
Rish 2020-05-19 13:41:03 +05:30 committed by Rishabh Garg
parent b015a08c43
commit 2f90c97629
2 changed files with 4 additions and 1 deletions

View file

@ -218,7 +218,8 @@ module.exports = function MembersApi({
const sessionInfo = await stripe.createCheckoutSession(member, plan, {
successUrl: req.body.successUrl,
cancelUrl: req.body.cancelUrl,
customerEmail: req.body.customerEmail
customerEmail: req.body.customerEmail,
metadata: req.body.metadata
});
res.writeHead(200, {

View file

@ -115,12 +115,14 @@ module.exports = class StripePaymentProcessor {
}
const plan = this._plans.find(plan => plan.nickname === planName);
const customerEmail = (!customer && options.customerEmail) ? options.customerEmail : undefined;
const metadata = options.metadata || undefined;
const session = await this._stripe.checkout.sessions.create({
payment_method_types: ['card'],
success_url: options.successUrl || this._checkoutSuccessUrl,
cancel_url: options.cancelUrl || this._checkoutCancelUrl,
customer: customer ? customer.id : undefined,
customer_email: customerEmail,
metadata,
subscription_data: {
items: [{
plan: plan.id