Merged v5.22.4 into main

v5.22.4
This commit is contained in:
Daniel Lockyer 2022-11-02 07:09:23 +07:00
commit ab678c3a90
No known key found for this signature in database
4 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ghost-admin",
"version": "5.22.3",
"version": "5.22.4",
"description": "Ember.js admin client for Ghost",
"author": "Ghost Foundation",
"homepage": "http://ghost.org",

View File

@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "5.22.3",
"version": "5.22.4",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",

View File

@ -165,7 +165,7 @@ describe('Create Stripe Checkout Session', function () {
if (uri === '/v1/checkout/sessions') {
const bodyJSON = querystring.parse(body);
// TODO: Actually work out what Stripe checks and when/how it errors
if (bodyJSON.customerEmail) {
if (Reflect.has(bodyJSON, 'customerEmail')) {
return [400, {error: 'Invalid Email'}];
}
return [200, {id: 'cs_123', url: 'https://site.com'}];

View File

@ -88,14 +88,19 @@ class PaymentsService {
const email = options.email || null;
const session = await this.stripeAPIService.createCheckoutSession(price.id, customer, {
const data = {
metadata,
successUrl: options.successUrl,
cancelUrl: options.cancelUrl,
customerEmail: customer ? email : null,
trialDays: trialDays ?? tier.trialDays,
coupon: coupon?.id
});
};
if (!customer && email) {
data.customerEmail = email;
}
const session = await this.stripeAPIService.createCheckoutSession(price.id, customer, data);
return session.url;
}
@ -108,9 +113,7 @@ class PaymentsService {
for (const row of rows) {
const customer = await this.stripeAPIService.getCustomer(row.customer_id);
if (!customer.deleted) {
return {
id: customer.id
};
return customer;
}
}