diff --git a/atom/browser/in_app_purchase.h b/atom/browser/in_app_purchase.h index 902d70deacf..d4957e8c97f 100644 --- a/atom/browser/in_app_purchase.h +++ b/atom/browser/in_app_purchase.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef ATOM_BROWSER_UI_IN_APP_PURCHASE_H_ -#define ATOM_BROWSER_UI_IN_APP_PURCHASE_H_ +#ifndef ATOM_BROWSER_IN_APP_PURCHASE_H_ +#define ATOM_BROWSER_IN_APP_PURCHASE_H_ #include @@ -27,4 +27,4 @@ void PurchaseProduct(const std::string& productID, } // namespace in_app_purchase -#endif // ATOM_BROWSER_UI_IN_APP_PURCHASE_H_ +#endif // ATOM_BROWSER_IN_APP_PURCHASE_H_ diff --git a/atom/browser/in_app_purchase_mac.mm b/atom/browser/in_app_purchase_mac.mm index 9e859e7faac..5f4c994a0bc 100644 --- a/atom/browser/in_app_purchase_mac.mm +++ b/atom/browser/in_app_purchase_mac.mm @@ -112,8 +112,10 @@ * @param product - The product to purchase. */ - (void)runCallback:(bool)isProductValid { - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::Bind(callback_, isProductValid)); + if (callback_) { + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, + base::Bind(callback_, isProductValid)); + } } @end diff --git a/atom/browser/in_app_purchase_observer.h b/atom/browser/in_app_purchase_observer.h index 450ee286b34..4b9f1d7b984 100644 --- a/atom/browser/in_app_purchase_observer.h +++ b/atom/browser/in_app_purchase_observer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef ATOM_BROWSER_UI_IN_APP_PURCHASE_OBSERVER_H_ -#define ATOM_BROWSER_UI_IN_APP_PURCHASE_OBSERVER_H_ +#ifndef ATOM_BROWSER_IN_APP_PURCHASE_OBSERVER_H_ +#define ATOM_BROWSER_IN_APP_PURCHASE_OBSERVER_H_ #include @@ -38,4 +38,4 @@ void AddTransactionObserver(const InAppTransactionCallback& callback); } // namespace in_app_purchase -#endif // ATOM_BROWSER_UI_IN_APP_PURCHASE_OBSERVER_H_ +#endif // ATOM_BROWSER_IN_APP_PURCHASE_OBSERVER_H_ diff --git a/lib/browser/api/in-app-purchase.js b/lib/browser/api/in-app-purchase.js index a0585e80dd9..e88b210ea9c 100644 --- a/lib/browser/api/in-app-purchase.js +++ b/lib/browser/api/in-app-purchase.js @@ -6,32 +6,25 @@ const v8Util = process.atomBinding('v8_util') module.exports = { canMakePayments: function() { - return binding.canMakePayments(); + return binding.canMakePayments() }, getReceiptURL: function() { - return binding.getReceiptURL(); + return binding.getReceiptURL() }, - purchaseProduct: function(productID, quantity, callback) { - + purchaseProduct: function(productID, quantity = 1, callback) { if (typeof productID !== 'string') { throw new TypeError('productID must be a string') } - - if (typeof quantity !== 'number') { + if (typeof quantity === 'function') { quantity = 1 + callback = quantity } - - if (typeof callback !== 'function') { - callback = function() {}; - } - return binding.purchaseProduct(productID, quantity, callback) }, addTransactionListener: function(callback) { - if (typeof callback !== 'function') { throw new TypeError('callback must be a function') }