Skip to content

Commit

Permalink
Add support for API version 2019-02-19
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Feb 18, 2019
1 parent a0cee2f commit 0298844
Show file tree
Hide file tree
Showing 9 changed files with 502 additions and 554 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cache:
env:
global:
# If changing this number, please also change it in `testing/testing.go`.
- STRIPE_MOCK_VERSION=0.44.0
- STRIPE_MOCK_VERSION=0.45.0

go:
- "1.9.x"
Expand Down
537 changes: 256 additions & 281 deletions account.go

Large diffs are not rendered by default.

78 changes: 38 additions & 40 deletions account/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,49 @@ func TestAccountList(t *testing.T) {

func TestAccountNew(t *testing.T) {
account, err := New(&stripe.AccountParams{
Type: stripe.String(string(stripe.AccountTypeCustom)),
Country: stripe.String("CA"),
BusinessURL: stripe.String("www.stripe.com"),
BusinessName: stripe.String("Stripe"),
BusinessPrimaryColor: stripe.String("#ffffff"),
DeclineChargeOn: &stripe.AccountDeclineSettingsParams{
AVSFailure: stripe.Bool(true),
CVCFailure: stripe.Bool(true),
BusinessProfile: &stripe.AccountBusinessProfileParams{
Name: stripe.String("name"),
SupportEmail: stripe.String("foo@bar.com"),
SupportURL: stripe.String("www.stripe.com"),
SupportPhone: stripe.String("4151234567"),
},
DebitNegativeBalances: stripe.Bool(true),
SupportEmail: stripe.String("foo@bar.com"),
SupportURL: stripe.String("www.stripe.com"),
SupportPhone: stripe.String("4151234567"),
LegalEntity: &stripe.LegalEntityParams{
Type: stripe.String(string(stripe.LegalEntityTypeIndividual)),
BusinessName: stripe.String("Stripe Go"),
AdditionalOwners: []*stripe.AdditionalOwnerParams{
{
FirstName: stripe.String("Jane"),
LastName: stripe.String("Doe"),
Verification: &stripe.IdentityVerificationParams{
Document: stripe.String("file_345"),
DocumentBack: stripe.String("file_567"),
},
},
{
FirstName: stripe.String("John"),
LastName: stripe.String("Doe"),
BusinessType: stripe.String(string(stripe.AccountBusinessTypeCompany)),
Company: &stripe.AccountCompanyParams{
DirectorsProvided: stripe.Bool(true),
Name: stripe.String("company_name"),
},
Country: stripe.String("CA"),
ExternalAccount: &stripe.AccountExternalAccountParams{
Token: stripe.String("tok_123"),
},
RequestedCapabilities: []*string{
stripe.String("card_payments"),
},
Settings: &stripe.AccountSettingsParams{
Branding: &stripe.AccountSettingsBrandingParams{
Icon: stripe.String("file_123"),
Logo: stripe.String("file_234"),
},
CardPayments: &stripe.AccountSettingsCardPaymentsParams{
DeclineOn: &stripe.AccountDeclineSettingsParams{
AVSFailure: stripe.Bool(true),
CVCFailure: stripe.Bool(true),
},
StatementDescriptorPrefix: stripe.String("prefix"),
},
DOB: &stripe.DOBParams{
Day: stripe.Int64(1),
Month: stripe.Int64(2),
Year: stripe.Int64(1990),
Payments: &stripe.AccountSettingsPaymentsParams{
StatementDescriptor: stripe.String("descriptor"),
},
Verification: &stripe.IdentityVerificationParams{
Document: stripe.String("file_123"),
DocumentBack: stripe.String("file_234"),
Payouts: &stripe.AccountSettingsPayoutsParams{
DebitNegativeBalances: stripe.Bool(true),
Schedule: &stripe.PayoutScheduleParams{
DelayDaysMinimum: stripe.Bool(true),
Interval: stripe.String(string(stripe.PayoutIntervalManual)),
},
StatementDescriptor: stripe.String("payout_descriptor"),
},
},
TOSAcceptance: &stripe.TOSAcceptanceParams{
IP: stripe.String("127.0.0.1"),
Date: stripe.Int64(1437578361),
UserAgent: stripe.String("Mozilla/5.0"),
},
Type: stripe.String(string(stripe.AccountTypeCustom)),
})
assert.Nil(t, err)
assert.NotNil(t, account)
Expand All @@ -97,7 +95,7 @@ func TestAccountReject(t *testing.T) {

func TestAccountUpdate(t *testing.T) {
account, err := Update("acct_123", &stripe.AccountParams{
LegalEntity: &stripe.LegalEntityParams{
Company: &stripe.AccountCompanyParams{
Address: &stripe.AccountAddressParams{
Country: stripe.String("CA"),
City: stripe.String("Montreal"),
Expand Down
235 changes: 63 additions & 172 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func TestAccountExternalAccountParams_AppendTo(t *testing.T) {
func TestAccount_Unmarshal(t *testing.T) {
accountData := map[string]interface{}{
"id": "acct_123",
"business_profile": map[string]interface{}{
"mcc": "123",
},
"business_type": "company",
"capabilities": map[string]interface{}{
"card_payments": "active",
"platform_payments": "inactive",
},
"decline_charge_on": map[string]interface{}{
"avs_failure": true,
"cvc_failure": false,
},
"external_accounts": map[string]interface{}{
"object": "list",
"has_more": true,
Expand All @@ -55,104 +55,53 @@ func TestAccount_Unmarshal(t *testing.T) {
},
},
},
"legal_entity": map[string]interface{}{
"additional_owners": []map[string]interface{}{
{
"address": map[string]interface{}{
"city": "city1",
"country": "US",
"line1": "line1",
"line2": "line2",
"postal_code": "90210",
"state": "CA",
},
"dob": map[string]interface{}{
"day": 1,
"month": 1,
"year": 1970,
},
"first_name": "First",
"last_name": "Last",
"maiden_name": "Maiden",
"personal_id_number_provided": true,
"verification": map[string]interface{}{
"details": "details",
"details_code": "failed_other",
"document": "file_123",
"document_back": "file_234",
"status": "pending",
},
},
{
"address": map[string]interface{}{
"city": "city2",
},
"dob": map[string]interface{}{
"day": 1,
"month": 1,
"year": 1960,
},
"first_name": "First2",
},
"metadata": map[string]interface{}{
"key1": "value1",
"key2": "value2",
},
"object": "account",
"requirements": map[string]interface{}{
"current_deadline": 1234567890,
"currently_due": []interface{}{
"tos_acceptance.date",
"tos_acceptance.ip",
},
"disabled_reason": "fields_needed",
"eventually_due": []interface{}{
"relationship.account_opener",
},
"address": map[string]interface{}{
"city": "city-3",
"country": "US",
"line1": "line1-3",
"line2": "line2-3",
"postal_code": "91111",
"state": "CA",
"past_due": []interface{}{},
},
"settings": map[string]interface{}{
"branding": map[string]interface{}{
"icon": "file_123",
"logo": "file_234",
},
"business_tax_id_provided": true,
"dob": map[string]interface{}{
"day": 1,
"month": 1,
"year": 1980,
"card_payments": map[string]interface{}{
"decline_on": map[string]interface{}{
"avs_failure": true,
"cvc_failure": false,
},
"statement_descriptor_prefix": "prefix",
},
"first_name": "John",
"last_name": "Doe",
"maiden_name": "Maiden",
"personal_address": map[string]interface{}{
"city": "personal_city1",
"country": "US",
"line1": "personal_line1",
"line2": "personal_line2",
"postal_code": "90210",
"state": "CA",
"payments": map[string]interface{}{
"statement_descriptor": "descriptor",
},
"personal_id_number_provided": true,
"ssn_last_4_provided": true,
"type": "company",
"verification": map[string]interface{}{
"details": "details",
"details_code": "failed_other",
"document": "file_345",
"document_back": "file_456",
"status": "unverified",
"payouts": map[string]interface{}{
"debit_negative_balances": true,
"schedule": map[string]interface{}{
"delay_days": 2,
"interval": "weekly",
},
"statement_descriptor_prefix": "prefix",
},
},
"metadata": map[string]interface{}{
"key1": "value1",
"key2": "value2",
},
"payout_schedule": map[string]interface{}{
"delay_days": 2,
"interval": "weekly",
},
"tos_acceptance": map[string]interface{}{
"date": 1528573382,
"ip": "127.0.0.1",
"user_agent": "user agent",
},
"type": "custom",
"verification": map[string]interface{}{
"disabled_reason": "fields_needed",
"due_by": 1528573382,
"fields_needed": []interface{}{
"legal_entity.verification.document",
"legal_entity.business_name",
},
},
}

bytes, err := json.Marshal(&accountData)
Expand All @@ -164,102 +113,44 @@ func TestAccount_Unmarshal(t *testing.T) {

assert.Equal(t, "acct_123", account.ID)

assert.Equal(t, "123", account.BusinessProfile.MCC)

assert.Equal(t, AccountCapabilityStatusActive, account.Capabilities.CardPayments)
assert.Equal(t, AccountCapabilityStatus(""), account.Capabilities.LegacyPayments)
assert.Equal(t, AccountCapabilityStatusInactive, account.Capabilities.PlatformPayments)

assert.Equal(t, true, account.DeclineChargeOn.AVSFailure)
assert.Equal(t, false, account.DeclineChargeOn.CVCFailure)

assert.Equal(t, "value1", account.Metadata["key1"])
assert.Equal(t, "value2", account.Metadata["key2"])

assert.Equal(t, int64(2), account.PayoutSchedule.DelayDays)
assert.Equal(t, PayoutIntervalWeekly, account.PayoutSchedule.Interval)

assert.Equal(t, AccountTypeCustom, account.Type)

assert.Equal(t, int64(1528573382), account.TOSAcceptance.Date)
assert.Equal(t, "127.0.0.1", account.TOSAcceptance.IP)
assert.Equal(t, "user agent", account.TOSAcceptance.UserAgent)

assert.Equal(t, IdentityVerificationDisabledReasonFieldsNeeded, account.Verification.DisabledReason)
assert.Equal(t, int64(1528573382), account.Verification.DueBy)
assert.Equal(t, 2, len(account.Verification.FieldsNeeded))
assert.Equal(t, "legal_entity.verification.document", account.Verification.FieldsNeeded[0])
assert.Equal(t, "legal_entity.business_name", account.Verification.FieldsNeeded[1])
assert.Equal(t, AccountBusinessTypeCompany, account.BusinessType)

// Assert ExternalAccounts are fully deserialized
assert.Equal(t, true, account.ExternalAccounts.HasMore)

assert.Equal(t, 2, len(account.ExternalAccounts.Data))
assert.Equal(t, "ba_123", account.ExternalAccounts.Data[0].ID)
assert.Equal(t, "card_123", account.ExternalAccounts.Data[1].ID)

// Ensure LegalEntity is fully deserialized
assert.NotNil(t, account.LegalEntity)

assert.Equal(t, 2, len(account.LegalEntity.AdditionalOwners))
assert.Equal(t, "city1", account.LegalEntity.AdditionalOwners[0].Address.City)
assert.Equal(t, "US", account.LegalEntity.AdditionalOwners[0].Address.Country)
assert.Equal(t, "line1", account.LegalEntity.AdditionalOwners[0].Address.Line1)
assert.Equal(t, "line2", account.LegalEntity.AdditionalOwners[0].Address.Line2)
assert.Equal(t, "90210", account.LegalEntity.AdditionalOwners[0].Address.PostalCode)
assert.Equal(t, "CA", account.LegalEntity.AdditionalOwners[0].Address.State)
assert.Equal(t, int64(1), account.LegalEntity.AdditionalOwners[0].DOB.Day)
assert.Equal(t, int64(1), account.LegalEntity.AdditionalOwners[0].DOB.Month)
assert.Equal(t, int64(1970), account.LegalEntity.AdditionalOwners[0].DOB.Year)
assert.Equal(t, "First", account.LegalEntity.AdditionalOwners[0].FirstName)
assert.Equal(t, "Last", account.LegalEntity.AdditionalOwners[0].LastName)
assert.Equal(t, "Maiden", account.LegalEntity.AdditionalOwners[0].MaidenName)
assert.True(t, account.LegalEntity.AdditionalOwners[0].PersonalIDNumberProvided)
assert.Equal(t, "details", account.LegalEntity.AdditionalOwners[0].Verification.Details)
assert.Equal(t, IdentityVerificationDetailsCodeFailedOther, account.LegalEntity.AdditionalOwners[0].Verification.DetailsCode)
assert.Equal(t, "file_123", account.LegalEntity.AdditionalOwners[0].Verification.Document.ID)
assert.Equal(t, "file_234", account.LegalEntity.AdditionalOwners[0].Verification.DocumentBack.ID)
assert.Equal(t, IdentityVerificationStatusPending, account.LegalEntity.AdditionalOwners[0].Verification.Status)

assert.Equal(t, "city2", account.LegalEntity.AdditionalOwners[1].Address.City)
assert.Equal(t, "First2", account.LegalEntity.AdditionalOwners[1].FirstName)

assert.Equal(t, "city1", account.LegalEntity.AdditionalOwners[0].Address.City)
assert.Equal(t, "US", account.LegalEntity.AdditionalOwners[0].Address.Country)
assert.Equal(t, "line1", account.LegalEntity.AdditionalOwners[0].Address.Line1)
assert.Equal(t, "line2", account.LegalEntity.AdditionalOwners[0].Address.Line2)
assert.Equal(t, "90210", account.LegalEntity.AdditionalOwners[0].Address.PostalCode)
assert.Equal(t, "CA", account.LegalEntity.AdditionalOwners[0].Address.State)

assert.Equal(t, "city-3", account.LegalEntity.Address.City)
assert.Equal(t, "US", account.LegalEntity.Address.Country)
assert.Equal(t, "line1-3", account.LegalEntity.Address.Line1)
assert.Equal(t, "line2-3", account.LegalEntity.Address.Line2)
assert.Equal(t, "91111", account.LegalEntity.Address.PostalCode)
assert.Equal(t, "CA", account.LegalEntity.Address.State)

assert.True(t, account.LegalEntity.BusinessTaxIDProvided)
assert.Equal(t, int64(1), account.LegalEntity.DOB.Day)
assert.Equal(t, int64(1), account.LegalEntity.DOB.Month)
assert.Equal(t, int64(1980), account.LegalEntity.DOB.Year)
assert.True(t, account.LegalEntity.PersonalIDNumberProvided)
assert.Equal(t, "John", account.LegalEntity.FirstName)
assert.Equal(t, "Doe", account.LegalEntity.LastName)
assert.Equal(t, "Maiden", account.LegalEntity.MaidenName)
assert.Equal(t, "value1", account.Metadata["key1"])
assert.Equal(t, "value2", account.Metadata["key2"])

assert.Equal(t, "personal_city1", account.LegalEntity.PersonalAddress.City)
assert.Equal(t, "US", account.LegalEntity.PersonalAddress.Country)
assert.Equal(t, "personal_line1", account.LegalEntity.PersonalAddress.Line1)
assert.Equal(t, "personal_line2", account.LegalEntity.PersonalAddress.Line2)
assert.Equal(t, "90210", account.LegalEntity.PersonalAddress.PostalCode)
assert.Equal(t, "CA", account.LegalEntity.PersonalAddress.State)
assert.Equal(t, int64(1234567890), account.Requirements.CurrentDeadline)
assert.Equal(t, 2, len(account.Requirements.CurrentlyDue))
assert.Equal(t, AccountRequirementsDisabledReasonFieldsNeeded, account.Requirements.DisabledReason)
assert.Equal(t, 1, len(account.Requirements.EventuallyDue))
assert.Equal(t, 0, len(account.Requirements.PastDue))

assert.Equal(t, "file_123", account.Settings.Branding.Icon.ID)
assert.Equal(t, "file_234", account.Settings.Branding.Logo.ID)
assert.Equal(t, true, account.Settings.CardPayments.DeclineOn.AVSFailure)
assert.Equal(t, false, account.Settings.CardPayments.DeclineOn.CVCFailure)
assert.Equal(t, "prefix", account.Settings.CardPayments.StatementDescriptorPrefix)
assert.Equal(t, "descriptor", account.Settings.Payments.StatementDescriptor)
assert.Equal(t, true, account.Settings.Payouts.DebitNegativeBalances)
assert.Equal(t, int64(2), account.Settings.Payouts.Schedule.DelayDays)
assert.Equal(t, PayoutIntervalWeekly, account.Settings.Payouts.Schedule.Interval)

assert.True(t, account.LegalEntity.PersonalIDNumberProvided)
assert.True(t, account.LegalEntity.SSNLast4Provided)
assert.Equal(t, LegalEntityTypeCompany, account.LegalEntity.Type)
assert.Equal(t, int64(1528573382), account.TOSAcceptance.Date)
assert.Equal(t, "127.0.0.1", account.TOSAcceptance.IP)
assert.Equal(t, "user agent", account.TOSAcceptance.UserAgent)

assert.Equal(t, IdentityVerificationDetailsCodeFailedOther, account.LegalEntity.Verification.DetailsCode)
assert.Equal(t, "file_345", account.LegalEntity.Verification.Document.ID)
assert.Equal(t, "file_456", account.LegalEntity.Verification.DocumentBack.ID)
assert.Equal(t, IdentityVerificationStatusUnverified, account.LegalEntity.Verification.Status)
assert.Equal(t, AccountTypeCustom, account.Type)
}

func TestAccount_UnmarshalJSON(t *testing.T) {
Expand Down
Loading

0 comments on commit 0298844

Please sign in to comment.