Giter Club home page Giter Club logo

cordova-plugin-purchase's Introduction

Cordova Purchase Plugin

In-App Purchases for Cordova


Need professional help and support? Contact Me.

Summary

This plugin allows In-App Purchases to be made from Cordova, Ionic and Capacitor applications.

It lets you handle in-app purchases on many platforms with a single codebase.

This is a plugin for the Apache Cordova framework that provides an easy and flexible way to integrate in-app purchases into Cordova-based mobile applications, including popular frameworks such as Ionic and PhoneGap. With this plugin, you can easily add support for in-app purchases of digital content, such as subscriptions, consumables, and non-consumables, using the store-specific purchase APIs provided by the major mobile platforms. The plugin also supports requesting payments through popular payment providers such as Braintree, allowing you to easily accept payments from your users.

The Cordova-Plugin-Purchase plugin is designed to be easy to use and integrate into your Cordova app, and it provides a consistent API across all supported platforms, so you can focus on building your app without worrying about platform-specific differences. Whether you are building a subscription-based app, a freemium app, or any other app that requires in-app purchases, the Cordova-Plugin-Purchase plugin can help you get started quickly and easily.

Features

AppStore (iOS / macOS) Google Play Braintree (iOS / Android)
consumables
non consumables
subscriptions
restore purchases
payment requests
receipt validation

Installation

Install the plugin (Cordova)

cordova plugin add "cordova-plugin-purchase"

Recommended plugins

Install cordova-plugin-network-information (click for details).

Sometimes, the plugin cannot connect to the app store because it has no network connection. It will then retry either:

  • periodically after a certain amount of time;
  • when the device fires an 'online' event.

The cordova-plugin-network-information plugin is required in order for the 'online' event to be properly received in the Cordova application. Without it, this plugin will only be able to use the periodic check to determine if the device is back online.

Install cordova-plugin-advanced-http (click for details).

When making receipt validation requests, the purchase plugin uses, by default, the browser's ajax capabilities. This sometime causes issues with CORS restriction. CORS also imposes an extra back-and-forth with the server (the CORS preflight request) to ensure the server allows for such request to be made. By installing the advanced-http plugin, you get rid of those issue and benefit from the extra feature of the the plugin, like advanced authentication option. Read the advanced-http plugin documentation for details.

Note for ionic 3

Since version 13 of the plugin, it should be used without @ionic-native/in-app-purchase-2.

ionic 3 doesn't support recent typescript notations, but the plugin can be used without typings by just declaring it:

declare var CdvPurchase: any

Note for Capacitor users

Capacitor users can install the latest version of the plugin without the help of the awesome-cordova-plugins wrapper. Just install the cordova-plugin-purchase module and import "cordova-plugin-purchase" in files where it's needed. (some user reported using import "cordova-plugin-purchase/www/store.d" to get it working).

As with other plugins, you should wait for Capacitor this.platform.ready() before using the plugin.

import 'cordova-plugin-purchase';

@Injectable()
export class AppStoreService {

  // DO NOT initialize to CdvPurchase.store here
  store?: CdvPurchase.Store;

  constructor() {
    this.platform.ready().then(() => {
      // MUST WAIT for Cordova to initialize before referencing CdvPurchase namespace
      this.store = CdvPurchase.store
    });
  }
}

Setup your Application

See Setup iOS Applications and Setup Android Applications.

Getting Started

Learning about In-App Purchases

If you wish to learn more about In-App Purchases (IAP), you'll find a good overview on the subject from the various platforms documentation:

All platforms share the same concepts, so they are a good reads in all cases.

Using the Plugin

To ease the beginning of your journey into the intimidating world of In-App Purchase with Cordova, we wrote a guide which hopefully will help you get things done:

You'll have two main tasks to accomplish:

  1. Setup your application and In-App Products on AppStore, Play, Braintree or Azure platforms using their respective web interfaces.
  2. Add In-App Purchase code to your application.

For platform setup, the wiki is a good starting point.

There's a specific page for the version 13.

API documentation can be found here: cordova-plugin-purchase API

Upgrading to Version 13

There's been some changes to the API with version 13 of the plugin. This document should help existing apps with the migration: Migrate to version 13.

Extra Resources

For iOS

Extensions

  • Braintree SDK
    • Add the Braintree SDK to your application, enable Braintree on iOS and Android.

Subscriptions

For proper subscription support, you need a receipt validation server. You can implement your own or use Iaptic's receipt validation service.

Here is a full example of a cordova application implementing subscriptions, with and without a backend server:

