capacitor-community / proposals

Plugin and platform requests ✋
74 stars 2 forks source link

In App Purchases #2

Open mhartington opened 4 years ago

mhartington commented 4 years ago

Plugin Request

Name: in-app-purchases Package: @capacitor-community/in-app-purchases

Platform(s)

iOS, Android

Description

Reviewing the work done here by this cordova plugins

https://ionicframework.com/docs/native/in-app-purchase-2

https://github.com/j3k0/cordova-plugin-purchase

Plugin should be cover most of the APIs listed there, to be able to avoid situations like this..

https://twitter.com/dhh/status/1272968382329942017

Ionitron commented 4 years ago

Original request: https://github.com/ionic-team/capacitor/issues/1102

selected-pixel-jameson commented 4 years ago

Please keep subscriptions in mind as this flow is different then just payments.

carsten-klaffke commented 4 years ago

I have a plugin for a Non‑Consumable, No-Subscription in-App purchase: capacitor-billing. It is implemented for both Android and iOS. Can I contribute?

Shekhar-Satyanshu commented 4 years ago

Is it also Worked for Android? It's not working on Android for me. I'm getting this error continuously that { errorCode: -2, message: "Billing is not initialized", code: -2 }

philmerrell commented 3 years ago

FWIW, I think this plugin is too crucial to be driven by the community. I hope an up-to-date, modern version of something like cordova-plugin-purchase would be up for consideration to be created by the Capacitor team.

As someone that is currently working w/ in app purchases, the plugins that are available right now are barely hanging on and in various states of not working well. At least that is my current experience working with iOS.

Shekhar-Satyanshu commented 3 years ago

Is it also Worked for Android? It's not working on Android for me. I'm getting this error continuously that { errorCode: -2, message: "Billing is not initialized", code: -2

The solution for this issue is, We need to change the url name from , InAppBillingV3.java if you are working with Ionic-React. But this plugin is very painful..There are no any option to handle the issue like --> If user will get the subscription, and after the month user cancel that, Don't know how can I get the status.

riderx commented 2 years ago

Any news on that ?

cossminuu commented 2 years ago

I have managed to implement this plugin on iOS and Android(ionic, capacitor, Vue). 3 days work because the documentation is very bad. If anyone needs help, contact me.

@Shekhar-Satyanshu you can check if the product is "owned" or not.

riderx commented 2 years ago

@cossminuu same but i don't want old buggy cordova plugin in my stack that the only one

riderx commented 2 years ago

I made one with revenuecat sdk in swift and capacitor implementation 👍 https://github.com/riderx/capacitor-purchases I’m working on the android part

Angel-Rivilla commented 2 years ago

@cossminuu can u Help my about In app purchase2 on capacitor, please?

riderx commented 2 years ago

@Angel-Rivilla whats your issue with witch plugin ?

Angel-Rivilla commented 2 years ago

I have problems with in app purchase 2 on capacitor for ios, when i buy a product i got invalid authentication

El mar, 4 ene 2022 a las 2:49, Martin DONADIEU @.***>) escribió:

@Angel-Rivilla https://github.com/Angel-Rivilla whats your issue with witch plugin ?

— Reply to this email directly, view it on GitHub https://github.com/capacitor-community/proposals/issues/2#issuecomment-1004470587, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT3KVFY2RJRNIMICV2ILOCDUUJG2RANCNFSM4OAQOKEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

riderx commented 2 years ago

@Angel-Rivilla a cannot really help for https://ionicframework.com/docs/native/in-app-purchase-2 since it's old cordova plugin. Did you try to ask for help in discord community ? Otherwise i can help you if you use : https://github.com/riderx/capacitor-purchases

cossminuu commented 2 years ago

@Angel-Rivilla can you please give me more details ? what type of error message do you get ?

Angel-Rivilla commented 2 years ago

Yes, im trying to test this payments with a sanbox user with one ios simulator on XCode and wach mys logs. Thanks for all !

o Native Cordova -> InAppPurchase purchase InAppPurchase75026 ["options": [pp_1299_1m, 1, , { }]] 2022-01-05 09:36:09.414910-0800 App[2859:38999] InAppPurchase[objc]: purchase: About to do IAP 2022-01-05 09:36:09.415394-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: pp_1299_1m 2022-01-05 09:36:09.415520-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: Purchasing... 2022-01-05 09:36:09.415635-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: State: PaymentTransactionStatePurchasing 2022-01-05 09:36:09.415747-0800 App[2859:38999] InAppPurchase[objc]: processTransactionUpdate:withArgs: transactionIdentifier= ⚡️ [log] - [store.js] DEBUG: ios -> is purchasing pp_1299_1m ⚡️ [log] - [store.js] DEBUG: state: pp_1299_1m -> initiated 2022-01-05 09:36:17.879645-0800 App[2859:41748] <SKPaymentQueue: 0x600001f00670>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x600001382910 {Error Domain=AMSErrorDomain Code=100 "Authentication Failed" UserInfo={NSLocalizedFailureReason=The verify credentials call failed., NSLocalizedDescription=Authentication Failed, NSUnderlyingError=0x600001382d60 {Error Domain=AMSErrorDomain Code=15 "Ocurrió un error desconocido. Reintenta." UserInfo={NSLocalizedDescription=Ocurrió un error desconocido. Reintenta.}}}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception} 2022-01-05 09:36:17.879874-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: pp_1299_1m 2022-01-05 09:36:17.880040-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: Error ERR_UNKNOWN - UNKNOWN_ERROR 2022-01-05 09:36:17.880203-0800 App[2859:38999] InAppPurchase[objc]: transactionFinished: (null) 2022-01-05 09:36:17.881022-0800 App[2859:38999] InAppPurchase[objc]: paymentQueue:updatedTransactions: State: PaymentTransactionStateFailed 2022-01-05 09:36:17.881165-0800 App[2859:38999] InAppPurchase[objc]: processTransactionUpdate:withArgs: transactionIdentifier= ⚡️ [log] - [store.js] ERROR: ios -> ERROR 6777010: UNKNOWN_ERROR - {"productId":"pp_1299_1m"} ⚡️ [log] - [store.js] DEBUG: state: pp_1299_1m -> valid

