Skip to content

Commit

Permalink
feat(setup_intent): verify microdeposits flow
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Pianka <pianka@eml.cc>
  • Loading branch information
seanpianka committed Apr 26, 2024
1 parent 51e34d6 commit 15b3663
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/resources/setup_intent_ext.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -47,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 @@ -56,6 +75,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)
}

/// 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 15b3663

Please sign in to comment.