Skip to content

Commit

Permalink
Merge pull request #547 from seanpianka/master
Browse files Browse the repository at this point in the history
feat(setup_intent): add mandate_data for confirm
  • Loading branch information
arlyon committed Apr 30, 2024
2 parents a6dd321 + 362659e commit 56637bc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
17 changes: 9 additions & 8 deletions src/resources/customer_ext.rs
Expand Up @@ -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<String>,

///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<i32>,

///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<String>,

///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<CustomerPaymentMethodRetrievalType>,
}

impl<'a> CustomerPaymentMethodRetrieval<'a> {
pub fn new(the_type: CustomerPaymentMethodRetrievalType) -> Self {
pub fn new() -> Self {

Check failure on line 39 in src/resources/customer_ext.rs

View workflow job for this annotation

GitHub Actions / clippy (tokio-hyper)

you should consider adding a `Default` implementation for `CustomerPaymentMethodRetrieval<'a>`

Check failure on line 39 in src/resources/customer_ext.rs

View workflow job for this annotation

GitHub Actions / clippy (blocking)

you should consider adding a `Default` implementation for `CustomerPaymentMethodRetrieval<'a>`

Check failure on line 39 in src/resources/customer_ext.rs

View workflow job for this annotation

GitHub Actions / clippy (blocking-rustls)

you should consider adding a `Default` implementation for `CustomerPaymentMethodRetrieval<'a>`
CustomerPaymentMethodRetrieval {
ending_before: None,
expand: &[],
limit: None,
starting_after: None,
type_: the_type,
type_: None,
}
}
}
Expand Down
55 changes: 48 additions & 7 deletions src/resources/setup_intent_ext.rs
@@ -1,27 +1,42 @@
use serde::Serialize;

use crate::client::{Client, Response};
use crate::params::Expand;
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 <https://stripe.com/docs/api/setup_intents/confirm>
#[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<String>,
pub payment_method: Option<PaymentMethodId>,

/// Specifies which payment method
/// This hash contains details about the mandate to create
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method: Option<String>,
pub mandate_data: Option<MandateData>,

/// 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<crate::UpdatePaymentIntentPaymentMethodData>,

/// Payment method-specific configuration for this SetupIntent.
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method_options: Option<crate::UpdatePaymentIntentPaymentMethodOptions>,

// 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<String>,

/// 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.
Expand All @@ -33,6 +48,24 @@ pub struct CancelSetupIntent {
pub cancellation_reason: Option<SetupIntentCancellationReason>,
}

/// Verifies microdeposits on a SetupIntent object.
///
/// For more details see <https://stripe.com/docs/api/setup_intents/verify_microdeposits>
#[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<Vec<i64>>,

/// 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,
Expand All @@ -43,6 +76,14 @@ impl SetupIntent {
client.post_form(&format!("/setup_intents/{}/confirm", setup_id), &params)
}

pub fn verify_micro_deposits(
client: &Client,
setup_id: &SetupIntentId,
params: VerifyMicrodeposits,
) -> Response<SetupIntent> {
client.post_form(&format!("/setup_intents/{}/verify_microdeposits", setup_id), &params)

Check failure on line 84 in src/resources/setup_intent_ext.rs

View workflow job for this annotation

GitHub Actions / clippy (blocking)

the borrowed expression implements the required traits

Check failure on line 84 in src/resources/setup_intent_ext.rs

View workflow job for this annotation

GitHub Actions / clippy (blocking-rustls)

the borrowed expression implements the required traits
}

/// 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 <https://stripe.com/docs/api/setup_intents/cancel>.
Expand Down

0 comments on commit 56637bc

Please sign in to comment.