@@ -122,6 +122,8 @@ type Payment interface {
122122 StripeBillingPortalUrl () (string , error )
123123 AcknowledgeGooglePurchase (purchaseToken , planId string ) (string , error )
124124 AcknowledgeApplePurchase (receipt , planII string ) (string , error )
125+ RestoreGooglePlayPurchase (purchaseToken string ) (string , error )
126+ RestoreApplePurchase (receipt string ) (string , error )
125127 PaymentRedirect (provider , planID , email , idempotencyKey string ) (string , error )
126128 ActivationCode (email , resellerCode string ) error
127129 SubscriptionPaymentRedirectURL (redirectBody account.PaymentRedirectData ) (string , error )
@@ -871,6 +873,38 @@ func (lc *LanternCore) AcknowledgeApplePurchase(receipt, planII string) (string,
871873 return lc .client .VerifySubscription (lc .ctx , account .AppleService , params )
872874}
873875
876+ func (lc * LanternCore ) RestoreGooglePlayPurchase (purchaseToken string ) (string , error ) {
877+ params := map [string ]string {
878+ "purchaseToken" : purchaseToken ,
879+ "idempotencyKey" : strconv .FormatInt (time .Now ().UnixNano (), 10 ),
880+ }
881+ resp , err := lc .client .RestoreSubscription (lc .ctx , account .GoogleService , params )
882+ if err != nil {
883+ return "" , err
884+ }
885+ data , err := json .Marshal (resp )
886+ if err != nil {
887+ return "" , fmt .Errorf ("error marshalling restore google play purchase response: %w" , err )
888+ }
889+ return string (data ), nil
890+ }
891+
892+ func (lc * LanternCore ) RestoreApplePurchase (receipt string ) (string , error ) {
893+ params := map [string ]string {
894+ "receipt" : receipt ,
895+ "idempotencyKey" : strconv .FormatInt (time .Now ().UnixNano (), 10 ),
896+ }
897+ resp , err := lc .client .RestoreSubscription (lc .ctx , account .AppleService , params )
898+ if err != nil {
899+ return "" , err
900+ }
901+ data , err := json .Marshal (resp )
902+ if err != nil {
903+ return "" , fmt .Errorf ("error marshalling restore apple purchase response: %w" , err )
904+ }
905+ return string (data ), nil
906+ }
907+
874908func (lc * LanternCore ) SubscriptionPaymentRedirectURL (redirectBody account.PaymentRedirectData ) (string , error ) {
875909 return lc .client .SubscriptionPaymentRedirectURL (lc .ctx , redirectBody )
876910}
0 commit comments