Merge pull request #27800 from overleaf/ls-support-create-stripe-customer-from-admin-panel

Support creating Stripe customer from admin panel

GitOrigin-RevId: 3e23008e1f4690e6f3737b5689e20958bf468f82
This commit is contained in:
Liangjun Song
2025-08-14 11:32:02 +01:00
committed by Copybot
parent 4ecf4a26ba
commit 1acb68f41c
6 changed files with 17 additions and 11 deletions

View File

@@ -603,7 +603,7 @@ class PaymentProviderAccount {
* @param {object} props
* @param {string} props.code
* @param {string} props.email
* @param {boolean} props.hasPastDueInvoice
* @param {boolean} [props.hasPastDueInvoice]
*/
constructor(props) {
this.code = props.code

View File

@@ -90,7 +90,7 @@ async function createAccountForUserId(userId) {
}
const account = await client.createAccount(accountCreate)
logger.debug({ userId, account }, 'created recurly account')
return account
return accountFromApi(account)
}
/**

View File

@@ -30,6 +30,7 @@ import {
GroupPolicy,
ManagedGroupSubscription,
MemberGroupSubscription,
StripePaymentProviderService,
} from '../../../types/subscription/dashboard/subscription'
import { SplitTestInfo } from '../../../types/split-test'
import { ValidationStatus } from '../../../types/group-management/validation'
@@ -254,6 +255,7 @@ export interface Meta {
'ol-stripeSubscriptionData': {
customerId: string
subscriptionState: string | null
paymentProviderService: StripePaymentProviderService | null
}
'ol-subscription': any // TODO: mixed types, split into two fields
'ol-subscriptionChangePreview': SubscriptionChangePreview

View File

@@ -193,11 +193,10 @@ describe('RecurlyClient', function () {
describe('createAccountForUserId', function () {
it('should return the Account as created by recurly', async function () {
this.client.createAccount = sinon.stub().resolves(this.recurlyAccount)
await expect(
this.RecurlyClient.promises.createAccountForUserId(this.user._id)
const result = await this.RecurlyClient.promises.createAccountForUserId(
this.user._id
)
.to.eventually.be.an.instanceOf(recurly.Account)
.that.has.property('code', this.user._id)
expect(result).to.has.property('code', this.user._id)
})
it('should throw any API errors', async function () {

View File

@@ -17,6 +17,7 @@ export type AdminCapability =
| 'view-script-log'
| 'view-split-test'
| 'view-user-additional-info'
| 'create-stripe-account'
export type AdminRole =
| 'engagement'

View File

@@ -107,11 +107,15 @@ export type MemberGroupSubscription = Omit<GroupSubscription, 'admin_id'> & {
admin_id: User
}
type PaymentProviderService = 'stripe-us' | 'stripe-uk' | 'recurly'
export type StripePaymentProviderService = Exclude<
PaymentProviderService,
'recurly'
>
const STRIPE_PAYMENT_PROVIDER_SERVICES = ['stripe-uk', 'stripe-us'] as const
const PAYMENT_PROVIDER_SERVICES = [
...STRIPE_PAYMENT_PROVIDER_SERVICES,
'recurly',
] as const
export type PaymentProviderService = (typeof PAYMENT_PROVIDER_SERVICES)[number]
export type StripePaymentProviderService =
(typeof STRIPE_PAYMENT_PROVIDER_SERVICES)[number]
export type PaymentProvider = {
service: PaymentProviderService