Billing fixes (#4422)

* Only update the PaymentMethod ID if not using placeholder ID

* comment

* Create Anrok transactions for all charges

* Fix comment

* Prefer using payment method's address rather than customer address

* chore: query cache, clippy, fmt
This commit is contained in:
François-Xavier Talbot
2025-09-26 16:39:47 +01:00
committed by GitHub
parent d43451e398
commit 14af3d0763
4 changed files with 91 additions and 42 deletions

View File

@@ -530,15 +530,28 @@ pub async fn create_or_update_payment_intent(
}
if let Some(payment_intent_id) = existing_payment_intent {
let update_payment_intent = stripe::UpdatePaymentIntent {
let mut update_payment_intent = stripe::UpdatePaymentIntent {
amount: Some(charge_data.amount + tax_amount),
currency: Some(inferred_stripe_currency),
customer: Some(customer_id),
metadata: Some(metadata),
payment_method: Some(payment_method.id.clone()),
..Default::default()
};
// If the payment request type was done through a confirmation token,
// the payment method ID is an invalid placeholder so we don't want
// to use it.
//
// The PaymentIntent will be confirmed using the confirmation token
// by the client.
if let PaymentSession::Interactive {
payment_request_type: PaymentRequestType::PaymentMethod { .. },
} = &payment_session
{
update_payment_intent.payment_method =
Some(payment_method.id.clone());
}
stripe::PaymentIntent::update(
stripe_client,
&payment_intent_id,