-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d2b67d
commit 75d1224
Showing
8 changed files
with
80 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
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
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
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 |
---|---|---|
|
@@ -169,8 +169,22 @@ void main() { | |
|
||
group('purchaseProduct', () { | ||
final map = <String, dynamic>{'unit': 'year', 'numberOfUnits': 1}; | ||
final product = Product( | ||
final androidProduct = Product( | ||
'merchant.pro.android', | ||
'base.product', | ||
'offerId', | ||
'offerToken', | ||
1500.00, | ||
'1500.00', | ||
'title', | ||
'INR', | ||
SubscriptionPeriod.fromMap(map), | ||
); | ||
final iOSProduct = Product( | ||
'merchant.pro.android', | ||
null, | ||
null, | ||
null, | ||
1500.00, | ||
'1500.00', | ||
'title', | ||
|
@@ -185,8 +199,16 @@ void main() { | |
'', | ||
'', | ||
); | ||
final params = { | ||
Constants.product: product.id, | ||
final paramsForAndroid = { | ||
Constants.product: androidProduct.id, | ||
Constants.offerToken: androidProduct.offerToken, | ||
Constants.customerId: customer.id ?? '', | ||
Constants.firstName: customer.firstName ?? '', | ||
Constants.lastName: customer.lastName ?? '', | ||
Constants.email: customer.email ?? '', | ||
}; | ||
final paramsForiOS = { | ||
Constants.product: iOSProduct.id, | ||
Constants.customerId: customer.id ?? '', | ||
Constants.firstName: customer.firstName ?? '', | ||
Constants.lastName: customer.lastName ?? '', | ||
|
@@ -195,11 +217,11 @@ void main() { | |
test('returns subscription result for Android', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final result = await Chargebee.purchaseProduct(product, 'abc'); | ||
final result = await Chargebee.purchaseProduct(androidProduct, customer: customer); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: params, | ||
arguments: paramsForAndroid, | ||
) | ||
]); | ||
expect(result.status, 'active'); | ||
|
@@ -208,24 +230,11 @@ void main() { | |
test('returns subscription result for iOS', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; | ||
final result = await Chargebee.purchaseProduct(product, 'abc'); | ||
final result = await Chargebee.purchaseProduct(iOSProduct, customer:customer); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: params, | ||
) | ||
]); | ||
expect(result.status, 'active'); | ||
}); | ||
|
||
test('subscribed with customer id for Android', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final result = await Chargebee.purchaseProduct(product, 'abc'); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: params, | ||
arguments: paramsForiOS, | ||
) | ||
]); | ||
expect(result.status, 'active'); | ||
|
@@ -234,11 +243,11 @@ void main() { | |
test('subscribed with customer id for iOS', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final result = await Chargebee.purchaseProduct(product, 'abc'); | ||
final result = await Chargebee.purchaseProduct(iOSProduct, customer: customer); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: params, | ||
arguments: paramsForiOS, | ||
) | ||
]); | ||
expect(result.status, 'active'); | ||
|
@@ -247,12 +256,13 @@ void main() { | |
test('subscribed with customer info for Android', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final result = await Chargebee.purchaseProduct(product, customer: CBCustomer('abc_flutter_test', 'flutter', 'test', '[email protected]')); | ||
final result = await Chargebee.purchaseProduct(androidProduct, customer: CBCustomer('abc_flutter_test', 'flutter', 'test', '[email protected]')); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: { | ||
Constants.product: product.id, | ||
Constants.product: androidProduct.id, | ||
Constants.offerToken: androidProduct.offerToken, | ||
Constants.customerId: 'abc_flutter_test', | ||
Constants.firstName: 'flutter', | ||
Constants.lastName: 'test', | ||
|
@@ -266,12 +276,12 @@ void main() { | |
test('subscribed with customer info for iOS', () async { | ||
channelResponse = purchaseResult; | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final result = await Chargebee.purchaseProduct(product, customer: CBCustomer('abc_flutter_test', 'flutter', 'test', '[email protected]')); | ||
final result = await Chargebee.purchaseProduct(iOSProduct, customer: CBCustomer('abc_flutter_test', 'flutter', 'test', '[email protected]')); | ||
expect(callStack, <Matcher>[ | ||
isMethodCall( | ||
Constants.mPurchaseProduct, | ||
arguments: { | ||
Constants.product: product.id, | ||
Constants.product: iOSProduct.id, | ||
Constants.customerId: 'abc_flutter_test', | ||
Constants.firstName: 'flutter', | ||
Constants.lastName: 'test', | ||
|
@@ -288,7 +298,7 @@ void main() { | |
code: 'PlatformError', message: 'An error occured',); | ||
}); | ||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; | ||
await expectLater(() => Chargebee.purchaseProduct(product), | ||
await expectLater(() => Chargebee.purchaseProduct(iOSProduct), | ||
throwsA(isA<PlatformException>()),); | ||
channel.setMockMethodCallHandler(null); | ||
}); | ||
|
@@ -299,7 +309,7 @@ void main() { | |
code: 'PlatformError', message: 'An error occured',); | ||
}); | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
await expectLater(() => Chargebee.purchaseProduct(product), | ||
await expectLater(() => Chargebee.purchaseProduct(androidProduct), | ||
throwsA(isA<PlatformException>()),); | ||
channel.setMockMethodCallHandler(null); | ||
}); | ||
|
@@ -837,6 +847,9 @@ void main() { | |
final map = <String, dynamic>{'unit': 'year', 'numberOfUnits': 1}; | ||
final product = Product( | ||
'merchant.pro.android', | ||
'base.product', | ||
'offerId', | ||
'offerToken', | ||
1500.00, | ||
'1500.00', | ||
'title', | ||
|
@@ -1011,11 +1024,14 @@ void main() { | |
group('validateReceiptForNonSubscriptions', () { | ||
final product = Product( | ||
'merchant.pro.android', | ||
'base.product', | ||
'offerId', | ||
'offerToken', | ||
1500.00, | ||
'1500.00', | ||
'title', | ||
'INR', | ||
SubscriptionPeriod.fromMap({'periodUnit': 'month', 'numberOfUnits': 1}), | ||
SubscriptionPeriod.fromMap({'periodUnit': 'month', 'numberOfUnits': 1}), | ||
); | ||
const consumableProductType = ProductType.consumable; | ||
const nonConsumableProductType = ProductType.non_consumable; | ||
|