Skip to content
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

Return to merchant button not working #96

Closed
raghuchaharsqm opened this issue Aug 31, 2021 · 5 comments
Closed

Return to merchant button not working #96

raghuchaharsqm opened this issue Aug 31, 2021 · 5 comments

Comments

@raghuchaharsqm
Copy link

raghuchaharsqm commented Aug 31, 2021

I am trying to integrate payment flow using stripe and capacitor on frontend and stripe with NodeJs on backend, Following steps provided in this repo but stucked on return to merchant button after createPaymentFlow method.

Backend(NodeJs):

const createPaymentIntent = async (args) => {
  const { currency, amount, customerId } = args;
  const result = await stripe.paymentIntents.create({
    amount,
    currency: CURRENCY,
    customer: customerId
  });
  return result;
};

const createEphermalKey = async (args) => {
  const { customerId } = args || {};
  const ephemeralKey = await stripe.ephemeralKeys.create({ customer: customerId }, { apiVersion: "2020-08-27" });
  return ephemeralKey;
};

const createCustomer = async (args) => {
  const { email, metadata, name, paymentMethod } = args || {};
  const result = await stripe.customers.create({
    email,
    metadata,
    name

    // payment_method: paymentMethod
  });
  return result;
};

Fontend(Ionic-react/capacitor) -

const initiatePayment = async () => {
    var stripObj: any = await API.graphql(
      graphqlOperation(createStripeIntent, { reservationId: "121212121", paymentMethod: "card" })
    );
    try {
      const {
        clientSecret: paymentIntent,
        ephemeralKey,
        customerId: customer
      } = stripObj && stripObj.data && stripObj.data.createStripeIntent;
      let option: CreatePaymentSheetOption = {
        customerId: customer,
        paymentIntentClientSecret: paymentIntent,
        customerEphemeralKeySecret: ephemeralKey,
        style: "alwaysDark"
      };
      const result1 = await Stripe.createPaymentSheet(option);
      console.log("result1 >>> ", result1);

      const result = await Stripe.presentPaymentSheet();
      console.log("result >>> ", result);
    } catch (error) {
      console.error("4 : ", error);
    }
  };

When I am initiating payment, I am getting add your payment information page.
After adding card, I am getting a button return to merchant in stripe web view, but that button is not working, neither the payment is successful.
Is there any step missing in docs which I had to consider, please help me out in this.

@rdlabo
Copy link
Member

rdlabo commented Sep 2, 2021

@raghuchaharsqm Please try demo app. : https://github.com/capacitor-community/stripe/tree/master/demo/angular
Also check the console for any errors.

@raghuchaharsqm
Copy link
Author

raghuchaharsqm commented Sep 7, 2021

@raghuchaharsqm Please try demo app. : https://github.com/capacitor-community/stripe/tree/master/demo/angular
Also check the console for any errors.

I got the error, actually there were few things missing in docs i.e we have to save address, description and name while creating customer while paying in outside currency from India (eg. USD) which is not mentioned in docs and is explicitly mentioned on this doc https://stripe.com/docs/india-accept-international-payments.
I guess stripe needs to update the docs for this specific case. Later I tried payments in INR which worked perfectly. Also, return to merchant button would start work after deep linking as mentioned in docs but the payment was successful after using INR or saving address, description and name for other currencies.

@rdlabo
Copy link
Member

rdlabo commented Sep 7, 2021

@raghuchaharsqm Thanks for good issues and resolve method.
This plugin is wrapper for using stripe, so can't cover in this case in readme. But if anyone get same trouble, may support by this issues! And if you have a time, please conntact stripe for recommend update to document of stripe.
Thanks.

@rdlabo
Copy link
Member

rdlabo commented Sep 7, 2021

It looks to resolved issue, so I will close this issue.

@rdlabo rdlabo closed this as completed Sep 7, 2021
@rdlabo
Copy link
Member

rdlabo commented Jan 19, 2022

@raghuchaharsqm Did you adapt this plugin for production? If yes, please tell us what app. Please help us to develop this plugin in 2022.
#145
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants