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 Network on Charge #1001

Merged
merged 1 commit into from
Dec 4, 2019
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
2 changes: 2 additions & 0 deletions charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ type ChargePaymentMethodDetailsCard struct {
Funding CardFunding `json:"funding"`
Installments *ChargePaymentMethodDetailsCardInstallments `json:"installments"`
Last4 string `json:"last4"`
Network PaymentMethodCardNetwork `json:"network"`
MOTO bool `json:"moto"`
ThreeDSecure *ChargePaymentMethodDetailsCardThreeDSecure `json:"three_d_secure"`
Wallet *ChargePaymentMethodDetailsCardWallet `json:"wallet"`
Expand Down Expand Up @@ -346,6 +347,7 @@ type ChargePaymentMethodDetailsCardPresent struct {
Funding CardFunding `json:"funding"`
GeneratedCard string `json:"generated_card"`
Last4 string `json:"last4"`
Network PaymentMethodCardNetwork `json:"network"`
ReadMethod string `json:"read_method"`
Receipt *ChargePaymentMethodDetailsCardPresentReceipt `json:"receipt"`
}
Expand Down
17 changes: 17 additions & 0 deletions paymentmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ const (
PaymentMethodCardBrandVisa PaymentMethodCardBrand = "visa"
)

// PaymentMethodCardNetwork is the list of allowed values to represent the network
// used for a card-like transaction.
type PaymentMethodCardNetwork string
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 made a call here on where to set the enum. I am not sure this is the right decision in the library. In a "normal" world we'd name if ChargePaymentMethodDetailsCardNetwork and it'd be specific, and duplicated for CardPresent, but in the future the network will be chosen for a PI and that will make us rename it.

Long story short: we need to figure out clear rules on how to name enums.


// List of values that PaymentMethodCardNetwork can take.
const (
PaymentMethodCardNetworkAmex PaymentMethodCardNetwork = "amex"
PaymentMethodCardNetworkDiners PaymentMethodCardNetwork = "diners"
PaymentMethodCardNetworkDiscover PaymentMethodCardNetwork = "discover"
PaymentMethodCardNetworkInterac PaymentMethodCardNetwork = "interac"
PaymentMethodCardNetworkJCB PaymentMethodCardNetwork = "jcb"
PaymentMethodCardNetworkMastercard PaymentMethodCardNetwork = "mastercard"
PaymentMethodCardNetworkUnionpay PaymentMethodCardNetwork = "unionpay"
PaymentMethodCardNetworkUnknown PaymentMethodCardNetwork = "unknown"
PaymentMethodCardNetworkVisa PaymentMethodCardNetwork = "visa"
)

// PaymentMethodCardWalletType is the list of allowed values for the type a wallet can take on
// a Card PaymentMethod.
type PaymentMethodCardWalletType string
Expand Down