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 BACS Debit as a PaymentMethod #1109

Merged
merged 1 commit into from
May 29, 2020
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
17 changes: 12 additions & 5 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ type AccountSettingsBrandingParams struct {
SecondaryColor *string `form:"secondary_color"`
}

// AccountSettingsBACSDebitPaymentsParams represent allowed parameters to configure settings specific to
// BACS Debit charging on the account.
type AccountSettingsBACSDebitPaymentsParams struct {
DisplayName *string `form:"display_name"`
}

// AccountSettingsCardPaymentsParams represent allowed parameters to configure settings specific to
// card charging on the account.
type AccountSettingsCardPaymentsParams struct {
Expand Down Expand Up @@ -228,11 +234,12 @@ type AccountSettingsPayoutsParams struct {

// AccountSettingsParams are the parameters allowed for the account's settings.
type AccountSettingsParams struct {
Branding *AccountSettingsBrandingParams `form:"branding"`
CardPayments *AccountSettingsCardPaymentsParams `form:"card_payments"`
Dashboard *AccountSettingsDashboardParams `form:"dashboard"`
Payments *AccountSettingsPaymentsParams `form:"payments"`
Payouts *AccountSettingsPayoutsParams `form:"payouts"`
BACSDebitPayments *AccountSettingsBACSDebitPaymentsParams `form:"bacs_debit_payments"`
Branding *AccountSettingsBrandingParams `form:"branding"`
CardPayments *AccountSettingsCardPaymentsParams `form:"card_payments"`
Dashboard *AccountSettingsDashboardParams `form:"dashboard"`
Payments *AccountSettingsPaymentsParams `form:"payments"`
Payouts *AccountSettingsPayoutsParams `form:"payouts"`
}

// PayoutScheduleParams are the parameters allowed for payout schedules.
Expand Down
13 changes: 12 additions & 1 deletion charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
ChargePaymentMethodDetailsTypeAcssDebit ChargePaymentMethodDetailsType = "acss_debit"
ChargePaymentMethodDetailsTypeAlipay ChargePaymentMethodDetailsType = "alipay"
ChargePaymentMethodDetailsTypeAUBECSDebit ChargePaymentMethodDetailsType = "au_becs_debit"
ChargePaymentMethodDetailsTypeBACSDebit ChargePaymentMethodDetailsType = "bacs_debit"
ChargePaymentMethodDetailsTypeBancontact ChargePaymentMethodDetailsType = "bancontact"
ChargePaymentMethodDetailsTypeBitcoin ChargePaymentMethodDetailsType = "bitcoin" // This is unsupported today and is here for legacy charges.
ChargePaymentMethodDetailsTypeCard ChargePaymentMethodDetailsType = "card"
Expand Down Expand Up @@ -249,6 +250,14 @@ type ChargePaymentMethodDetailsAUBECSDebit struct {
Mandate string `json:"mandate"`
}

// ChargePaymentMethodDetailsBACSDebit represents details about the BECS Debit PaymentMethod.
type ChargePaymentMethodDetailsBACSDebit struct {
Fingerprint string `json:"fingerprint"`
Last4 string `json:"last4"`
Mandate string `json:"mandate"`
SortCode string `json:"sort_code"`
}

// ChargePaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod.
type ChargePaymentMethodDetailsBancontact struct {
BankCode string `json:"bank_code"`
Expand Down Expand Up @@ -501,9 +510,11 @@ type ChargePaymentMethodDetailsWechat struct {
type ChargePaymentMethodDetails struct {
AchCreditTransfer *ChargePaymentMethodDetailsAchCreditTransfer `json:"ach_credit_transfer"`
AchDebit *ChargePaymentMethodDetailsAchDebit `json:"ach_debit"`
AcssDebit *ChargePaymentMethodDetailsAcssDebit `json:"acss_debit"`
Alipay *ChargePaymentMethodDetailsAlipay `json:"alipay"`
Bancontact *ChargePaymentMethodDetailsBancontact `json:"bancontact"`
AUBECSDebit *ChargePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *ChargePaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Bancontact *ChargePaymentMethodDetailsBancontact `json:"bancontact"`
Bitcoin *ChargePaymentMethodDetailsBitcoin `json:"bitcoin"`
Card *ChargePaymentMethodDetailsCard `json:"card"`
CardPresent *ChargePaymentMethodDetailsCardPresent `json:"card_present"`
Expand Down
23 changes: 22 additions & 1 deletion mandate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const (
)

// MandateCustomerAcceptanceType is the list of allowed values for the type of customer acceptance
// for a given mandate..
// for a given mandate.
type MandateCustomerAcceptanceType string

// List of values that MandateStatus can take.
Expand All @@ -19,6 +19,18 @@ const (
MandateStatusPending MandateStatus = "pending"
)

// MandatePaymentMethodDetailsBACSDebitNetworkStatus is the list of allowed values for the status
// with the network for a given mandate.
type MandatePaymentMethodDetailsBACSDebitNetworkStatus string

// List of values that MandateStatus can take.
const (
MandatePaymentMethodDetailsBACSDebitNetworkStatusAccepted MandatePaymentMethodDetailsBACSDebitNetworkStatus = "accepted"
MandatePaymentMethodDetailsBACSDebitNetworkStatusPending MandatePaymentMethodDetailsBACSDebitNetworkStatus = "pending"
MandatePaymentMethodDetailsBACSDebitNetworkStatusRefused MandatePaymentMethodDetailsBACSDebitNetworkStatus = "refused"
MandatePaymentMethodDetailsBACSDebitNetworkStatusRevoked MandatePaymentMethodDetailsBACSDebitNetworkStatus = "revoked"
)

// MandateStatus is the list of allowed values for the mandate status.
type MandateStatus string

Expand Down Expand Up @@ -66,6 +78,14 @@ type MandatePaymentMethodDetailsAUBECSDebit struct {
URL string `json:"url"`
}

// MandatePaymentMethodDetailsBACSDebit represents details about the BACS debit account
// associated with this mandate.
type MandatePaymentMethodDetailsBACSDebit struct {
NetworkStatus MandatePaymentMethodDetailsBACSDebitNetworkStatus `json:"network_status"`
Reference string `json:"reference"`
URL string `json:"url"`
}

// MandatePaymentMethodDetailsCard represents details about the card associated with this mandate.
type MandatePaymentMethodDetailsCard struct {
}
Expand All @@ -81,6 +101,7 @@ type MandatePaymentMethodDetailsSepaDebit struct {
// mandate.
type MandatePaymentMethodDetails struct {
AUBECSDebit *MandatePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *MandatePaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Card *MandatePaymentMethodDetailsCard `json:"card"`
SepaDebit *MandatePaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Type PaymentMethodType `json:"type"`
Expand Down
8 changes: 8 additions & 0 deletions paymentmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type PaymentMethodType string
// List of values that PaymentMethodType can take.
const (
PaymentMethodTypeAUBECSDebit PaymentMethodType = "au_becs_debit"
PaymentMethodTypeBACSDebit PaymentMethodType = "bacs_debit"
PaymentMethodTypeCard PaymentMethodType = "card"
PaymentMethodTypeCardPresent PaymentMethodType = "card_present"
PaymentMethodTypeFPX PaymentMethodType = "fpx"
Expand Down Expand Up @@ -88,6 +89,12 @@ type PaymentMethodAUBECSDebitParams struct {
BSBNumber *string `form:"bsb_number"`
}

// PaymentMethodBACSDebitParams is the set of parameters allowed for BACS Debit payment method.
type PaymentMethodBACSDebitParams struct {
AccountNumber *string `form:"account_number"`
SortCode *string `form:"sort_code"`
}

// PaymentMethodCardParams is the set of parameters allowed for the `card` hash when creating a
// PaymentMethod of type card.
type PaymentMethodCardParams struct {
Expand Down Expand Up @@ -127,6 +134,7 @@ type PaymentMethodSepaDebitParams struct {
type PaymentMethodParams struct {
Params `form:"*"`
AUBECSDebit *PaymentMethodAUBECSDebitParams `form:"au_becs_debit"`
BACSDebit *PaymentMethodBACSDebitParams `form:"bacs_debit"`
BillingDetails *BillingDetailsParams `form:"billing_details"`
Card *PaymentMethodCardParams `form:"card"`
FPX *PaymentMethodFPXParams `form:"fpx"`
Expand Down