Skip to content

Commit ade2e9e

Browse files
authored
OMG-25752 - Truncate fields before sending to Shippo (#11)
OMG-25752 - Truncate fields before sending to Shippo
2 parents 3ede812 + a240d6c commit ade2e9e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

client/address.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ func (c *Client) CreateAddress(input *models.AddressInput, shippoSubAccountID st
1414
return nil, errors.New("nil input")
1515
}
1616

17+
// Truncate phone to 50 characters to avoid Stripe API errors
18+
if len(input.Phone) > 50 {
19+
input.Phone = input.Phone[:50]
20+
}
21+
1722
output := &models.Address{}
1823
err := c.do(http.MethodPost, "/addresses/", input, output, c.subAccountHeader(shippoSubAccountID))
1924
return output, err

client/sub_account.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ func (c *Client) CreateSubAccount(input *models.SubAccountInput) (*models.SubAcc
1111
return nil, errors.New("nil input")
1212
}
1313

14+
// Truncate fields to avoid Stripe API errors
15+
if len(input.FirstName) > 30 {
16+
input.FirstName = input.FirstName[:30]
17+
}
18+
if len(input.LastName) > 30 {
19+
input.LastName = input.LastName[:30]
20+
}
21+
if len(input.CompanyName) > 50 {
22+
input.CompanyName = input.CompanyName[:50]
23+
}
24+
1425
output := &models.SubAccount{}
1526
err := c.doWithoutVersion(http.MethodPost, "/shippo-accounts", input, output, nil)
1627
return output, err

0 commit comments

Comments
 (0)