File tree Expand file tree Collapse file tree
main/java/com/trynoice/api/subscription
test/java/com/trynoice/api/subscription Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -737,7 +737,7 @@ public SubscriptionResponse redeemGiftCard(
737737 Subscription .builder ()
738738 .customer (giftCard .getCustomer ())
739739 .plan (giftCard .getPlan ())
740- .providerSubscriptionId (String . valueOf ( giftCard . getId ()) )
740+ .providerSubscriptionId (giftCardCode )
741741 .isPaymentPending (false )
742742 .isAutoRenewing (false )
743743 .isRefunded (false )
@@ -797,6 +797,10 @@ private static SubscriptionResponse buildSubscriptionResponse(@NonNull Subscript
797797 .googlePlayPurchaseToken (
798798 subscription .isActive () && subscription .getPlan ().getProvider () == SubscriptionPlan .Provider .GOOGLE_PLAY
799799 ? subscription .getProviderSubscriptionId () : null )
800+ .giftCardCode (
801+ subscription .getPlan ().getProvider () == SubscriptionPlan .Provider .GIFT_CARD
802+ ? subscription .getProviderSubscriptionId ()
803+ : null )
800804 .build ();
801805 }
802806
Original file line number Diff line number Diff line change @@ -57,4 +57,7 @@ public class SubscriptionResponse {
5757 @ Schema (description = "purchase token corresponding to this subscription purchase. only present when the " +
5858 "subscription is active and provided by Google Play" )
5959 private String googlePlayPurchaseToken ;
60+
61+ @ Schema (description = "the gift card code if this subscription was activated using a gift card." )
62+ private String giftCardCode ;
6063}
Original file line number Diff line number Diff line change @@ -401,7 +401,8 @@ void redeemGiftCard_withValidCode() {
401401 val card = buildGiftCard (code , 1L );
402402 when (giftCardRepository .findByCode (code )).thenReturn (Optional .of (card ));
403403 when (subscriptionRepository .save (any ())).thenAnswer (i -> i .getArgument (0 ));
404- assertDoesNotThrow (() -> service .redeemGiftCard (1L , code ));
404+ val response = assertDoesNotThrow (() -> service .redeemGiftCard (1L , code ));
405+ assertEquals (card .getCode (), response .getGiftCardCode ());
405406 }
406407
407408 @ Test
You can’t perform that action at this time.
0 commit comments