@@ -36,16 +36,29 @@ module.exports = StripeResource.extend({
36
36
retrieveUpcoming : stripeMethod ( {
37
37
method : 'GET' ,
38
38
path : function ( urlData ) {
39
- var url = 'upcoming?customer=' + urlData . customerId ;
39
+ var url = 'upcoming?' ;
40
+ var hasParam = false ;
41
+
42
+ // If you pass just a hash with the relevant parameters, including customer id inside.
43
+ if ( urlData . invoiceOptionsOrCustomerId && typeof urlData . invoiceOptionsOrCustomerId === 'object' ) {
44
+ return url + utils . stringifyRequestData ( urlData . invoiceOptionsOrCustomerId ) ;
45
+ }
46
+
47
+ // Legacy implementation where the first parameter is a customer id as a string
48
+ if ( urlData . invoiceOptionsOrCustomerId && typeof urlData . invoiceOptionsOrCustomerId === 'string' ) {
49
+ url = url + 'customer=' + urlData . invoiceOptionsOrCustomerId ;
50
+ hasParam = true ;
51
+ }
52
+
40
53
// Legacy support where second argument is the subscription id
41
- if ( urlData . invoiceOptions && typeof urlData . invoiceOptions === 'string' ) {
42
- return url + '& subscription=' + urlData . invoiceOptions ;
43
- } else if ( urlData . invoiceOptions && typeof urlData . invoiceOptions === 'object' ) {
44
- return url + '&' + utils . stringifyRequestData ( urlData . invoiceOptions ) ;
54
+ if ( urlData . invoiceOptionsOrSubscriptionId && typeof urlData . invoiceOptionsOrSubscriptionId === 'string' ) {
55
+ return url + ( hasParam ? '&' : '' ) + ' subscription=' + urlData . invoiceOptionsOrSubscriptionId ;
56
+ } else if ( urlData . invoiceOptionsOrSubscriptionId && typeof urlData . invoiceOptionsOrSubscriptionId === 'object' ) {
57
+ return url + ( hasParam ? '&' : '' ) + utils . stringifyRequestData ( urlData . invoiceOptionsOrSubscriptionId ) ;
45
58
}
46
59
return url ;
47
60
} ,
48
- urlParams : [ 'customerId ' , 'optional!invoiceOptions ' ] ,
61
+ urlParams : [ 'optional!invoiceOptionsOrCustomerId ' , 'optional!invoiceOptionsOrSubscriptionId ' ] ,
49
62
} ) ,
50
63
51
64
sendInvoice : stripeMethod ( {
0 commit comments