mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -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:
parent
b015a08c43
commit
2f90c97629
2 changed files with 4 additions and 1 deletions
|
@ -218,7 +218,8 @@ module.exports = function MembersApi({
|
||||||
const sessionInfo = await stripe.createCheckoutSession(member, plan, {
|
const sessionInfo = await stripe.createCheckoutSession(member, plan, {
|
||||||
successUrl: req.body.successUrl,
|
successUrl: req.body.successUrl,
|
||||||
cancelUrl: req.body.cancelUrl,
|
cancelUrl: req.body.cancelUrl,
|
||||||
customerEmail: req.body.customerEmail
|
customerEmail: req.body.customerEmail,
|
||||||
|
metadata: req.body.metadata
|
||||||
});
|
});
|
||||||
|
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
|
|
|
@ -115,12 +115,14 @@ module.exports = class StripePaymentProcessor {
|
||||||
}
|
}
|
||||||
const plan = this._plans.find(plan => plan.nickname === planName);
|
const plan = this._plans.find(plan => plan.nickname === planName);
|
||||||
const customerEmail = (!customer && options.customerEmail) ? options.customerEmail : undefined;
|
const customerEmail = (!customer && options.customerEmail) ? options.customerEmail : undefined;
|
||||||
|
const metadata = options.metadata || undefined;
|
||||||
const session = await this._stripe.checkout.sessions.create({
|
const session = await this._stripe.checkout.sessions.create({
|
||||||
payment_method_types: ['card'],
|
payment_method_types: ['card'],
|
||||||
success_url: options.successUrl || this._checkoutSuccessUrl,
|
success_url: options.successUrl || this._checkoutSuccessUrl,
|
||||||
cancel_url: options.cancelUrl || this._checkoutCancelUrl,
|
cancel_url: options.cancelUrl || this._checkoutCancelUrl,
|
||||||
customer: customer ? customer.id : undefined,
|
customer: customer ? customer.id : undefined,
|
||||||
customer_email: customerEmail,
|
customer_email: customerEmail,
|
||||||
|
metadata,
|
||||||
subscription_data: {
|
subscription_data: {
|
||||||
items: [{
|
items: [{
|
||||||
plan: plan.id
|
plan: plan.id
|
||||||
|
|
Loading…
Add table
Reference in a new issue