Skip to content

[in_app_purchase] Add expiration date to Transaction #8030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.19

* Adds StoreKit2 Transaction expiration date.

## 0.3.18+5

* Updates README to remove contributor-focused documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,15 @@ extension Product.PurchaseResult {
extension Transaction {
func convertToPigeon(receipt: String?) -> SK2TransactionMessage {

let dateFromatter: DateFormatter = DateFormatter()
dateFromatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

return SK2TransactionMessage(
id: Int64(id),
originalId: Int64(originalID),
productId: productID,
purchaseDate: dateFromatter.string(from: purchaseDate),
purchaseDate: dateFormatter.string(from: purchaseDate),
expirationDate: expirationDate.map { dateFormatter.string(from: $0) },
purchasedQuantity: Int64(purchasedQuantity),
appAccountToken: appAccountToken?.uuidString,
restoring: receipt != nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ struct SK2TransactionMessage {
var originalId: Int64
var productId: String
var purchaseDate: String
var expirationDate: String? = nil
var purchasedQuantity: Int64
var appAccountToken: String? = nil
var restoring: Bool
Expand All @@ -324,17 +325,19 @@ struct SK2TransactionMessage {
let originalId = pigeonVar_list[1] as! Int64
let productId = pigeonVar_list[2] as! String
let purchaseDate = pigeonVar_list[3] as! String
let purchasedQuantity = pigeonVar_list[4] as! Int64
let appAccountToken: String? = nilOrValue(pigeonVar_list[5])
let restoring = pigeonVar_list[6] as! Bool
let receiptData: String? = nilOrValue(pigeonVar_list[7])
let error: SK2ErrorMessage? = nilOrValue(pigeonVar_list[8])
let expirationDate: String? = nilOrValue(pigeonVar_list[4])
let purchasedQuantity = pigeonVar_list[5] as! Int64
let appAccountToken: String? = nilOrValue(pigeonVar_list[6])
let restoring = pigeonVar_list[7] as! Bool
let receiptData: String? = nilOrValue(pigeonVar_list[8])
let error: SK2ErrorMessage? = nilOrValue(pigeonVar_list[9])

return SK2TransactionMessage(
id: id,
originalId: originalId,
productId: productId,
purchaseDate: purchaseDate,
expirationDate: expirationDate,
purchasedQuantity: purchasedQuantity,
appAccountToken: appAccountToken,
restoring: restoring,
Expand All @@ -348,6 +351,7 @@ struct SK2TransactionMessage {
originalId,
productId,
purchaseDate,
expirationDate,
purchasedQuantity,
appAccountToken,
restoring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class SK2TransactionMessage {
required this.originalId,
required this.productId,
required this.purchaseDate,
this.expirationDate,
this.purchasedQuantity = 1,
this.appAccountToken,
this.restoring = false,
Expand All @@ -315,6 +316,8 @@ class SK2TransactionMessage {

String purchaseDate;

String? expirationDate;

int purchasedQuantity;

String? appAccountToken;
Expand All @@ -331,6 +334,7 @@ class SK2TransactionMessage {
originalId,
productId,
purchaseDate,
expirationDate,
purchasedQuantity,
appAccountToken,
restoring,
Expand All @@ -346,11 +350,12 @@ class SK2TransactionMessage {
originalId: result[1]! as int,
productId: result[2]! as String,
purchaseDate: result[3]! as String,
purchasedQuantity: result[4]! as int,
appAccountToken: result[5] as String?,
restoring: result[6]! as bool,
receiptData: result[7] as String?,
error: result[8] as SK2ErrorMessage?,
expirationDate: result[4] as String?,
purchasedQuantity: result[5]! as int,
appAccountToken: result[6] as String?,
restoring: result[7]! as bool,
receiptData: result[8] as String?,
error: result[9] as SK2ErrorMessage?,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SK2Transaction {
required this.originalId,
required this.productId,
required this.purchaseDate,
this.expirationDate,
this.quantity = 1,
required this.appAccountToken,
this.subscriptionGroupID,
Expand All @@ -43,6 +44,9 @@ class SK2Transaction {
/// restored product, or for a subscription purchase or renewal after a lapse.
final String purchaseDate;

/// The date the subscription expires or renews.
final String? expirationDate;

/// The number of consumable products purchased.
final int quantity;

Expand Down Expand Up @@ -100,6 +104,7 @@ extension on SK2TransactionMessage {
originalId: originalId.toString(),
productId: productId,
purchaseDate: purchaseDate,
expirationDate: expirationDate,
appAccountToken: appAccountToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class SK2TransactionMessage {
required this.originalId,
required this.productId,
required this.purchaseDate,
this.expirationDate,
this.purchasedQuantity = 1,
this.appAccountToken,
this.error,
Expand All @@ -150,6 +151,7 @@ class SK2TransactionMessage {
final int originalId;
final String productId;
final String purchaseDate;
final String? expirationDate;
final int purchasedQuantity;
final String? appAccountToken;
final bool restoring;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.18+5
version: 0.3.19

environment:
sdk: ^3.3.0
Expand Down