Releases: j3k0/cordova-plugin-purchase
v13.3.3
Use canMakePayments on Apple AppStore
offer.canPurchase
will be false if the platform reports that it doesn't support the "order" functionality.
When you check if the offer can be purchased, the plugin will now use the value from canMakePurchases
(for Apple AppStore).
if (!offer.canPurchase) {
// the given offer cannot be purchased. hide it or hide the buy button.
}
If none of the offers can be purchased, you can choose to hide the whole store.
There are 2 reasons why an offer cannot be purchased:
- Product is already owned (see
product.owned
) - The adapter don't support "order()"
If you really want to access the low-level value of canMakePurchases
you can do it like so:
const appStore = store.getAdapter(CdvPurchase.Platform.APPLE_APPSTORE);
if (appStore && appStore.checkSupport('order')) {
// user can make payments
}
Ref #1378
v13.3.2
Add support for promotional offers on Apple AppStore
You can order a discount offer by providing additional data to "offer.order()" like so:
offer.order({
appStore: {
discount: {
id: "discount-id",
key: "...",
nonce: "...",
signature: "...",
timestamp: "...",
}
}
});
Check Apple documentation about the meaning of those fields and how to fill them. https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/setting_up_promotional_offers?language=objc
You can check this old example server here: https://github.com/j3k0/nodejs-suboffer-signature-server
v13.3.1
Fix "store.order" promise resolution
Wait for the transaction to be purchased or the purchase cancelled before resolving.
Example usage:
store.order(offer)
.then((result) => {
if (result && result.isError) {
if (result.code === CdvPurchase.ErrorCode.PAYMENT_CANCELLED) {
// Payment cancelled: window closed by user
}
else {
// Payment failed: check result.message
}
}
else {
// Success
}
});
v13.3.0
Add the AppStore autoFinish
option
Use this if the transaction queue is filled with unwanted transactions (in development).
It's safe to keep this option to "true" when using a receipt validation server and you only sell subscriptions
Example:
store.initialize([
{
platform: Platform.APPLE_APPSTORE,
options: { autoFinish: true }
},
Platform.GOOGLE_PLAY
]);
Optimize AppStore receipt loaded multiple times in parallel
When the Apple appStoreReceipt
is loaded from multiple source, it resulted in a lot of duplicate calls. 13.3.0 optimizes this use case.
Add transactionId and purchaseId to VerifiedPurchase
It's just a TypeScript definition since the plugin doesn't do much with it, but it has been requested by a few users.
v13.2.1
v13.2.0
v13.1.6
v13.1.5
AppStore fixes
- 51400ab Adding in-progress transaction to a pseudo receipt
- c0e47b3 Reloading receipt from native side before receipt validation
- 5a8542b Improved error reporting
- 7a80a6d Do not call "finished" for failed transactions
- 348431e Report success/failure of purchase
- e53017c Fix crash when logged out of iCloud (#1354)
v13.1.4
v13.1.3
Fixing some receipt validation use cases on Apple devices.
- 9cfce2d Load missing iOS appStoreReceipt when validation call is requested
- 2569147 Update validator functions to include the receipts
- f03a751 Refresh appStoreReceipt if empty at validation stage
Update to requestPayment()
In the payment request, the items
array now replace the productIds
array. Use this array to define the list of items the user is paying for. For example:
CdvPurchase.store.requestPayment({
platform: CdvPurchase.Platform.BRAINTREE,
amountMicros: 11000000,
currency: 'USD',
items: [{
id: 'margherita_large',
title: 'Pizza Margherita Large',
pricing: {
priceMicros: 10000000,
}
}, {
id: 'delivery_standard',
title: 'Delivery',
pricing: {
priceMicros: 1000000,
}
}]
});
The format for items makes them compatible with products loaded from the stores. You can then manage your inventory on Google Play but allow payment for those Google Play products using Braintree:
store.register([{
id: 'five_tokens',
type: ProductType.CONSUMABLE
platform: Platform.GOOGLE_PLAY,
}]);
// Later on...
store.requestPayment({
platform: CdvPurchase.Platform.BRAINTREE,
amountMicros: 11000000,
currency: 'USD',
items: [store.get('five_tokens')],
});
See PaymentRequest and PaymentRequestItem for details.
Fixes for Braintree.requestPayment()
Bug fixes:
- Properly using the provided
applePayOptions
- Detecting payment request cancellations by user
requestPayment() amount computed from items
If the amount is not provided in a payment request, it will be computed as the sum of all items.
Currency will also be retrieved from the items when missing.