Reputation: 361
I am using the payments API for an in-app purchase inside a Chrome extension.
I am able to initiate a purchase, which works and activates the transaction, But the callback goes to onPurchaseFailed instead of onPurchase.
manifest:
"offline_enabled": true,
"name": "__MSG_name__",
"description": "__MSG_description__",
"manifest_version": 2,
"version": "1.1.2",
"default_locale": "en",
"icons": {
"128": "style/128_on.png"
},
"background": {
"persistent": true,
"scripts": [ "js/jquery.min.js","js/bg.js" ]
},
"browser_action": {
"default_title": "__MSG_name__",
"default_icon": "style/128_off.png",
"default_popup": "popup.html"
},
"key": "...",
"oauth2": {
"client_id": "...",
"scopes": [ "https://www.googleapis.com/auth/chromewebstore.readonly" ]
},
"permissions": [ "*://*/*", "activeTab", "tabCapture", "tabs" ]
API buy method:
google.payments.inapp.buy({
parameters: {'env': "prod"},
'sku': sku,
'success': onPurchase,
'failure': onPurchaseFailed
});
I'm getting:
onPurchaseFailed Object{
checkoutOrderId:"10370910..."
response:Object{
errorType:"PURCHASE_CANCELED"}
}
The license gets activated however:
google.payments.inapp.getPurchases({
'parameters': {'env': 'prod'},
'success': onLicenseUpdate,
'failure': onLicenseUpdateFail
});
returns :
createdTime: //some number
itemId: //some string
kind:"chromewebstore#payment"
sku: //some string
state:"ACTIVE"
I have a suspicion that this happens because the purchasing window sends a cancellation message when it closes, which triggers the onPurchaseFailed callback. How to handle this?
Upvotes: 1
Views: 132
Reputation: 11
The only way I've found is to check the payment at failure callback
Upvotes: 1