Contribute

Contributors:

  • Jean-Christophe Hoelt, Author
  • Josef Fröhle, Support
  • Guillaume Charhon, (now defunct) v1 for android
  • Matt Kane, initial iOS code
  • Mohammad Naghavi, original unification attempt
  • Dave Alden @dpa99c (Apple-hosted IAPs for iOS)

Sponsors

Licence

The MIT License

Copyright (c) 2014-, Jean-Christophe HOELT and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

cordova-plugin-purchase's People

Contributors

aharbick avatar bostondv avatar caiiiycuk avatar chuckv01 avatar davvidbaker avatar deonkuhn avatar dependabot[bot] avatar dexus avatar dkarzon avatar dominic-simplan avatar dpa99c avatar dwburns avatar epabst avatar giuseppelt avatar hernanzh avatar j3k0 avatar jacknova avatar jacse avatar jkirkell avatar jscorales avatar kitsunde avatar kurtiev avatar mcroker avatar phfsantos avatar qwelias avatar sebastianzillessen avatar tehmaestro avatar theunreal avatar trumpet2012 avatar uareurapid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-purchase's Issues

transactionId not passed on restore

Sadly, I not able to reproduce it using the Apple sandbox env but few of our customers can't restore subscriptions on different device, looking at the server log it seems that the transaction id is not passed.

It seems to happen with IOS7 (but not 100% confirmed). Does anyone had the same issue? Also does the restore process is different on IOS 7, for purchase we have to use receipts.appStoreReceipt, is it the same for restore?

Thanks

Invalid product identifier: (null)

Hi!

I am trying your plugin in a phonegap 3.0 hello world project to keep things simple. When I call the purchase function:
window.storekit.purchase("com.example.app.inappid1", 1);

I am getting in the console:

