Skip to content

Commit

Permalink
create token card
Browse files Browse the repository at this point in the history
  • Loading branch information
o0Ignition0o committed Nov 19, 2020
1 parent 1a17988 commit 47bacf4
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion src/resources/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::config::{Client, Response};
use crate::ids::{CustomerId, TokenId};
use crate::params::{Expand, Metadata, Object, Timestamp};
use crate::resources::{
Address, BankAccount, BusinessType, Card, CompanyParams, Dob, PersonParams, TokenType,
Address, BankAccount, BusinessType, Card, CompanyParams, Currency, Dob, PersonParams, TokenType,
};
use serde_derive::{Deserialize, Serialize};

Expand Down Expand Up @@ -76,6 +76,10 @@ pub struct CreateToken<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub account: Option<CreateTokenAccount>,

/// Information for the account this token will represent.
#[serde(skip_serializing_if = "Option::is_none")]
pub card: Option<CreateTokenCard>,

/// The customer (owned by the application's account) for which to create a token.
///
/// This can be used only with an [OAuth access token](https://stripe.com/docs/connect/standard-accounts) or [Stripe-Account header](https://stripe.com/docs/connect/authentication).
Expand All @@ -100,6 +104,7 @@ impl<'a> CreateToken<'a> {
pub fn new() -> Self {
CreateToken {
account: Default::default(),
card: Default::default(),
customer: Default::default(),
expand: Default::default(),
person: Default::default(),
Expand All @@ -123,6 +128,58 @@ pub struct CreateTokenAccount {
pub tos_shown_and_accepted: Option<bool>,
}

#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct CreateTokenCard {
/// City/District/Suburb/Town/Village.
#[serde(skip_serializing_if = "Option::is_none")]
pub address_city: Option<String>,

/// Billing address country, if provided.
#[serde(skip_serializing_if = "Option::is_none")]
pub address_country: Option<String>,

/// Address line 1 (Street address/PO Box/Company name).
#[serde(skip_serializing_if = "Option::is_none")]
pub address_line1: Option<String>,

/// Address line 2 (Apartment/Suite/Unit/Building).
#[serde(skip_serializing_if = "Option::is_none")]
pub address_line2: Option<String>,

/// State/County/Province/Region.
#[serde(skip_serializing_if = "Option::is_none")]
pub address_state: Option<String>,

/// ZIP or postal code.
#[serde(skip_serializing_if = "Option::is_none")]
pub address_zip: Option<String>,

/// Required in order to add the card to an account;
/// in all other cases, this parameter is not used.
/// When added to an account, the card (which must be a debit card) can be used
/// as a transfer destination for funds in this currency.
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<Currency>,

/// Card security code. Highly recommended to always include this value,
/// but it's required only for accounts based in European countries.
#[serde(skip_serializing_if = "Option::is_none")]
pub cvc: Option<String>,

/// Two-digit number representing the card's expiration month.
pub exp_month: i64,

/// Four-digit number representing the card's expiration year.
pub exp_year: i64,

/// Cardholder's full name.
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,

/// The card number, as a string without any separators.
pub number: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateTokenPerson {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit 47bacf4

Please sign in to comment.