From 51e34d6fec2238d27e937f361d9e0b60f1bc564c Mon Sep 17 00:00:00 2001 From: Sean Pianka Date: Fri, 26 Apr 2024 13:36:23 -0400 Subject: [PATCH 1/3] feat(setup_intent): add mandate_data for confirm Signed-off-by: Sean Pianka --- src/resources/setup_intent_ext.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/resources/setup_intent_ext.rs b/src/resources/setup_intent_ext.rs index 7fdf31ef4..61e8fe8b8 100644 --- a/src/resources/setup_intent_ext.rs +++ b/src/resources/setup_intent_ext.rs @@ -2,26 +2,40 @@ use serde::Serialize; use crate::client::{Client, Response}; use crate::resources::SetupIntent; -use crate::{SetupIntentCancellationReason, SetupIntentId}; +use crate::{PaymentMethodId, SetupIntentCancellationReason, SetupIntentId}; /// The set of parameters that can be used when confirming a setup_intent object. /// /// For more details see #[derive(Clone, Debug, Serialize)] pub struct ConfirmSetupIntent { - /// The client secret if on the client side + /// ID of the payment method (a PaymentMethod, Card, or saved Source object) to attach to this SetupIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub client_secret: Option, + pub payment_method: Option, - /// Specifies which payment method + /// This hash contains details about the mandate to create #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method: Option, + pub mandate_data: Option, + + /// When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_data: Option, + + /// Payment method-specific configuration for this SetupIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_options: Option, - // Mandate data and payment method options not implemented. If you want - // something better, create an issue and lets fix /// The URL to redirect your customer back to after they authenticate on the payment method’s app or site. #[serde(skip_serializing_if = "Option::is_none")] pub return_url: Option, + + /// Set to `true` when confirming server-side and using Stripe.js, iOS, or Android client-side SDKs to handle the next actions. + pub use_stripe_sdk: bool, +} + +#[derive(Clone, Debug, Default, Serialize)] +pub struct MandateData { + pub customer_acceptance: crate::CustomerAcceptance, } /// The set of parameters that can be used when canceling a setup_intent object. From 15b3663336561ccf55d78dc66668d28627b4d59b Mon Sep 17 00:00:00 2001 From: Sean Pianka Date: Fri, 26 Apr 2024 15:14:41 -0400 Subject: [PATCH 2/3] feat(setup_intent): verify microdeposits flow Signed-off-by: Sean Pianka --- src/resources/setup_intent_ext.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/resources/setup_intent_ext.rs b/src/resources/setup_intent_ext.rs index 61e8fe8b8..0a4be0d76 100644 --- a/src/resources/setup_intent_ext.rs +++ b/src/resources/setup_intent_ext.rs @@ -1,6 +1,7 @@ use serde::Serialize; use crate::client::{Client, Response}; +use crate::params::Expand; use crate::resources::SetupIntent; use crate::{PaymentMethodId, SetupIntentCancellationReason, SetupIntentId}; @@ -47,6 +48,24 @@ pub struct CancelSetupIntent { pub cancellation_reason: Option, } +/// Verifies microdeposits on a SetupIntent object. +/// +/// For more details see +#[derive(Clone, Debug, Default, Serialize)] +pub struct VerifyMicrodeposits<'a> { + /// Two positive integers, in cents, equal to the values of the microdeposits sent to the bank account. + #[serde(skip_serializing_if = "Option::is_none")] + pub amounts: Option>, + + /// A six-character code starting with SM present in the microdeposit sent to the bank account. + #[serde(skip_serializing_if = "Option::is_none")] + pub descriptor_code: Option<&'a str>, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], +} + impl SetupIntent { pub fn confirm( client: &Client, @@ -56,6 +75,14 @@ impl SetupIntent { client.post_form(&format!("/setup_intents/{}/confirm", setup_id), ¶ms) } + pub fn verify_micro_deposits( + client: &Client, + setup_id: &SetupIntentId, + params: VerifyMicrodeposits, + ) -> Response { + client.post_form(&format!("/setup_intents/{}/verify_microdeposits", setup_id), ¶ms) + } + /// A SetupIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. /// /// For more details see . From 362659e3e7ace2706fae172e7936efdc5c17929d Mon Sep 17 00:00:00 2001 From: Sean Pianka Date: Fri, 26 Apr 2024 15:43:50 -0400 Subject: [PATCH 3/3] fix(customer-ext,PM query): type field is optional Signed-off-by: Sean Pianka --- src/resources/customer_ext.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/resources/customer_ext.rs b/src/resources/customer_ext.rs index 5e1b03215..efbc5f2d5 100644 --- a/src/resources/customer_ext.rs +++ b/src/resources/customer_ext.rs @@ -9,39 +9,40 @@ use crate::resources::{ #[derive(Clone, Debug, Serialize, Eq, PartialEq)] pub struct CustomerPaymentMethodRetrieval<'a> { - ///A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. + /// A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. ///For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, ///your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. #[serde(skip_serializing_if = "Option::is_none")] pub ending_before: Option, - ///Specifies which fields in the response should be expanded. + /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Expand::is_empty")] pub expand: &'a [&'a str], - ///A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. #[serde(skip_serializing_if = "Option::is_none")] pub limit: Option, - ///A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. + /// A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. ///For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, ///your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option, - ///A required filter on the list, based on the object `type` field. + /// An optional filter on the list, based on the object type field. Without the filter, the list includes all current and future payment method types. If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. #[serde(rename = "type")] - pub type_: CustomerPaymentMethodRetrievalType, + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option, } impl<'a> CustomerPaymentMethodRetrieval<'a> { - pub fn new(the_type: CustomerPaymentMethodRetrievalType) -> Self { + pub fn new() -> Self { CustomerPaymentMethodRetrieval { ending_before: None, expand: &[], limit: None, starting_after: None, - type_: the_type, + type_: None, } } }