2013-10-08 16:19:54.062 InAppTest[2934:60b] InAppPurchase[objc]: About to do IAP
2013-10-08 16:19:54.064 InAppTest[2934:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
*** First throw call stack:
(0x31303f53 0x3b6da6af 0x31303e95 0x33a0690f 0x105897 0xfe3e1 0xfdd11 0xfd8e9 0xfda93 0xfd9b1 0x31ce703b 0x312cf18b 0x312ce65b 0x312cce4f 0x31237ce7 0x31237acb 0x35f58283 0x33ad9a41 0x103f67 0x103f28)
libc++abi.dylib: terminating with uncaught exception of type NSException

The "null" is very weird. I am getting the same issue in my real app with the real app id. Any ideas of what could be wrong?

Thanks a lot for your help!

poiuytrez

PS: My real app is using Phonegap 1.9 with the old inappplugin (I even contributed to it). I am upgrading it to Phonegap 3.0

IAP.onRestore not firing

The callback for a successful restore isn't firing.

  • (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue is running but the code in it is commented.

Running Phonegap 3.1. Could that be the reason?

Get currency code & unformatted price for product

For tracking purposes we need to know the price & currency for the products.

I've made some changes so that storekit.load returns these values alongside the preformatted price. We tested it with different countries and so far it worked fine.

I'm not submitting a pull request as the current implementation would break existing code. In our code price is used for returning an unformatted number and the new localizedPrice is the formatted price as it was before.

See the changes for yourself here: https://github.com/platogo/PhoneGap-InAppPurchase-iOS/commit/0e8e842a246a0f2ab92d65932cffa49dd892568e

It would be great if price & currency code would find their way into the plugin.
Also, thanks for providing this plugin!

crash after purchase in testenvironment

Hello, I use cordova 3.4.1 my app crashes after purchasing an item.

2014-05-11 21:12:30.598 appname[10564:60b] InAppPurchase[objc]: State: PaymentTransactionStateFailed
2014-05-11 21:12:40.786 appname10564:60b] InAppPurchase[objc]: About to do IAP
2014-05-11 21:12:40.787 appname[10564:60b] InAppPurchase[objc]: Payment transaction updated ((null)):
2014-05-11 21:12:40.789 appname[10564:60b] InAppPurchase[objc]: Purchasing...
2014-05-11 21:12:57.449 appname[10564:60b] InAppPurchase[objc]: Payment transaction updated (3):
2014-05-11 21:12:57.451 appname[10564:60b] InAppPurchase[objc]: State: PaymentTransactionStatePurchased
2014-05-11 21:12:57.472 appname[10564:60b] InAppPurchase[objc]: Transaction 1000000110332005 finished.
appname(10564,0x3d36f18c) malloc: *** error for object 0x1722b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 10564 stopped

  • thread #1: tid = 0x17c2fa, 0x3b3ca1f0 libsystem_kernel.dylib__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x3b3ca1f0 libsystem_kernel.dylib__pthread_kill + 8
    libsystem_kernel.dylib`__pthread_kill + 8:
    -> 0x3b3ca1f0: blo 0x3b3ca208 ; __pthread_kill + 32
    0x3b3ca1f4: ldr r12, [pc, #4] ; __pthread_kill + 24
    0x3b3ca1f8: ldr r12, [pc, r12]
    0x3b3ca1fc: b 0x3b3ca204 ; __pthread_kill + 28

Anyone an idea?

Add integer error codes to the android plugin

Look for callbackContext.error in "InAppBilling.java".

The IabResult object already provides an integer status code, that just isn't passed to javascript error callback. Maybe to keep things backward compatible, it could be passed as an optional second argument to the error callbacks.

Typo in the readme

Reads:
phonegap local add git://github.com/j3k0/PhoneGap-InAppPurchase-iOS.git

I had to run:
phonegap local plugin add git://github.com/j3k0/PhoneGap-InAppPurchase-iOS.git

purchase callback

Hi,

Is it possible to add a custom callback function on purchase besides the one we need to give the init function?
I'd like to be able to run some code after a purchase is successfull, but in a different part of the code...

Thank you.

Publish to plugins.cordova.io

I'd like to have this plugin published to the cordova plugin registry, so that other published plugins can declare it as a dependency. com.google.payments would use this immediately, if it were made available there.

I'm willing to do the work of getting it published, and assigning ownership to you if necessary; just let me know.

Manually call finishTransaction

This may already be possible, if it is please let me know.

It would be really useful in some cases to be able to manually call finishTransaction rather than have it done automatically. Consider an auto-renewing subscription where subscriptions need to be tracked on the app server to authorize certain content.

  1. the user makes a purchase
  2. the onPurchase handler grabs the transactionID and receipt and uses AJAX to send them to the app server
  3. some unexpected error occurs on the app server-side that prevents storing the data

Currently, my understanding is that the app will still call finishTransaction. Desired behavior would be to wait for a response from the app server and a) retry if it failed or display some error message to the user or b) manually call finishTransaction if it succeeded.

Android Support

Add android support to the plugin. Turn it into a multi-platform In-App-Purchase solution.

The idea would be to provide as much abstraction of the platform as possible, yet giving access to platform specific APIs.

It could be implemented as a layered architecture:

  • keep the iOS plugin mostly as-is, make it available through "store.ios"
  • find the most stable Android In-App-Purchase available (any suggestion?), integrate it with minimal amount of changes as "store.android"
  • add a new layer of javascript API, built on top of that, that would present a uniform, generic, multi-platform "store" API.

It probably won't be possible to abstract everything, I think about things like receipts validation for instance... (except if we also provide server-side code, but lets keep this for later).

This is just a starting point of reflection. Please tell me what you think, share your remarks and ideas.

ios 6.0 validation

Hi,
i'm new to all this stuff and can now successfully validate purchases made from ios7+ devices via php. Thanks for that!

But i'm really struggling with validating receipts for ios6.
What should i do with the receipts.forTransaction(transactionId) to validate it?
When i send it untouched to the sandbox i get the
[status] => 21002
[exception] => java.lang.IllegalArgumentException
result.
The same when i try to base64 encode it with php or replace blanks with + etc.
I noticed a space around the 10. character and no == at the of the receipt. So i assume it's not properly encoded by the client or is it another validation progress than in 7?
Type is consumable

window.storekit is undefined.

Hey,

So I've double checked and triple checked to make sure everything is set up correctly, but in deviceready, when I alert window.storekit, it says it is undefined. We're using Cordova 2.9 and xCode 5, deploying to iOS 5 using the iOS 7 SDK.

Any help would be appreciated. Thanks.

Incorrect error code on dequeued transaction

SKPaymentTransactionStateFailed produces error callback with transaction error code

errorCode = transaction.error.code;

and thanks to that it doesnt follow InAppPurchase.ERR_* codes stategy.

Hosting content on Apple servers

Heya,

Any idea would this work out of the box or do I need some configuring? For what its worth, I read something about using the SKDownload class to download the content.

You can read more about it in the In-app-purchase guide provided by Apple.

Thank you already for the plugin :)

Crashing after initialization

Hi there,

First of all, thank you for doing this. I had been trying to do this on my own, and it was not working at all, so your plugin has filled in a lot of the blanks I had.

Right now, I'm just trying to initialize, then display the items in an alert, to try it out. Here's some of my code:

initialize: function() {
    console.log('IOS STORE INITIALIZING');

    var me = this;
    var readyCallback = function successCallback(result) {
        console.log( 'STORE INITIALIZED' )
        me.getDetails();
    };

    storekit.init({
        debug:    true, // Enable IAP messages on the console
        ready:    readyCallback,
        purchase: function() { alert('coming soon') },
        restore:  function() { alert('coming soon') },
        error:    function() { alert('error') }
    });
},


getDetails: function() {
    var skuList = [/* An array of my SKUs */];
    var successCallback = function() {
        var strResult = "";
        if(typeof result === 'object') {
            strResult = JSON.stringify(result);
        } else {
            strResult = result;
        }
        alert("SUCCESS: \r\n" + strResult );
    }
    storekit.load( skuList, successCallback );
}

Now, the alert pops up with the details of my products, but then the app immediately crashes. Here's where it crashes:

- (void)evalJsHelper2:(NSString*)js
{
    CDV_EXEC_LOG(@"Exec: evalling: %@", [js substringToIndex:MIN([js length], 160)]);
    NSString* commandsJSON = [_viewController.webView stringByEvaluatingJavaScriptFromString:js];
    if ([commandsJSON length] > 0) {
        CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by chaining.");
    }

    [_commandQueue enqueueCommandBatch:commandsJSON];
    [_commandQueue executePending];
}

It fails trying to set commandsJSON. The value of js is a string:

cordova.require('cordova/exec').nativeCallback('InAppPurchase662531270',1,
  [
    [
      {
        "title" : "Video 5",
        "id" : "sku1",
        "price" : "$0.99",
        "description" : "Product description goes here."
      },
      {
        "title" : "Video 6",
        "id" : "sku2",
        "price" : "$0.99",
        "description" : "Product description goes here."
      }
    ],
    [

    ]
  ]
,0)

Any idea what I'm doing wrong?

clear Queue

The plugin is working like charm but I recommend to add function to clear the old transactions Queue.
thanks.

[issue] Can it handle store redirection error?

If user used other store (e.g. France) last time, then when IAP popups a dialog for entering iTunes account and he enters account for US store, he will see an alert for store redirection (from current France to US, default store of being entered account). The app doesn't know this case and just gets an error. Worse, App Store also shows below error in a blank page:

Your request produced an error.
[new NullResponse]

iOS 7.1.1 Support

Apparently there's something wrong when we try to purchase on 7.1.1

I will do more debugging and will try to get back asap but I just got one of my apps rejected :)
(My bad, I didn't upgrade my testing device).

Will be posting back soon.

Anybody else having this issue?

Cannot finish transaction

Hello there,
thank you for do this beautiful plugin. I have a problem when i call purchase. Debug of xcode answer Cannot finish transaction, and i don't have recepit. Can you help me?
This is debug:
2014-06-08 16:58:54.027 Tis[571:60b] InAppPurchase[objc]: About to do IAP
2014-06-08 16:58:54.028 Tis[571:60b] InAppPurchase[objc]: Payment transaction updated ((null)):
2014-06-08 16:58:54.030 Tis[571:60b] InAppPurchase[objc]: Purchasing...
2014-06-08 16:58:58.684 Tis[571:60b] InAppPurchase[objc]: Payment transaction updated ((null)):
2014-06-08 16:58:58.685 Tis[571:60b] InAppPurchase[objc]: State: PaymentTransactionStatePurchased
2014-06-08 16:58:58.689 Tis[571:60b] InAppPurchase[objc]: Cannot finish transaction 1000000113327529.

IAP.onRestore not firing

Hi, Thanks for very useful plugin.
there is a problem IAP.onRestore not firing
please guide me

Invalid product identifier: (null)

Hi!

I am trying your plugin in a phonegap 3.0 hello world project to keep things simple. When I call the purchase function:
window.storekit.purchase("com.example.app.inappid1", 1);

I am getting in the console:

2013-10-08 16:19:54.062 InAppTest[2934:60b] InAppPurchase[objc]: About to do IAP
2013-10-08 16:19:54.064 InAppTest[2934:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
*** First throw call stack:
(0x31303f53 0x3b6da6af 0x31303e95 0x33a0690f 0x105897 0xfe3e1 0xfdd11 0xfd8e9 0xfda93 0xfd9b1 0x31ce703b 0x312cf18b 0x312ce65b 0x312cce4f 0x31237ce7 0x31237acb 0x35f58283 0x33ad9a41 0x103f67 0x103f28)
libc++abi.dylib: terminating with uncaught exception of type NSException

The "null" is very weird. I am getting the same issue in my real app with the real app id. Any ideas of what could be wrong?

Thanks a lot for your help!

poiuytrez

PS: My real app is using Phonegap 1.9 with the old inappplugin (I even contributed to it). I am upgrading it to Phonegap 3.0

iOS 7 support.

Hey guys,

Any chance of getting full iOS 7 support in the near future? Specifically, the transactionReceipt property is deprecated in iOS 7, and we need to use the appStoreReceiptUrl property of the mainBundle object to be able to get the transaction receipt. Without this, it is impossible to verify purchases on iOS 7. I'd do this myself, but obj-c is beyond me at this point.

Thanks.

restoreCompleted never fires

Hi there,

In my test setup (Phonegap app running on iPad Mini with iOS 7), running the storekit.restore() command causes the 'restore' event handler to fire for every restored purchase, but the restoreCompleted handler never runs.

Your docs are not 100% clear to me on this issue, but I expected the 'restore' handler to be fired for every individual restored purchase and the 'restoreCompleted' to be fired when all purchases were restored.

If I check your .js and .m files, I see that this is not how it works. In the file inAppPurchase.m, the handlers "restoreCompletedTransactionsFailedWithError" and "restoreCompletedTransactionsFinished" only do one line of debugging, the rest of the code is commented out.

I noticed that both of these commented-out bits refer to javascript handlers with a slightly different name, including an unused "on" prefix:
onRestoreCompletedTransactionsFailed (in the .m file)
restoreCompletedTransactionsFailed (in the js file)

Could it be that this caused errors, and you commented out the code to prevent bigger problems?

Regards,

Wytze

receipts.appStoreReceipt() in README.md

in "Advanced use/Receipts" section:
...
receipts.appStoreReceipt(); // null or base64 encoded receipt (iOS >= 7)
...
receipts.appStoreReceipt is not a function, I think it's should be:
...
receipts.appStoreReceipt; // null or base64 encoded receipt (iOS >= 7)
...
it's kinda a little problem, but fixing it will save people time to debug code like me: I submit my app 2 days ago without testing IAP on iOS7 until I found this problem.

Ipad iOS 7.1.1 support for In App Purchases

Hi

There seems to be a problem with the in app purchases plugin and iOS 7 on iPads. It works perfectly on an iphone, but on an ipad the IAP information is not shown and neither is the purchase button. Only the restore all button appears.

Any ideas.

My app gets rejected from the itunes.connect store due to this issue.

screenshot_0-2
img_1243

Does not support multiple calls to load()

There's a bug in the Javascript where the plugin won't maintain which product IDs have been previously loaded in a load() call, and therefore won't allow you to purchase a product that has previously been loaded.

If I call storekit.load("A"), then call storekit.load("B"), the InAppPurchase.js overwrites the array of productIDs with "B" only.

This happens on line 196 of InAppPurchase.js:

    InAppPurchase._productIds = productIds;

Our use case for this is a paginated list of products from our server. Rather than loading up hundreds of products from our server on app start, we paginate them, loading them from the app store as we get the products from our server.

[issue] storekit.restore is fired multiple times

If user purchased more than one items in the past, then he restores on a new device now, then storekit.restore event is fired multiple times for every item. It's expectable behavior, except we don't know in advance how many times this event will be fired. So if for example we show an alert (to say thank you) in the event handler, it will be displayed more than one time, and it surely annoys user.

iOS 8.0 not getting past storekit.init()

Unfortunately this is my first experience with Cordova development.

When I call storekit.init() absolutely nothing happens. I don't get past it, I don't trigger ready(), I don't see any details in the console.

Do I need to include a license key anywhere?

Is there any known issues with iOS 8 yet?

noAutoFinish: "finish" callback is called when a purchase failed

@maxmoore14 : do you remember if it necessary to call StoreKit's finish on a failed transaction?

https://github.com/j3k0/PhoneGap-InAppPurchase-iOS/blob/master/src/ios/InAppPurchase.m#L403-L407

Anyway, I don't think user side's finish() callback should be called in that case, or maybe with a error code as a parameter. The behavior is especially weird when storekit.purchase() is called again by the user on a product with non-finished transaction in progress: this results in a failed transaction and user code's finish() callback called directly... Could be mind-bugging ;)

Any thoughts?

IAP.onPurchase not firing

I've got a problem with the callback function when doing a purchase, In the console of Xcode, it gives me an ok on the purchase, the product gets purchased and I get an succes.

When I look at the InAppPurchase.prototype.purchase function, it never gets into the purchaseOk or purchaseFailed function, which should be called by the exec purchase command.

Any ideas where this can go wrong?

Receipt is undefined

One of the problems with Cordova is the ability to call Javascript functions from the web inspector.

As such I want to send the receipt of the purchase to our server along with the request to validate serverSide that the purchase has been made.

However, it seems that the receipt parameter in the onPurchase callback is always undefined.

Xcode unable to find InAppPurchase

Hey,

I have tried to implement this IAP plugin, however whenever I try to run my code I consistently get the same error message in Xcode:

2014-05-06 16:41:57.281 Airborne[80261:70b] CDVPlugin class InAppPurchase (pluginName: InAppPurchase) does not exist.
2014-05-06 16:41:57.281 Airborne[80261:70b] ERROR: Plugin 'InAppPurchase' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-05-06 16:41:57.282 Airborne[80261:70b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"InAppPurchase466332499",
"InAppPurchase",
"setup",
[

]
]

I have absolutely no idea why this is happening, as it seems that all the files are there and registered in the proper confix.xml and cordova_plugins.json files. I am currently compiling with cordova version 3.4.1-0.1.0

Any help would be really appreciated

Your cross-platform Indiegogo campaign.

Hi. I saw your cross-platform IAP campaign. IAP code seems to be difficult to implement even without considering Cordova usage.

Edit: I see you are working on it. Great. :-)

uncaught exception during purchase

I assume this happens possibly because my app is still very young and I haven't signed my application with my developer license, but it would be nice if this didn't crash my app because of an unhandled exception. Here's the logs with relevant stack trace:

2014-01-08 20:58:25.066 XXX[52022:70b] InAppPurchase[objc]: About to do IAP
2014-01-08 20:58:25.075 XXX[52022:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
*** First throw call stack:
(
0 CoreFoundation 0x000f05e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01e088b6 objc_exception_throw + 44
2 CoreFoundation 0x000f03bb +[NSException raise:format:] + 139
3 StoreKit 0x019ae74f -[SKPaymentQueue addPayment:] + 659
4 XXX 0x00033098 -[InAppPurchase purchase:] + 440

Restore failed: Error code 0

Cordova: 3.0
Installation method: CLI

Everything is running smooth until I call the "restore()" method.

Console simply returns (as this is the JS method for restoreFailed()):

Restore Failed: 0

Then, seconds later, the console is updated with the (correctly) purchased items.

Payment transaction updated:
2013-11-27 18:22:35.768 MyApp[593:60b] InAppPurchase[objc]: State: PaymentTransactionStatePurchased
2013-11-27 18:22:35.769 MyApp[593:60b] InAppPurchase[objc]: js: window.storekit.updatedTransactionCallback.apply(window.storekit, [
  "PaymentTransactionStatePurchased",
  0,
  "",
  "1000000094876393",
  "com.my.product.id"
])

Is there something I'm doing wrong? What does error code 0 mean?

Return transaction receipt back to JS

When buying on the app store you get a transaction receipt from Apple, which should be used to verify that the purchase is real. This is quite important when unlocking content on a server, because it is the only way to actually secure your content from being stolen.

I see that you have commented it out InAppPurchase.m.

What are the reasons to not pass back to JS?

Monthly subscriptions?

Hi Jean-Christophe!

I currently trying to integrate a monthly subscription into my Cordova App - but unfortunately I do not have any clue how and I've opened an issue over at the ngStorekit repo from Alex:
https://github.com/AlexDisler/ng-storekit/issues/2#issuecomment-51860226

Seems like there's a serious need for this, so the question came up if it's even possible by using your current plugin?

Would be absolutely great if we can put something together (if it does not exist already and I'm just missing it?!) which can be used for the subscription payments!

Phonegap 3.0 compatibility? Project status?

Hello!

Just curious about this project status given the warning in the readme:

WARNING: I'M CURRENLTY REWRITING PART OF THIS PLUGING. IT'S NOT YET USABLE!

Now that cordova 3.0 is out it's unclear whether this will work or not, or whether it is still in active development.

Store Access Authorization

This is not really an issue as this plugin is for in-app purchases, but my question is related to this.
How to know what a user purchased ? Do you know if its possible ? do you know a plugin for it ?
Thank you and sorry for opening an issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.