New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stripe with Google pay and Apple pay #1
Comments
I haven't had a chance to document the plugin yet. You can take a look at the declaration file here: Quick example: import { Plugins } from '@capacitor/core';
const { StripePlugin } = Plugins;
// apple pay
// Option A: Charges
StripePlugin.payWithApplePay({
merchantId: 'merchant.test.com', // apple merchant id
country: 'CA', // 2 letter country code
currency: 'CAD', // currency code
items: [
// list your items here so the user knows what they're paying for
// tax + total are optional
{
label: 'Blue Tshirt',
amount: 50,
},
{
label: 'Tax',
amount: 10,
},
{
label: 'Total',
amount: 60,
}
]
})
.then((res) => {
// send token to API and handle charge (res.token)
// then call finalizeApplePayTransaction with the result to dismiss the UI modal
StripePlugin.finalizeApplePayTransaction({ success: true })
})
.catch(err => {
// something went wrong
// user cancelled, integration issue, timeout ..etc
});
// Option #2: Payment Intents
StripePlugin.confirmPaymentIntent({
clientSecret: 'secret from API',
applePayOptions: { /* same as above */ },
})
.then(res => {
// dismiss the apple pay modal in the UI
// check with your server that everything is fine, depending on your PaymentIntent implementation
StripePlugin.finalizeApplePayTransaction({ success: true })
})
.catch(err => {
StripePlugin.finalizeApplePayTransaction({ success: false })
})
// google pay
StripePlugin.startGooglePayTransaction({
// options not available in definitions file
// can find some of them here: https://github.com/zyra/capacitor-stripe/blob/master/packages/plugin/android/src/main/java/ca/zyra/capacitor/stripe/StripePlugin.kt#L407-L483
})
.then(res => {
StripePlugin.confirmPaymentIntent({ fromGooglePay: true });
})
.catch(err => {
}); |
Hello @ihadeed Android build issue
|
Regarding the Android build: To use Android X now you can do one of the following: Install capacitor-android from that PR: there are some instructions here that I haven't tested but they should work. or, here is what I did:
|
That iOS error must be coming from this function: https://github.com/zyra/capacitor-stripe/blob/master/packages/plugin/ios/Plugin/Helper.swift#L172 It's possible that I did not implement the custom errors properly which is why you're seeing that generic error message. I noticed I made a mistake in my example. I wrote Check the following:
|
Hey @ihadeed
After capacitor android installation from PR I got this error message when i call function from this plugin on web and mobile (setPublishableKey('KEY'); startGooglePayTransaction(); payWithApplePay(); etc.) Error: Uncaught (in promise): StripePlugin does not have web implementation. p.s. I stuck with all of this, i need more info for set up this plugin and i need to implement all stripe payments like a credit card, gPay and iPay very soon. |
@filipnaumoski thanks for the feedback Looking into it now as I'm integrating it into an app. Will publish any necessary fixes soon. |
@ihadeed I managed to resolve the issue with GooglePay. The issue was in MainActivity.java - to be more specific, it was missing add(StripePlugin.class) in the bridge initialization function. Additionally, there was an issue with Stripe API POST request in web.js, therefore I made some modification in CallStripeAPI function:
Please, let me know if you have some update in regards to ApplePay. I am still working on this, however I haven't manage to find solution yet. |
Thanks @filipnaumoski , I implemented your fix for the web and it seems to work well now. As for iOS, I just ran a test and managed to successfully use Apple Pay. A few things to double check:
await Capacitor.Plugins.StripePlugin.payWithApplePay({ applePayOptions: { ... } });
|
Releasing a new version now with the recent fixes/updates. Breaking changes:
Stripe.payWithGooglePay({ googlePayOptions: { ... } }); Probably will get rid of |
Pls, add to "installation" that Stripe.setPublishableKey call need before plugin usage |
@san4ezgig will do as soon as I get a chance to work on the docs. For now if it requires the publishable key it should throw a console error message. |
Hi! I'm using the version 0.4.0 and I want to pay with stripe in Applepay and Googlepay.
What I'm doing wrong? The error is: "No such Payment_intent" |
Please, can you give us a working example for test it? |
@josebyte 0.4.0 version |
Thank you @san4ezgig :) Thanks in advance!! |
DId you manage to get Apple Pay working? I have the same error as you: "Unable to parse apple pay options: The operation couldn't be completed. (CapacitorStripe.StripePluginError error 0.)" |
Seems like some docs are getting added |
@ihadeed I was able to add Google pay to my app, but I'm not sure I did it right. I used my server-side to initialize a payment_intent for the clientSecret.. Is that right? After using payWithGooglePay, it returns nothing, and I go straight to confirmPaymentIntent, but I need to interact with the paymentMethod before I confirm. Edit: actually nevermind I don't know what I was thinking. Apple wouldn't let me set up an app subscription using the official Apple pay API. I need to use a webview and web APIs. |
@ihadeed I am having below error, when i try to do paywithGooglePay in my app. let me summarized the steps to reproduce the issue. When I invoke payWithGooglePay, then action sheet is opened, followed up with the error alert box pops up.
Please advice, what this means? And also please advice, how to do payment with google pay and apple pay? |
@ihadeed I have found out the reason for the above error. Please see below
and please advice, why UNKNOWN is not valid enum and Why AMERICAN_EXPRESS not a valid enum. But these values are present in enum. If i put visa or master card in allowed card networks payment sheet opens with out any alert box |
@ihadeed Please respond for my queries, I am having lot of issues with this plugin. I need you clarification and guidance for this. When I do confirm payment Intent with googlePayOptions, I got below error. I create payment intent from server. and then passing my client secret to stripe plugin cofirm payment intent. But I got the error. Please see the below code and advice.
I can't able to use payWithGooglePay also, because it return void rather than token response. Please advice. |
Hi, |
See pull request #9 for payWithGooglePay fix |
@bolekro I got this error when I had forgotten to run npx cap sync ios. Once I did that I moved on to the next error. |
@ihadeed Thanks for the example. It worked well for me. Is there a way to use this for a Stripe Connect account? |
How can I integrate Google pay and Apple pay using this capacitor plugin in ionic 4?
I don't see any documentation for this.
Thanks!
The text was updated successfully, but these errors were encountered: