@@ -15,14 +15,12 @@ import {
1515 TInvoicePdf ,
1616 TInvoicePaymentDetails ,
1717 TPaymentIntent ,
18- TCustomer ,
1918 TPaymentSource ,
2019 TInvoice ,
2120 Transaction ,
2221} from 'loopback4-billing' ;
2322import { getModelSchemaRefSF , STATUS_CODE } from '@sourceloop/core' ;
2423import {
25- BillingCustomerBody ,
2624 BillingPaymentSourceBody ,
2725 BillingPaymentMethodBody ,
2826 BillingInvoiceBody ,
@@ -44,117 +42,7 @@ export class BillingServiceController {
4442 private readonly billingService : IService ,
4543 ) { }
4644
47- // -------------------------------------------------------------------------
48- // CUSTOMER
49- // -------------------------------------------------------------------------
50-
51- /**
52- * Create a new customer in Stripe.
53- *
54- * Example body:
55- * ```json
56- * {
57- * "firstName": "John",
58- * "lastName": "Doe",
59- * "email": "john.doe@example .com",
60- * "phone": "+1234567890"
61- * }
62- * ```
63- */
64- @authorize ( { permissions : [ '*' ] } )
65- @post ( `${ BASE } /customers` , {
66- summary : 'Create a new customer' ,
67- responses : {
68- [ STATUS_CODE . OK ] : {
69- description : 'Created customer object' ,
70- content : { 'application/json' : { schema : { type : 'object' } } } ,
71- } ,
72- } ,
73- } )
74- async createCustomer (
75- @requestBody ( {
76- content : {
77- 'application/json' : {
78- schema : { ...getModelSchemaRefSF ( BillingCustomerBody ) } ,
79- } ,
80- } ,
81- } )
82- customerDto : BillingCustomerBody ,
83- ) : Promise < TCustomer > {
84- return this . billingService . createCustomer ( customerDto as TCustomer ) ;
85- }
86-
87- /**
88- * Get a customer by external ID (Stripe customer ID, e.g. cus_XXXXX).
89- */
90- @authorize ( { permissions : [ '*' ] } )
91- @get ( `${ BASE } /customers/{customerId}` , {
92- summary : 'Get a customer by ID' ,
93- responses : {
94- [ STATUS_CODE . OK ] : {
95- description : 'Customer object' ,
96- content : { 'application/json' : { schema : { type : 'object' } } } ,
97- } ,
98- } ,
99- } )
100- async getCustomer (
101- @param . path . string ( 'customerId' ) customerId : string ,
102- ) : Promise < TCustomer > {
103- return this . billingService . getCustomers ( customerId ) ;
104- }
105-
106- /**
107- * Update an existing customer (email, phone, billing address, etc.).
108- *
109- * Example body:
110- * ```json
111- * {
112- * "email": "new.email@example .com",
113- * "billingAddress": { "city": "New York", "country": "US" }
114- * }
115- * ```
116- */
117- @authorize ( { permissions : [ '*' ] } )
118- @put ( `${ BASE } /customers/{customerId}` , {
119- summary : 'Update a customer' ,
120- responses : {
121- [ STATUS_CODE . NO_CONTENT ] : { description : 'Customer updated' } ,
122- } ,
123- } )
124- async updateCustomer (
125- @param . path . string ( 'customerId' ) customerId : string ,
126- @requestBody ( {
127- content : {
128- 'application/json' : {
129- schema : { ...getModelSchemaRefSF ( BillingCustomerBody ) } ,
130- } ,
131- } ,
132- } )
133- customerDto : Partial < BillingCustomerBody > ,
134- ) : Promise < void > {
135- await this . billingService . updateCustomerById (
136- customerId ,
137- customerDto as Partial < TCustomer > ,
138- ) ;
139- }
140-
141- /**
142- * Delete (permanently remove) a customer from Stripe.
143- */
144- @authorize ( { permissions : [ '*' ] } )
145- @del ( `${ BASE } /customers/{customerId}` , {
146- summary : 'Delete a customer' ,
147- responses : {
148- [ STATUS_CODE . NO_CONTENT ] : { description : 'Customer deleted' } ,
149- } ,
150- } )
151- async deleteCustomer (
152- @param . path . string ( 'customerId' ) customerId : string ,
153- ) : Promise < void > {
154- await this . billingService . deleteCustomer ( customerId ) ;
155- }
156-
157- // -------------------------------------------------------------------------
45+ // ------------------------------------------------------------------------
15846 // PAYMENT SOURCE
15947 // -------------------------------------------------------------------------
16048
0 commit comments