My code:

<-- TS -->

const PlanB_M = productsId.PlanB_Month; const PlanP_M = productsId.PlanP_Month;

@Component({ selector: 'app-account-plans-payment', templateUrl: './account-plans-payment.component.html', styleUrls: ['./account-plans-payment.component.scss'], }) export class AccountPlansPaymentComponent implements OnInit {

products: IAPProduct[] = []; isPro: boolean = false;

constructor( private navController: NavController, private paymentService: PaymentService, private plt: Platform, private alertController: AlertController, private store: InAppPurchase2, private ref: ChangeDetectorRef) { this.plt.ready().then(() => { // Only for debugging! this.store.verbosity = this.store.DEBUG;

              this.registerProducts();
              this.setupListeners();

              // Get the real product information
              this.store.ready(() => {
                this.products = this.store.products;
                this.ref.detectChanges();
              });
            });
           }

ngOnInit() { }

registerProducts() { this.store.register({ id: PlanB_M, type: this.store.PAID_SUBSCRIPTION });

this.store.register({
  id: PlanP_M,
  type: this.store.PAID_SUBSCRIPTION,
});

this.store.refresh();

}

purchase(product: IAPProduct) { this.store.order(product); }

restore() { this.store.refresh(); }

setupListeners() { this.store.when('product') .approved((p: IAPProduct) => { alert('Purchase completed') return p.verify(); });

  this.store.when('product')
  .verified((p: IAPProduct) => {
    p.finish();
  })

}

async presentAlert(header, message) { const alert = await this.alertController.create({ header, message, buttons: ['OK'] });

await alert.present();

}

<-- HTML -->

{{ p.title }}

{{ p.description }}

{{ p.price }} {{ p.currency }}

<ion-button expand="full" (click)="restore()">Restore

El mié, 5 ene 2022 a las 0:38, Cosmin Dumitriu @.***>) escribió:

@Angel-Rivilla https://github.com/Angel-Rivilla can you please give me more details ? what type of error message do you get ?

— Reply to this email directly, view it on GitHub https://github.com/capacitor-community/proposals/issues/2#issuecomment-1005254252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT3KVF43XVWPB4OBZRKL74LUUOAIHANCNFSM4OAQOKEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

ckarsan commented 2 years ago

@riderx

I made one with revenuecat sdk in swift and capacitor implementation https://github.com/riderx/capacitor-purchases I’m working on the android part

This looks great, would like to implement...

Couple of questions, Do I need to sign up to revenuecat to use this plugin? Is there any video / tutorial of this being implemented in a react project? Does it work on android aswell?

Cheers!

selected-pixel-jameson commented 2 years ago

@riderx have you reached out to Revenucat to see if they'd be interested in contributing? They are pretty responsive on Twitter.

riderx commented 2 years ago

@ckarsan yes you need to sign up to revenuecat. No video for now, i have done it only in vue it works for android too

riderx commented 2 years ago

@selected-pixel-jameson i reached in github issue there: https://github.com/RevenueCat/cordova-plugin-purchases/issues/114

ckarsan commented 2 years ago

@riderx would it be possible to write a short implementation example in the readme, say to display an example subscription offering for a userid. I have set everything up with app store and revenuecat, but not sure even what to import from the capacitor-purchases module to get up and running (i'm using react without typescript) - thanks, very much appreciated.

riderx commented 2 years ago

@ckarsan you are right i have to make it you have one example in my open source app there : https://github.com/Forgr-ee/Mimesis/blob/main/src/services/iap.ts if that can help

TomDoesb commented 9 months ago

https://github.com/CraigRonald555/capacitor-subscriptions/

I came across this library by @CraigRonald. It supports both Google and StoreKit2, but its not complete. e.g for IOS it could be improved by adding support for SubcriptionStoreView

manish-jhavtech commented 8 months ago

Hi @cossminuu Can you please help me? I am trying to implement in-app-purchase in nuxt.js, capacitor and ionic app but due to bad documentation. I am stuck on how to implement can you please share any resource or your in-app purchase project GitHub repo link for community reference. Thank in advance.

wsamoht commented 8 months ago

I'd recommend using RevenueCat. Their free plan is pretty generous and after that it is only 1% of revenue. They now have an official Capacitor plugin (vs. a Cordova one) - https://www.revenuecat.com/docs/ionic. They are dedicated with in-app purchases and handle all the wiggles associated with it (along with all the other features they offer). Why spend time implementing all that when you can focus on the features of your app itself 😁