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

Allow setting three_d_secure[customer] on 3DS Source creation #1069

Merged
merged 1 commit into from
Dec 26, 2017
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
71 changes: 47 additions & 24 deletions src/Stripe.Tests.XUnit/sources/creating_three_d_secure_source.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,54 @@ public class creating_three_d_secure_source
{
private StripeSource Source { get; }
private StripeSource ThreeDSecure { get; }
private StripeCustomer Customer { get; }
private StripeSource SourceCustomer { get; }
private StripeSource ThreeDSecureCustomer { get; }

public creating_three_d_secure_source()
{
Source = new StripeSourceService(Cache.ApiKey).Create(
new StripeSourceCreateOptions
var sourceCreateOptions = new StripeSourceCreateOptions
{
Type = StripeSourceType.Card,
Amount = 1234,
Currency = "eur",
RedirectReturnUrl = "http://no.where/webhooks",
Card = new StripeCreditCardOptions
{
Type = StripeSourceType.Card,
Amount = 8675309,
Currency = "eur",
RedirectReturnUrl = "http://no.where/webhooks",
Card = new StripeCreditCardOptions
{
// Using PAN as we don't have a 3DS test token yet
Number = "4000000000003063",
ExpirationMonth = 12,
ExpirationYear = 2020
}
// Using PAN as we don't have a 3DS test token yet
Number = "4000000000003063",
ExpirationMonth = 12,
ExpirationYear = 2020
}
);
};

var threeDSCreateOptions = new StripeSourceCreateOptions
{
Type = StripeSourceType.ThreeDSecure,
Amount = 8675309,
Currency = "eur",
RedirectReturnUrl = "http://no.where/webhooks",
};

var sourceService = new StripeSourceService(Cache.ApiKey);
var customerService = new StripeCustomerService(Cache.ApiKey);
Customer = customerService.Create(new StripeCustomerCreateOptions{});

Source = sourceService.Create(sourceCreateOptions);
threeDSCreateOptions.ThreeDSecureCardOrSourceId = Source.Id;
ThreeDSecure = sourceService.Create(threeDSCreateOptions);

SourceCustomer = sourceService.Create(sourceCreateOptions);
var SourceAttachOptions = new StripeSourceAttachOptions
{
Source = SourceCustomer.Id
};
sourceService.Attach(Customer.Id, SourceAttachOptions);

threeDSCreateOptions.ThreeDSecureCardOrSourceId = SourceCustomer.Id;
threeDSCreateOptions.ThreeDSecureCustomer = Customer.Id;
ThreeDSecureCustomer = sourceService.Create(threeDSCreateOptions);

ThreeDSecure = new StripeSourceService(Cache.ApiKey).Create(
new StripeSourceCreateOptions
{
Type = StripeSourceType.ThreeDSecure,
Amount = 8675309,
Currency = "eur",
RedirectReturnUrl = "http://no.where/webhooks",
ThreeDSecureCardOrSourceId = Source.Id
}
);

// from here, you have to go to the threeDSecure.Redirect.Url and click success

Expand All @@ -56,6 +74,11 @@ public void should_setup_for_3d_secure()
Source.Should().NotBeNull();
ThreeDSecure.Should().NotBeNull();
ThreeDSecure.Redirect.Url.Should().NotBeNull();

SourceCustomer.Should().NotBeNull();
ThreeDSecureCustomer.Should().NotBeNull();
ThreeDSecureCustomer.ThreeDSecure.CardId.Should().Be(SourceCustomer.Id);
ThreeDSecureCustomer.ThreeDSecure.CustomerId.Should().Be(Customer.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class StripeSourceCreateOptions : StripeBaseOptions
[JsonProperty("sofort[statement_descriptor]")]
public string SofortStatementDescriptor { get; set; }

[JsonProperty("[three_d_secure][customer]")]
public string ThreeDSecureCustomer { get; set; }

[JsonProperty("[three_d_secure][card]")]
public string ThreeDSecureCardOrSourceId { get; set; }

Expand Down