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

Next major release changes #1512

Merged
merged 7 commits into from
Aug 1, 2022
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
377 changes: 143 additions & 234 deletions account.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions account/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestAccountNew(t *testing.T) {
Logo: stripe.String("file_234"),
},
CardPayments: &stripe.AccountSettingsCardPaymentsParams{
DeclineOn: &stripe.AccountDeclineSettingsParams{
DeclineOn: &stripe.AccountSettingsCardPaymentsDeclineOnParams{
AVSFailure: stripe.Bool(true),
CVCFailure: stripe.Bool(true),
},
Expand All @@ -89,9 +89,9 @@ func TestAccountNew(t *testing.T) {
},
Payouts: &stripe.AccountSettingsPayoutsParams{
DebitNegativeBalances: stripe.Bool(true),
Schedule: &stripe.PayoutScheduleParams{
Schedule: &stripe.AccountSettingsPayoutsScheduleParams{
DelayDaysMinimum: stripe.Bool(true),
Interval: stripe.String(string(stripe.PayoutIntervalManual)),
Interval: stripe.String(string(stripe.AccountSettingsPayoutsScheduleIntervalManual)),
},
StatementDescriptor: stripe.String("payout_descriptor"),
},
Expand All @@ -104,7 +104,7 @@ func TestAccountNew(t *testing.T) {

func TestAccountReject(t *testing.T) {
account, err := Reject("acct_123", &stripe.AccountRejectParams{
Reason: stripe.String(string(stripe.AccountRejectReasonFraud)),
Reason: stripe.String("fraud"),
})
assert.Nil(t, err)
assert.NotNil(t, account)
Expand All @@ -113,7 +113,7 @@ func TestAccountReject(t *testing.T) {
func TestAccountUpdate(t *testing.T) {
account, err := Update("acct_123", &stripe.AccountParams{
Company: &stripe.AccountCompanyParams{
Address: &stripe.AccountAddressParams{
Address: &stripe.AddressParams{
Country: stripe.String("CA"),
City: stripe.String("Montreal"),
PostalCode: stripe.String("H2Y 1C6"),
Expand Down
8 changes: 4 additions & 4 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestAccount_Unmarshal(t *testing.T) {
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.Equal(t, AccountSettingsPayoutsScheduleIntervalWeekly, account.Settings.Payouts.Schedule.Interval)

assert.Equal(t, int64(1528573382), account.TOSAcceptance.Date)
assert.Equal(t, "127.0.0.1", account.TOSAcceptance.IP)
Expand Down Expand Up @@ -193,10 +193,10 @@ func TestExternalAccount_UnmarshalJSON(t *testing.T) {
// decode
data := []byte(`{"id":"ba_123", "object":"bank_account"}`)

var v ExternalAccount
var v AccountExternalAccount
err := json.Unmarshal(data, &v)
assert.NoError(t, err)
assert.Equal(t, ExternalAccountTypeBankAccount, v.Type)
assert.Equal(t, AccountExternalAccountTypeBankAccount, v.Type)

// The external account has a field for each possible type, so the
// bank account is located one level down
Expand All @@ -206,7 +206,7 @@ func TestExternalAccount_UnmarshalJSON(t *testing.T) {

func TestPayoutScheduleParams_AppendTo(t *testing.T) {
{
params := &PayoutScheduleParams{DelayDaysMinimum: Bool(true)}
params := &AccountSettingsPayoutsScheduleParams{DelayDaysMinimum: Bool(true)}
body := &form.Values{}
form.AppendTo(body, params)
t.Logf("body = %+v", body)
Expand Down
2 changes: 1 addition & 1 deletion fee.go → applicationfee.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ApplicationFee struct {
// Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued)
AmountRefunded int64 `json:"amount_refunded"`
// ID of the Connect application that earned the fee.
Application string `json:"application"`
Application *Application `json:"application"`
// Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
// ID of the charge that the application fee was taken from.
Expand Down
4 changes: 2 additions & 2 deletions fee/client.go → applicationfee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
//

// Package fee provides the /application_fees APIs
package fee
// Package applicationfee provides the /application_fees APIs
package applicationfee

import (
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion fee/client_test.go → applicationfee/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fee
package applicationfee

import (
"testing"
Expand Down
9 changes: 3 additions & 6 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const (
BalanceSourceTypeFPX BalanceSourceType = "fpx"
)

// BalanceTransactionStatus is the list of allowed values for the balance transaction's status.
type BalanceTransactionStatus string

// Retrieves the current account balance, based on the authentication that was used to make the request.
// For a sample request, see [Accounting for negative balances](https://stripe.com/docs/connect/account-balances#accounting-for-negative-balances).
type BalanceParams struct {
Expand All @@ -28,12 +25,12 @@ type BalanceParams struct {
// Funds that are available to be transferred or paid out, whether automatically by Stripe or explicitly via the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). The available balance for each currency and payment type can be found in the `source_types` property.
type Amount struct {
// Balance amount.
Value int64 `json:"amount"`
Amount int64 `json:"amount"`
// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
Currency Currency `json:"currency"`
SourceTypes map[BalanceSourceType]int64 `json:"source_types"`
}
type BalanceDetails struct {
type BalanceIssuing struct {
// Funds that are available for use.
Available []*Amount `json:"available"`
}
Expand All @@ -57,7 +54,7 @@ type Balance struct {
ConnectReserved []*Amount `json:"connect_reserved"`
// Funds that can be paid out using Instant Payouts.
InstantAvailable []*Amount `json:"instant_available"`
Issuing *BalanceDetails `json:"issuing"`
Issuing *BalanceIssuing `json:"issuing"`
// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Livemode bool `json:"livemode"`
// String representing the object's type. Objects of the same type share the same value.
Expand Down
10 changes: 0 additions & 10 deletions balance/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ func (c Client) Get(params *stripe.BalanceParams) (*stripe.Balance, error) {
return balance, err
}

// Iter is an iterator for balance transactions.
type Iter struct {
*stripe.Iter
}

// BalanceTransaction returns the balance transaction which the iterator is currently pointing to.
func (i *Iter) BalanceTransaction() *stripe.BalanceTransaction {
return i.Current().(*stripe.BalanceTransaction)
}

func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}
10 changes: 5 additions & 5 deletions balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func TestBalance_Unmarshal(t *testing.T) {
err = json.Unmarshal(bytes, &balance)
assert.NoError(t, err)

assert.Equal(t, int64(111), balance.Available[0].Value)
assert.Equal(t, int64(111), balance.Available[0].Amount)
assert.Equal(t, CurrencyUSD, balance.Available[0].Currency)
assert.Equal(t, int64(222), balance.Available[1].Value)
assert.Equal(t, int64(222), balance.Available[1].Amount)
assert.Equal(t, CurrencyEUR, balance.Available[1].Currency)
assert.Equal(t, int64(222), balance.Available[1].Value)
assert.Equal(t, int64(222), balance.Available[1].Amount)

assert.Equal(t, int64(333), balance.Pending[0].Value)
assert.Equal(t, int64(333), balance.Pending[0].Amount)
assert.Equal(t, CurrencyUSD, balance.Pending[0].Currency)
assert.Equal(t, int64(444), balance.Pending[1].Value)
assert.Equal(t, int64(444), balance.Pending[1].Amount)
assert.Equal(t, CurrencyEUR, balance.Pending[1].Currency)

// Confirm source-type deserialization works
Expand Down
83 changes: 43 additions & 40 deletions balancetransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ const (
BalanceTransactionSourceTypeIssuingTransaction BalanceTransactionSourceType = "issuing.transaction"
BalanceTransactionSourceTypePayout BalanceTransactionSourceType = "payout"
BalanceTransactionSourceTypeRefund BalanceTransactionSourceType = "refund"
BalanceTransactionSourceTypeReversal BalanceTransactionSourceType = "reversal"
BalanceTransactionSourceTypeTopup BalanceTransactionSourceType = "topup"
BalanceTransactionSourceTypeTransfer BalanceTransactionSourceType = "transfer"
BalanceTransactionSourceTypeTransferReversal BalanceTransactionSourceType = "transfer_reversal"
)

// If the transaction's net funds are available in the Stripe balance yet. Either `available` or `pending`.
type BalanceTransactionStatus string

// List of values that BalanceTransactionStatus can take
const (
BalanceTransactionStatusAvailable BalanceTransactionStatus = "available"
Expand All @@ -71,38 +74,38 @@ type BalanceTransactionType string

// List of values that BalanceTransactionType can take
const (
BalanceTransactionTypeAdjustment BalanceTransactionType = "adjustment"
BalanceTransactionTypeAdvance BalanceTransactionType = "advance"
BalanceTransactionTypeAdvanceFunding BalanceTransactionType = "advance_funding"
BalanceTransactionTypeAnticipationRepayment BalanceTransactionType = "anticipation_repayment"
BalanceTransactionTypeApplicationFee BalanceTransactionType = "application_fee"
BalanceTransactionTypeApplicationFeeRefund BalanceTransactionType = "application_fee_refund"
BalanceTransactionTypeCharge BalanceTransactionType = "charge"
BalanceTransactionTypeConnectCollectionTransfer BalanceTransactionType = "connect_collection_transfer"
BalanceTransactionTypeContribution BalanceTransactionType = "contribution"
BalanceTransactionTypeIssuingAuthorizationHold BalanceTransactionType = "issuing_authorization_hold"
BalanceTransactionTypeIssuingAuthorizationRelease BalanceTransactionType = "issuing_authorization_release"
BalanceTransactionTypeIssuingAuthorizationDispute BalanceTransactionType = "issuing_dispute"
BalanceTransactionTypeIssuingAuthorizationTransaction BalanceTransactionType = "issuing_transaction"
BalanceTransactionTypePayment BalanceTransactionType = "payment"
BalanceTransactionTypePaymentFailureRefund BalanceTransactionType = "payment_failure_refund"
BalanceTransactionTypePaymentRefund BalanceTransactionType = "payment_refund"
BalanceTransactionTypePayout BalanceTransactionType = "payout"
BalanceTransactionTypePayoutCancel BalanceTransactionType = "payout_cancel"
BalanceTransactionTypePayoutFailure BalanceTransactionType = "payout_failure"
BalanceTransactionTypeRefund BalanceTransactionType = "refund"
BalanceTransactionTypeRefundFailure BalanceTransactionType = "refund_failure"
BalanceTransactionTypeReserveTransaction BalanceTransactionType = "reserve_transaction"
BalanceTransactionTypeReservedFunds BalanceTransactionType = "reserved_funds"
BalanceTransactionTypeStripeFee BalanceTransactionType = "stripe_fee"
BalanceTransactionTypeStripeFxFee BalanceTransactionType = "stripe_fx_fee"
BalanceTransactionTypeTaxFee BalanceTransactionType = "tax_fee"
BalanceTransactionTypeTopup BalanceTransactionType = "topup"
BalanceTransactionTypeTopupReversal BalanceTransactionType = "topup_reversal"
BalanceTransactionTypeTransfer BalanceTransactionType = "transfer"
BalanceTransactionTypeTransferCancel BalanceTransactionType = "transfer_cancel"
BalanceTransactionTypeTransferFailure BalanceTransactionType = "transfer_failure"
BalanceTransactionTypeTransferRefund BalanceTransactionType = "transfer_refund"
BalanceTransactionTypeAdjustment BalanceTransactionType = "adjustment"
BalanceTransactionTypeAdvance BalanceTransactionType = "advance"
BalanceTransactionTypeAdvanceFunding BalanceTransactionType = "advance_funding"
BalanceTransactionTypeAnticipationRepayment BalanceTransactionType = "anticipation_repayment"
BalanceTransactionTypeApplicationFee BalanceTransactionType = "application_fee"
BalanceTransactionTypeApplicationFeeRefund BalanceTransactionType = "application_fee_refund"
BalanceTransactionTypeCharge BalanceTransactionType = "charge"
BalanceTransactionTypeConnectCollectionTransfer BalanceTransactionType = "connect_collection_transfer"
BalanceTransactionTypeContribution BalanceTransactionType = "contribution"
BalanceTransactionTypeIssuingAuthorizationHold BalanceTransactionType = "issuing_authorization_hold"
BalanceTransactionTypeIssuingAuthorizationRelease BalanceTransactionType = "issuing_authorization_release"
BalanceTransactionTypeIssuingDispute BalanceTransactionType = "issuing_dispute"
BalanceTransactionTypeIssuingTransaction BalanceTransactionType = "issuing_transaction"
BalanceTransactionTypePayment BalanceTransactionType = "payment"
BalanceTransactionTypePaymentFailureRefund BalanceTransactionType = "payment_failure_refund"
BalanceTransactionTypePaymentRefund BalanceTransactionType = "payment_refund"
BalanceTransactionTypePayout BalanceTransactionType = "payout"
BalanceTransactionTypePayoutCancel BalanceTransactionType = "payout_cancel"
BalanceTransactionTypePayoutFailure BalanceTransactionType = "payout_failure"
BalanceTransactionTypeRefund BalanceTransactionType = "refund"
BalanceTransactionTypeRefundFailure BalanceTransactionType = "refund_failure"
BalanceTransactionTypeReserveTransaction BalanceTransactionType = "reserve_transaction"
BalanceTransactionTypeReservedFunds BalanceTransactionType = "reserved_funds"
BalanceTransactionTypeStripeFee BalanceTransactionType = "stripe_fee"
BalanceTransactionTypeStripeFxFee BalanceTransactionType = "stripe_fx_fee"
BalanceTransactionTypeTaxFee BalanceTransactionType = "tax_fee"
BalanceTransactionTypeTopup BalanceTransactionType = "topup"
BalanceTransactionTypeTopupReversal BalanceTransactionType = "topup_reversal"
BalanceTransactionTypeTransfer BalanceTransactionType = "transfer"
BalanceTransactionTypeTransferCancel BalanceTransactionType = "transfer_cancel"
BalanceTransactionTypeTransferFailure BalanceTransactionType = "transfer_failure"
BalanceTransactionTypeTransferRefund BalanceTransactionType = "transfer_refund"
)

// Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
Expand Down Expand Up @@ -133,8 +136,8 @@ type BalanceTransactionParams struct {
Params `form:"*"`
}

// Fees (in %s) paid for this transaction.
type BalanceTransactionFee struct {
// Detailed breakdown of fees (in %s) paid for this transaction.
type BalanceTransactionFeeDetail struct {
// Amount of the fee, in cents.
Amount int64 `json:"amount"`
// ID of the Connect application that earned the fee.
Expand Down Expand Up @@ -168,7 +171,7 @@ type BalanceTransaction struct {
// Fees (in %s) paid for this transaction.
Fee int64 `json:"fee"`
// Detailed breakdown of fees (in %s) paid for this transaction.
FeeDetails []*BalanceTransactionFee `json:"fee_details"`
FeeDetails []*BalanceTransactionFeeDetail `json:"fee_details"`
// Unique identifier for the object.
ID string `json:"id"`
// Net amount of the transaction, in %s.
Expand All @@ -195,12 +198,12 @@ type BalanceTransactionSource struct {
FeeRefund *FeeRefund `json:"-"`
IssuingAuthorization *IssuingAuthorization `json:"-"`
IssuingDispute *IssuingDispute `json:"-"`
IssuingTransaction *IssuingAuthorization `json:"-"`
IssuingTransaction *IssuingTransaction `json:"-"`
Payout *Payout `json:"-"`
Refund *Refund `json:"-"`
Reversal *Reversal `json:"-"`
Topup *Topup `json:"-"`
Transfer *Transfer `json:"-"`
TransferReversal *TransferReversal `json:"-"`
}

// BalanceTransactionList is a list of BalanceTransactions as retrieved from a list endpoint.
Expand Down Expand Up @@ -268,12 +271,12 @@ func (b *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
err = json.Unmarshal(data, &b.Payout)
case BalanceTransactionSourceTypeRefund:
err = json.Unmarshal(data, &b.Refund)
case BalanceTransactionSourceTypeReversal:
err = json.Unmarshal(data, &b.Reversal)
case BalanceTransactionSourceTypeTopup:
err = json.Unmarshal(data, &b.Topup)
case BalanceTransactionSourceTypeTransfer:
err = json.Unmarshal(data, &b.Transfer)
case BalanceTransactionSourceTypeTransferReversal:
err = json.Unmarshal(data, &b.TransferReversal)
}
return err
}
12 changes: 8 additions & 4 deletions bankaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ type BankAccountParams struct {
AccountHolderName *string `form:"account_holder_name"`
// The type of entity that holds the account. This can be either `individual` or `company`.
AccountHolderType *string `form:"account_holder_type"`
AccountNumber *string `form:"account_number"`
// The account number for the bank account, in string form. Must be a checking account.
AccountNumber *string `form:"account_number"`
// The bank account type. This can only be `checking` or `savings` in most countries. In Japan, this can only be `futsu` or `toza`.
AccountType *string `form:"account_type"`
// City/District/Suburb/Town/Village.
Expand All @@ -75,16 +76,19 @@ type BankAccountParams struct {
AddressState *string `form:"address_state"`
// ZIP or postal code.
AddressZip *string `form:"address_zip"`
Country *string `form:"country"`
Currency *string `form:"currency"`
// The country in which the bank account is located.
Country *string `form:"country"`
// The currency the bank account is in. This must be a country/currency pairing that [Stripe supports](https://stripe.com/docs/payouts).
Currency *string `form:"currency"`
// When set to true, this becomes the default external account for its currency.
DefaultForCurrency *bool `form:"default_for_currency"`
// Two digit number representing the card's expiration month.
ExpMonth *string `form:"exp_month"`
// Four digit number representing the card's expiration year.
ExpYear *string `form:"exp_year"`
// Cardholder name.
Name *string `form:"name"`
Name *string `form:"name"`
// The routing number, sort code, or other country-appropriate institution number for the bank account. For US bank accounts, this is required and should be the ACH routing number, not the wire routing number. If you are providing an IBAN for `account_number`, this field is not required.
RoutingNumber *string `form:"routing_number"`
// ID is used when tokenizing a bank account for shared customers
ID *string `form:"*"`
Expand Down
Loading