@@ -239,7 +239,7 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
239
239
OrganizationId = organization . Id ,
240
240
OrganizationName = organization . Name ,
241
241
Date = stripeInvoice . Created ,
242
- Paid = stripeInvoice . Paid ,
242
+ Paid = stripeInvoice . Status == "paid" ,
243
243
Total = stripeInvoice . Total / 100.0m
244
244
} ;
245
245
@@ -260,7 +260,7 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
260
260
invoice . Items . Add ( item ) ;
261
261
}
262
262
263
- var coupon = stripeInvoice . Discount ? . Coupon ;
263
+ var coupon = stripeInvoice . Discounts ? . FirstOrDefault ( ) ? . Coupon ;
264
264
if ( coupon is not null )
265
265
{
266
266
if ( coupon . AmountOff . HasValue )
@@ -435,9 +435,6 @@ public async Task<ActionResult<ChangePlanResult>> ChangePlanAsync(string id, str
435
435
Email = CurrentUser . EmailAddress
436
436
} ;
437
437
438
- if ( ! String . IsNullOrWhiteSpace ( couponId ) )
439
- createCustomer . Coupon = couponId ;
440
-
441
438
var customer = await customerService . CreateAsync ( createCustomer ) ;
442
439
443
440
// Create subscription separately since Plan is deprecated in CustomerCreateOptions
@@ -447,8 +444,14 @@ public async Task<ActionResult<ChangePlanResult>> ChangePlanAsync(string id, str
447
444
Items = new List < SubscriptionItemOptions > { new SubscriptionItemOptions { Price = planId } }
448
445
} ;
449
446
447
+ // Apply coupon as discount if provided
450
448
if ( ! String . IsNullOrWhiteSpace ( couponId ) )
451
- subscriptionCreateOptions . Coupon = couponId ;
449
+ {
450
+ subscriptionCreateOptions . Discounts = new List < SubscriptionDiscountOptions >
451
+ {
452
+ new SubscriptionDiscountOptions { Coupon = couponId }
453
+ } ;
454
+ }
452
455
453
456
await subscriptionService . CreateAsync ( subscriptionCreateOptions ) ;
454
457
@@ -485,6 +488,16 @@ public async Task<ActionResult<ChangePlanResult>> ChangePlanAsync(string id, str
485
488
else
486
489
{
487
490
create . Items . Add ( new SubscriptionItemOptions { Price = planId } ) ;
491
+
492
+ // Apply coupon as discount if provided
493
+ if ( ! String . IsNullOrWhiteSpace ( couponId ) )
494
+ {
495
+ create . Discounts = new List < SubscriptionDiscountOptions >
496
+ {
497
+ new SubscriptionDiscountOptions { Coupon = couponId }
498
+ } ;
499
+ }
500
+
488
501
await subscriptionService . CreateAsync ( create ) ;
489
502
}
490
503
0 commit comments