You've already forked AstralRinth
forked from didirus/AstralRinth
Only skip attaching payment method when using ctoken (#4460)
This commit is contained in:
committed by
GitHub
parent
4d11dc821b
commit
9315af9b20
@@ -214,6 +214,8 @@ pub async fn create_or_update_payment_intent(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let mut intent_uses_confirmation_token = false;
|
||||||
|
|
||||||
let payment_method = match &payment_session {
|
let payment_method = match &payment_session {
|
||||||
PaymentSession::Interactive {
|
PaymentSession::Interactive {
|
||||||
payment_request_type: PaymentRequestType::PaymentMethod { id },
|
payment_request_type: PaymentRequestType::PaymentMethod { id },
|
||||||
@@ -232,6 +234,8 @@ pub async fn create_or_update_payment_intent(
|
|||||||
payment_request_type:
|
payment_request_type:
|
||||||
PaymentRequestType::ConfirmationToken { token },
|
PaymentRequestType::ConfirmationToken { token },
|
||||||
} => {
|
} => {
|
||||||
|
intent_uses_confirmation_token = true;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct ConfirmationToken {
|
struct ConfirmationToken {
|
||||||
payment_method_preview: Option<PaymentMethod>,
|
payment_method_preview: Option<PaymentMethod>,
|
||||||
@@ -544,10 +548,7 @@ pub async fn create_or_update_payment_intent(
|
|||||||
//
|
//
|
||||||
// The PaymentIntent will be confirmed using the confirmation token
|
// The PaymentIntent will be confirmed using the confirmation token
|
||||||
// by the client.
|
// by the client.
|
||||||
if let PaymentSession::Interactive {
|
if !intent_uses_confirmation_token {
|
||||||
payment_request_type: PaymentRequestType::PaymentMethod { .. },
|
|
||||||
} = &payment_session
|
|
||||||
{
|
|
||||||
update_payment_intent.payment_method =
|
update_payment_intent.payment_method =
|
||||||
Some(payment_method.id.clone());
|
Some(payment_method.id.clone());
|
||||||
}
|
}
|
||||||
@@ -575,10 +576,7 @@ pub async fn create_or_update_payment_intent(
|
|||||||
intent.customer = Some(customer_id);
|
intent.customer = Some(customer_id);
|
||||||
intent.metadata = Some(metadata);
|
intent.metadata = Some(metadata);
|
||||||
intent.receipt_email = user.email.as_deref();
|
intent.receipt_email = user.email.as_deref();
|
||||||
if let PaymentSession::Interactive {
|
if !intent_uses_confirmation_token {
|
||||||
payment_request_type: PaymentRequestType::PaymentMethod { .. },
|
|
||||||
} = &payment_session
|
|
||||||
{
|
|
||||||
intent.payment_method = Some(payment_method.id.clone());
|
intent.payment_method = Some(payment_method.id.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user