-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
also fixed issue with tests for transfers not passing due to account not being managed, per new stripe assertion * tests * renamed Stripe3DSecure to ThreeDSecure on card * fixed tests that needed to be a managed account, per stripe assertion change
- Loading branch information
1 parent
28fd442
commit b9e98e4
Showing
11 changed files
with
188 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using Machine.Specifications; | ||
|
||
namespace Stripe.Tests | ||
{ | ||
public class when_creating_3d_secure | ||
{ | ||
private static StripeToken _token; | ||
private static Stripe3DSecure _3DSecure; | ||
|
||
private Establish context = () => | ||
{ | ||
var tokenOptions = test_data.stripe_token_create_options.Valid(); | ||
tokenOptions.Card.Number = "4000000000003055"; | ||
|
||
_token = new StripeTokenService().Create(tokenOptions); | ||
}; | ||
|
||
Because of = () => | ||
_3DSecure = new Stripe3DSecureService().Create(new Stripe3DSecureCreateOptions | ||
{ | ||
Amount = 1000, | ||
Currency = "usd", | ||
ReturnUrl = "http://3d-secure-needs-no-glasses.com", | ||
CardTokenOrCardId = _token.Id | ||
}); | ||
|
||
It should_have_a_3d_secure_object = () => | ||
_3DSecure.ShouldNotBeNull(); | ||
|
||
It should_have_the_right_amount = () => | ||
_3DSecure.Amount.ShouldEqual(1000); | ||
|
||
It should_have_the_right_currency = () => | ||
_3DSecure.Currency.ShouldEqual("usd"); | ||
|
||
It should_have_a_redirect_url = () => | ||
_3DSecure.RedirectUrl.ShouldContain("http"); | ||
|
||
It should_have_a_card_with_3d_secure_hash = () => | ||
_3DSecure.Card.ThreeDSecure.Keys.ShouldContain("supported"); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Stripe.Tests/3d_secure/when_creating_3d_secure_for_a_customer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Machine.Specifications; | ||
|
||
namespace Stripe.Tests | ||
{ | ||
public class when_creating_3d_secure_for_a_customer | ||
{ | ||
private static StripeCustomer _customer; | ||
private static Stripe3DSecure _3DSecure; | ||
|
||
private Establish context = () => | ||
{ | ||
var customerOptions = test_data.stripe_customer_create_options.ValidCard(); | ||
_customer = new StripeCustomerService().Create(customerOptions); | ||
}; | ||
|
||
Because of = () => | ||
_3DSecure = new Stripe3DSecureService().Create(new Stripe3DSecureCreateOptions | ||
{ | ||
Amount = 1000, | ||
Currency = "usd", | ||
ReturnUrl = "http://3d-secure-needs-no-glasses.com", | ||
CardTokenOrCardId = _customer.DefaultSourceId, | ||
CustomerId = _customer.Id | ||
}); | ||
|
||
It should_have_a_3d_secure_object = () => | ||
_3DSecure.ShouldNotBeNull(); | ||
|
||
It should_have_the_right_amount = () => | ||
_3DSecure.Amount.ShouldEqual(1000); | ||
|
||
It should_have_the_right_currency = () => | ||
_3DSecure.Currency.ShouldEqual("usd"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
namespace Stripe | ||
{ | ||
public class Stripe3DSecure : StripeObject | ||
{ | ||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
[JsonProperty("amount")] | ||
public int Amount { get; set; } | ||
|
||
[JsonProperty("authenticated")] | ||
public bool Authenticated { get; set; } | ||
|
||
[JsonProperty("card")] | ||
public StripeCard Card { get; set; } | ||
|
||
[JsonProperty("created")] | ||
[JsonConverter(typeof(StripeDateTimeConverter))] | ||
public DateTime Created { get; set; } | ||
|
||
[JsonProperty("currency")] | ||
public string Currency { get; set; } | ||
|
||
[JsonProperty("livemode")] | ||
public bool LiveMode { get; set; } | ||
|
||
[JsonProperty("redirect_url")] | ||
public string RedirectUrl { get; set; } | ||
|
||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Stripe/Services/3DSecure/Stripe3DSecureCreateOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Stripe | ||
{ | ||
public class Stripe3DSecureCreateOptions | ||
{ | ||
[JsonProperty("amount")] | ||
public int Amount { get; set; } | ||
|
||
[JsonProperty("currency")] | ||
public string Currency { get; set; } | ||
|
||
[JsonProperty("return_url")] | ||
public string ReturnUrl { get; set; } | ||
|
||
/// <summary> | ||
/// If you pass a card id, you must also pass the customer id | ||
/// </summary> | ||
[JsonProperty("card")] | ||
public string CardTokenOrCardId { get; set; } | ||
|
||
[JsonProperty("customer")] | ||
public string CustomerId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Stripe | ||
{ | ||
public class Stripe3DSecureService : StripeBasicService<Stripe3DSecure> | ||
{ | ||
public Stripe3DSecureService(string apiKey = null) : base(apiKey) { } | ||
|
||
// Sync | ||
public virtual Stripe3DSecure Create(Stripe3DSecureCreateOptions createOptions, StripeRequestOptions requestOptions = null) | ||
{ | ||
return Post($"{Urls.BaseUrl}/3d_secure", requestOptions, createOptions); | ||
} | ||
|
||
|
||
|
||
|
||
// Async | ||
public virtual Task<Stripe3DSecure> CreateAsync(Stripe3DSecureCreateOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return PostAsync($"{Urls.BaseUrl}/3d_secure", requestOptions, cancellationToken, createOptions); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters