1- import chargebee from "chargebee" ;
1+ import Chargebee from "chargebee" ;
22
33export default {
44 type : "app" ,
@@ -10,44 +10,58 @@ export default {
1010 description : "The ID of the customer to create the subscription for." ,
1111 async options ( ) {
1212 const customers = await this . getCustomers ( ) ;
13- return customers . list . map ( ( customer ) => ( {
13+ return customers . list . map ( ( { customer } ) => ( {
1414 label : `${ customer . first_name ?? "" } ${ customer . last_name ?? "" } (${ customer . email ?? customer . id } )` ,
1515 value : customer . id ,
1616 } ) ) ;
1717 } ,
1818 } ,
19+ itemPriceId : {
20+ type : "string" ,
21+ label : "Item Price ID" ,
22+ description : "The unique identifier of the plan item price." ,
23+ async options ( ) {
24+ const itemPrices = await this . getItemPrices ( ) ;
25+ return itemPrices . list . map ( ( { item_price : { name, id } } ) => ( {
26+ label : name ,
27+ value : id ,
28+ } ) ) ;
29+ } ,
30+ } ,
1931 } ,
2032 methods : {
2133 instance ( ) {
22- chargebee . configure ( {
34+ return new Chargebee ( {
2335 site : this . $auth . sub_url ,
24- api_key : this . $auth . api_key ,
36+ apiKey : this . $auth . api_key ,
2537 } ) ;
26- return chargebee ;
2738 } ,
2839 getSubscriptions ( args = { } ) {
29- return this . instance ( ) . subscription . list ( args ) . request ( ) ;
40+ return this . instance ( ) . subscription . list ( args ) ;
3041 } ,
3142 getTransactions ( args = { } ) {
32- return this . instance ( ) . transaction . list ( args ) . request ( ) ;
43+ return this . instance ( ) . transaction . list ( args ) ;
3344 } ,
3445 getCustomers ( args = { } ) {
35- return this . instance ( ) . customer . list ( args ) . request ( ) ;
46+ return this . instance ( ) . customer . list ( args ) ;
3647 } ,
3748 getInvoices ( args = { } ) {
38- return this . instance ( ) . invoice . list ( args ) . request ( ) ;
49+ return this . instance ( ) . invoice . list ( args ) ;
3950 } ,
4051 getPaymentSources ( args = { } ) {
41- return this . instance ( ) . payment_source . list ( args ) . request ( ) ;
52+ return this . instance ( ) . paymentSource . list ( args ) ;
4253 } ,
4354 getEvents ( args = { } ) {
44- return this . instance ( ) . event . list ( args ) . request ( ) ;
55+ return this . instance ( ) . event . list ( args ) ;
4556 } ,
4657 createCustomer ( args = { } ) {
47- return this . instance ( ) . customer . create ( args ) . request ( ) ;
58+ return this . instance ( ) . customer . create ( args ) ;
4859 } ,
4960 createSubscription ( customerId , args = { } ) {
50- return this . instance ( ) . subscription . create_for_customer ( customerId , args ) . request ( ) ;
61+ return this . instance ( ) . subscription . createWithItems ( customerId , args ) ;
62+ } ,
63+ getItemPrices ( args = { } ) {
64+ return this . instance ( ) . itemPrice . list ( args ) ;
5165 } ,
5266 } ,
5367} ;
0 commit comments