Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle bank account token deserialization #1176

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/Stripe.Tests.XUnit/tokens/creating_a_bank_account_token.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using FluentAssertions;
using Stripe.Tests.Xunit;
using Xunit;

namespace Stripe.Tests.Xunit
{
public class creating_a_bank_account_token
{
private StripeToken Token { get; set; }

public creating_a_bank_account_token()
{
Token = new StripeTokenService(Cache.ApiKey).CreateAsync(
new StripeTokenCreateOptions
{
BankAccount = new BankAccountOptions
{
AccountNumber = "000123456789",
Country = "US",
Currency = "USD",
RoutingNumber = "110000000",
}
}
).Result;
}

[Fact]
public void not_null()
{
Token.Should().NotBeNull();
}

[Fact]
public void has_relevant_properties_set()
{
Token.Id.Should().NotBeNull();
Token.StripeBankAccount.Id.Should().NotBeNull();
Token.StripeBankAccount.Last4.Should().Be("6789");
Token.StripeBankAccount.RoutingNumber.Should().Be("110000000");
}
}
}
29 changes: 2 additions & 27 deletions src/Stripe.net/Entities/StripeToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,8 @@ public class StripeToken : StripeEntityWithId
[JsonProperty("object")]
public string Object { get; set; }

// TODO: use a single property to map bank_account to a StripeBankAccount object
[JsonProperty("bank_account[id]")]
public string BankAccountId { get; set; }

[JsonProperty("bank_account[object]")]
public string BankAccountObject { get; set; }

[JsonProperty("bank_account[country]")]
public string BankAccountCountry { get; set; }

[JsonProperty("bank_account[currency]")]
public string BankAccountCurrency { get; set; }

[JsonProperty("bank_account[last4]")]
public string BankAccountLast4 { get; set; }

[JsonProperty("bank_account[status]")]
public string BankAccountStatus { get; set; }

[JsonProperty("bank_account[bank_name]")]
public string BankAccountName { get; set; }

[JsonProperty("bank_account[fingerprint]")]
public string BankAccountFingerprint { get; set; }

[JsonProperty("bank_account[routing_number]")]
public string BankAccountRoutingNumber { get; set; }
[JsonProperty("bank_account")]
public StripeBankAccount StripeBankAccount { get; set; }

[JsonProperty("card")]
public StripeCard StripeCard { get; set; }
Expand Down