-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update redemption link instructions for current hybrid SDKs (#611)
- Loading branch information
Showing
4 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
code_blocks/web/revenuecat-billing/redemption_flutter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
String redemptionUrl = 'YOUR_REDEMPTION_URL'; | ||
|
||
final webPurchaseRedemption = await Purchases.parseAsWebPurchaseRedemption(redemptionUrl); | ||
|
||
if (webPurchaseRedemption != null) { | ||
final result = await Purchases.redeemWebPurchase(webPurchaseRedemption); | ||
result.when( | ||
success: (customerInfo) { | ||
// Redemption was successful and entitlements were granted to the user. | ||
}, | ||
error: (error) { | ||
// Redemption failed due to an error. | ||
}, | ||
purchaseBelongsToOtherUser: () { | ||
// The purchase associated to the link belongs to a different user and it cannot be redeemed. | ||
}, | ||
invalidToken: () { | ||
// The redemption link is invalid. | ||
}, | ||
expired: (obfuscatedEmail) { | ||
// The redemption link has expired. A new one has been sent to the user to the provided obfuscated email. | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
String redemptionUrl = 'YOUR_REDEMPTION_URL'; | ||
|
||
const webPurchaseRedemption = await Purchases.parseAsWebPurchaseRedemption(redemptionUrl); | ||
if (webPurchaseRedemption) { | ||
const result = await Purchases.redeemWebPurchase(webPurchaseRedemption); | ||
switch (result.result) { | ||
case WebPurchaseRedemptionResultType.SUCCESS: | ||
const customerInfo: CustomerInfo = result.customerInfo; | ||
// Redemption was successful and entitlements were granted to the user. | ||
break; | ||
case WebPurchaseRedemptionResultType.ERROR: | ||
const error: PurchasesError = result.error; | ||
// Redemption failed due to an error. | ||
break; | ||
case WebPurchaseRedemptionResultType.PURCHASE_BELONGS_TO_OTHER_USER: | ||
// The purchase associated to the link belongs to a different user and it cannot be redeemed. | ||
break; | ||
case WebPurchaseRedemptionResultType.INVALID_TOKEN: | ||
// The redemption link is invalid. | ||
break; | ||
case WebPurchaseRedemptionResultType.EXPIRED: | ||
const obfuscatedEmail: string = result.obfuscatedEmail; | ||
// The redemption link has expired. A new one has been sent to the user to the provided obfuscated email. | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
string redemptionUrl = 'YOUR_REDEMPTION_URL'; | ||
|
||
purchases.ParseAsWebPurchaseRedemption(redemptionUrl, (webPurchaseRedemption) => | ||
{ | ||
if (webPurchaseRedemption != null) | ||
{ | ||
purchases.RedeemWebPurchase(webPurchaseRedemption, (result) => | ||
{ | ||
switch (result) | ||
{ | ||
case Purchases.WebPurchaseRedemptionResult.Success success: | ||
Purchases.CustomerInfo customerInfo = success.CustomerInfo; | ||
// Redemption was successful and entitlements were granted to the user. | ||
break; | ||
case Purchases.WebPurchaseRedemptionResult.RedemptionError error: | ||
Purchases.Error error = error.Error; | ||
// Redemption failed due to an error. | ||
break; | ||
case Purchases.WebPurchaseRedemptionResult.InvalidToken: | ||
// The redemption link is invalid. | ||
break; | ||
case Purchases.WebPurchaseRedemptionResult.PurchaseBelongsToOtherUser: | ||
// The purchase associated to the link belongs to a different user and it cannot be redeemed. | ||
break; | ||
case Purchases.WebPurchaseRedemptionResult.Expired expired: | ||
string obfuscatedEmail = expired.ObfuscatedEmail; | ||
// The redemption link has expired. A new one has been sent to the user to the provided obfuscated email. | ||
break; | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters