#park-ios-paymentsheet
1 messages · Page 1 of 1 (latest)
I have a Rust server that uses the async-stripe crate that deals with the server-side stuff.
so client-side you get a PaymentIntent's client_secret and confirm the payment right?
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;
}
};
Hi @wraith jetty I'm taking over
Hi @solar narwhal
Do you see a error or something after running presentPaymentSheet() ?
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?
I can only support you through chat.
Ok no problem.
Did you pass valid customerEphemeralKeySecret, paymentIntentClientSecret, customerId to initPaymentSheet() ?
Yes
Is there a way to extract/retrieve the pmid from the sheet to save on to my customer?
Let's solve the paymentSheet problem first. Can you share with me the PaymentIntent ID?
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.
I've tried both Automatic and Manual leading to same result
And you got the unexpected state error because you were trying to change the amount when the status is of requires_action https://dashboard.stripe.com/test/logs/req_x9JyXZTyB2Sh1D
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
And you share with me the ID of the capture_method=automatic PaymentIntent?
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
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.
What can lead to requires_action status on an intent?
You can see the error details in log https://dashboard.stripe.com/test/logs/req_h5ee98WrkeVjfT
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I dont have dashboard access
https://stripe.com/docs/payments/intents This is the lifecycle of PaymentIntent
Oh, then you need to talk to your admin and get dashboard access.
So the paymentSheet should be taking care of setting the right pm/pmid without me manually doing it server-side?
Yes, you don't need to. Once the payment is succeeded. Stripe will automatically attach the payment_method to the customer.
pi_3M0Ek0DdMfkWbtGZ37JjXwxl
I removed the updating the amount code.
and got the same error
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
That's because you attempt to confirm an already succeeded PaymentIntent.
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?
It depends whether you set confirmation_method=manual when creating a PaymentIntent
If I do automatic, then I don't.
If I use Manual, then I do, right?
Yes you are right, and you can confirm it from either frontend or backend.
Also, is there a way to change the language of the apyment sheet to JP?
Yes, the PaymentSheet has built-in i18n. If your device's locale is set to JP, the PaymentSheet will be presented in JP
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?
For iOS, The PaymentSheet will display in a language according to the device's language settings
Is there a default billing address for ApplePay on the payment sheet I can use for test?
You can set up a billing address in the Apple Pay paymentsheet.