#park-ios-paymentsheet

1 messages · Page 1 of 1 (latest)

frigid steepleBOT
zinc jetty
#

Which exact doc are you following?

#

park-ios-paymentsheet

wraith jetty
#

I have a Rust server that uses the async-stripe crate that deals with the server-side stuff.

zinc jetty
#

so client-side you get a PaymentIntent's client_secret and confirm the payment right?

wraith jetty
#
  const initializePaymentSheet = async () => {
    const {
      customerEphemeralKeySecret,
      paymentIntentClientSecret,
      customerId,
    } = await fetchPaymentSheetParams();

    const { error } = await initPaymentSheet({
      customerId,
      customerEphemeralKeySecret,
      paymentIntentClientSecret,
      setupIntentClientSecret: "",
      merchantDisplayName: "OniGO",
      allowsDelayedPaymentMethods: true,
      defaultBillingDetails: {
        address: {
          country: "JP",
        },
      },
    });
    if (error) {
      notify({ message: "Could not initialize payment sheet" }); // then what?
      return;
    }
  };

solar narwhal
#

Hi @wraith jetty I'm taking over

wraith jetty
#

Hi @solar narwhal

solar narwhal
#

Do you see a error or something after running presentPaymentSheet() ?

wraith jetty
#

I get an error when calling my checkout enpoint (when I press buy after the paymentSheet is open and the method is selected). PaymentIntentUnexpectedState

Which from what I understtod going around is probably due to the intent not having a payment method

#

Are you guys allowed to do live, screen share support?

solar narwhal
#

I can only support you through chat.

wraith jetty
#

Ok no problem.

solar narwhal
#

Did you pass valid customerEphemeralKeySecret, paymentIntentClientSecret, customerId to initPaymentSheet() ?

wraith jetty
#

Yes

#

Is there a way to extract/retrieve the pmid from the sheet to save on to my customer?

solar narwhal
#

Let's solve the paymentSheet problem first. Can you share with me the PaymentIntent ID?

wraith jetty
#

Sure gimme a min.

#

pi_3M0ETMDdMfkWbtGZ0xVBKEYI

#

sorry for the delay

solar narwhal
#

No problem at all, let me take a look.

#

OK. So you set capture_method=manual when creating a PaymentIntent, that means you need to manually capture the PaymentIntent after confirming it.

wraith jetty
#

I've tried both Automatic and Manual leading to same result

solar narwhal
#

And you share with me the ID of the capture_method=automatic PaymentIntent?

wraith jetty
#

That one was manual

#

I can fire an automatic one.

#

    async fn create_payment_intent(
        &self,
        customer_id: String,
        total: f64,
        order_id: String,
        payment_method_id: Option<String>,
    ) -> Result<PaymentIntent, Error> {
        let mut create_intent = CreatePaymentIntent::new(total as i64, Currency::JPY);
        let mut meta: HashMap<String, String> = HashMap::new();
        let pmid = match payment_method_id.as_ref() {
            Some(id) => Some(convert_payment_method_id(id)?),
            None => None,
        };
        let customer = find_or_create_customer(customer_id, &self.client, pmid.as_ref()).await?;
        meta.insert("order_id".to_string(), order_id.to_string());
        create_intent.customer = Some(customer.id.clone());
        create_intent.payment_method_types = Some(vec!["card".to_string()]);
        create_intent.capture_method = Some(PaymentIntentCaptureMethod::Automatic);
        create_intent.confirmation_method = Some(PaymentIntentConfirmationMethod::Automatic);
        create_intent.metadata = Some(meta);
        create_intent.setup_future_usage = Some(PaymentIntentSetupFutureUsage::OffSession);

        if let Some(id) = payment_method_id {
            create_intent.payment_method = Some(
                PaymentMethodId::from_str(&id)
                    .map_err(|parse_error| Error::LogicError(format!("{:?}", parse_error)))?,
            );
        }

        let pi = PaymentIntent::create(&self.client, create_intent)
            .await
            .map_err(Error::from)?;
        Ok(pi)
    }

#

in case that helps

#

[routes/client/src/checkout.rs:60] format!("Payment Intent ID: {}", & payment_intent_id) = "Payment Intent ID: pi_3M0Ed0DdMfkWbtGZ2v2tuv25"

#

This one is automatic

solar narwhal
#

I mean the error happens because you attempts to change the PayementIntent's amount when it's in requires_action status, it's not related to PaymentSheet.

wraith jetty
#

What can lead to requires_action status on an intent?

solar narwhal
wraith jetty
#

I dont have dashboard access

solar narwhal
#

Oh, then you need to talk to your admin and get dashboard access.

wraith jetty
#

So the paymentSheet should be taking care of setting the right pm/pmid without me manually doing it server-side?

solar narwhal
#

Yes, you don't need to. Once the payment is succeeded. Stripe will automatically attach the payment_method to the customer.

wraith jetty
#

pi_3M0Ek0DdMfkWbtGZ37JjXwxl

#

I removed the updating the amount code.

#

and got the same error

solar narwhal
#

That's because you attempt to confirm an already succeeded PaymentIntent.

wraith jetty
#

I see.

#

Damn

#

So we have a single endpoint that handles checkout for both webapp and native. The webapp doesnt use payment sheet.

#

So I'll try to find a way to reconcile

#

So with paymentSheet, I don't need to confirm manually server side?

solar narwhal
#

It depends whether you set confirmation_method=manual when creating a PaymentIntent

wraith jetty
#

If I do automatic, then I don't.
If I use Manual, then I do, right?

solar narwhal
#

Yes you are right, and you can confirm it from either frontend or backend.

wraith jetty
#

Also, is there a way to change the language of the apyment sheet to JP?

solar narwhal
#

Yes, the PaymentSheet has built-in i18n. If your device's locale is set to JP, the PaymentSheet will be presented in JP

wraith jetty
#

I was able to make a succesful payment by remove update amount and manual confirm

#

my app's locale?

#

can it be given as a parameter on init?

solar narwhal
#

For iOS, The PaymentSheet will display in a language according to the device's language settings

wraith jetty
#

Is there a default billing address for ApplePay on the payment sheet I can use for test?

solar narwhal
#

You can set up a billing address in the Apple Pay paymentsheet.