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

Add support for document_back #1201

Merged
merged 2 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 14 additions & 4 deletions src/Stripe.Tests.XUnit/accounts/_fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ public account_fixture()
{
// create a file to attach to the additional owner as a verification document
var fileService = new StripeFileUploadService(Cache.ApiKey);
var fileStream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");
var file = fileService.Create("bumble.jpg", fileStream, StripeFilePurpose.IdentityDocument);
var additionalOwnerFileStream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");
var additionalOwnerFileStreamBack = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");
var verificationFileStream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");
var verificationFileStreamBack = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");

var additionalOwnerFile = fileService.Create("bumble.jpg", additionalOwnerFileStream, StripeFilePurpose.IdentityDocument);
var additionalOwnerFileBack = fileService.Create("bumble_back.jpg", additionalOwnerFileStreamBack, StripeFilePurpose.IdentityDocument);
var verificationOwnerFile = fileService.Create("bumble.jpg", verificationFileStream, StripeFilePurpose.IdentityDocument);
var verificationOwnerFileBack = fileService.Create("bumble_back.jpg", verificationFileStreamBack, StripeFilePurpose.IdentityDocument);

AccountCreateOptions = new StripeAccountCreateOptions
{
Expand All @@ -46,7 +53,8 @@ public account_fixture()
FirstName = "Bumble", LastName = "B",
// Ensure the owner is older than 18 to avoid API issues.
BirthDay = 29, BirthMonth = 8, BirthYear = 1980,
VerificationDocument = file.Id
VerificationDocument = additionalOwnerFile.Id,
VerificationDocumentBack = additionalOwnerFileBack.Id
},
new StripeAccountAdditionalOwner
{
Expand All @@ -55,7 +63,9 @@ public account_fixture()
Line1 ="B", Line2 = "C", PostalCode = "27635",
Country = "US"
}
}
},
VerificationDocumentFileId = verificationOwnerFile.Id,
VerificationDocumentFileBackId = verificationOwnerFileBack.Id
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public void created_has_legal_entity()
fixture.Account.LegalEntity.Should().NotBeNull();
}

[Fact]
public void created_has_legal_entity_verification_document()
{
fixture.Account.LegalEntity.LegalEntityVerification.DocumentId.Should().NotBeNull();
fixture.Account.LegalEntity.LegalEntityVerification.DocumentIdBack.Should().NotBeNull();
}

[Fact]
public void created_has_addditional_owners()
{
Expand All @@ -37,6 +44,7 @@ public void created_has_the_right_number_of_additional_owners()
public void created_has_the_verification_document()
{
fixture.Account.LegalEntity.AdditionalOwners.First().LegalEntityVerification.DocumentId.Should().NotBeNullOrEmpty();
fixture.Account.LegalEntity.AdditionalOwners.First().LegalEntityVerification.DocumentIdBack.Should().NotBeNullOrEmpty();
}

[Fact]
Expand Down
13 changes: 13 additions & 0 deletions src/Stripe.net/Entities/StripeLegalEntityVerification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ public class StripeLegalEntityVerification : StripeEntity

#region Expandable Document
public string DocumentId { get; set; }
public string DocumentIdBack { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor but I think you should separate each region but will defer to ob

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had thought we might want to group it into the same region but tbh its been a while since I've worked with c#

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the purpose is purely an IDE feature. Would you as a developer want to collapse both of these together always or would there be a reason to have this in its own region? Since they're so related I would think we'd want them together but idk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention so far has been to create a region for each expandable attribute, so I'd have a slight preference for sticking to the convention. That said, it's just an IDE feature so no strong feels here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I just placed it in its own region to follow convention. ✅


[JsonIgnore]
public StripeFileUpload Document { get; set; }

[JsonIgnore]
public StripeFileUpload DocumentBack { get; set; }

[JsonProperty("document")]
internal object InternalDocument
{
Expand All @@ -25,6 +29,15 @@ internal object InternalDocument
StringOrObject<StripeFileUpload>.Map(value, s => DocumentId = s, o => Document = o);
}
}

[JsonProperty("document_back")]
internal object InternalDocumentBack
{
set
{
StringOrObject<StripeFileUpload>.Map(value, s => DocumentIdBack = s, o => DocumentBack = o);
}
}
#endregion

[JsonProperty("status")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ public class StripeAccountAdditionalOwner : INestedOptions

[JsonProperty("verification[document]")]
public string VerificationDocument { get; set; }

[JsonProperty("verification[document_back]")]
public string VerificationDocumentBack { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ public class StripeAccountLegalEntityOptions : INestedOptions
[JsonProperty("legal_entity[verification][document]")]
public string VerificationDocumentFileId { get; set; }

[JsonProperty("legal_entity[verification][document_back]")]
public string VerificationDocumentFileBackId { get; set; }

#endregion

#region Additional Owners
Expand Down