From 3cd9252529a7b298d3cf9428c58dde6f3a5e3499 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 6 Oct 2020 18:27:54 -0400 Subject: [PATCH 1/3] support sepa_debit for bancontact, ideal, sofort --- charge.go | 38 ++++++++++++++++++++++---------------- paymentmethod.go | 18 +++++++++++++----- setupattempt.go | 41 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 23 deletions(-) diff --git a/charge.go b/charge.go index 95116c63a3..0cba1639be 100644 --- a/charge.go +++ b/charge.go @@ -274,12 +274,14 @@ type ChargePaymentMethodDetailsBACSDebit struct { // ChargePaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod. type ChargePaymentMethodDetailsBancontact struct { - BankCode string `json:"bank_code"` - BankName string `json:"bank_name"` - Bic string `json:"bic"` - IbanLast4 string `json:"iban_last4"` - PreferredLanguage string `json:"preferred_language"` - VerifiedName string `json:"verified_name"` + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + IbanLast4 string `json:"iban_last4"` + PreferredLanguage string `json:"preferred_language"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsCardChecks represents the checks associated with the charge's Card @@ -428,10 +430,12 @@ type ChargePaymentMethodDetailsGiropay struct { // ChargePaymentMethodDetailsIdeal represents details about the Ideal PaymentMethod. type ChargePaymentMethodDetailsIdeal struct { - Bank string `json:"bank"` - Bic string `json:"bic"` - IbanLast4 string `json:"iban_last4"` - VerifiedName string `json:"verified_name"` + Bank string `json:"bank"` + Bic string `json:"bic"` + IbanLast4 string `json:"iban_last4"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsInteracPresent represents details about the InteracPresent PaymentMethod. @@ -497,12 +501,14 @@ type ChargePaymentMethodDetailsSepaDebit struct { // ChargePaymentMethodDetailsSofort represents details about the Sofort PaymentMethod. type ChargePaymentMethodDetailsSofort struct { - BankCode string `json:"bank_code"` - BankName string `json:"bank_name"` - Bic string `json:"bic"` - Country string `json:"country"` - IbanLast4 string `json:"iban_last4"` - VerifiedName string `json:"verified_name"` + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + Country string `json:"country"` + IbanLast4 string `json:"iban_last4"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsStripeAccount represents details about the StripeAccount PaymentMethod. diff --git a/paymentmethod.go b/paymentmethod.go index a5b7bd2465..44f635c216 100644 --- a/paymentmethod.go +++ b/paymentmethod.go @@ -327,13 +327,21 @@ type PaymentMethodOXXO struct { type PaymentMethodP24 struct { } +// PaymentMethodSepaDebitGeneratedFrom represents information about the object +// that generated this PaymentMethod +type PaymentMethodSepaDebitGeneratedFrom struct { + Charge *Charge `json:"charge"` + SetupAttempt *SetupAttempt `json:"setup_attempt"` +} + // PaymentMethodSepaDebit represents the SEPA-debit-specific properties. type PaymentMethodSepaDebit struct { - BankCode string `json:"bank_code"` - BranchCode string `json:"branch_code"` - Country string `json:"country"` - Fingerprint string `json:"fingerprint"` - Last4 string `json:"last4"` + BankCode string `json:"bank_code"` + BranchCode string `json:"branch_code"` + Country string `json:"country"` + Fingerprint string `json:"fingerprint"` + Last4 string `json:"last4"` + GeneratedFrom PaymentMethodSepaDebitGeneratedFrom `json:"generated_from"` } // PaymentMethodSofort represents the Sofort-specific properties. diff --git a/setupattempt.go b/setupattempt.go index 01a0e9b606..e63051144a 100644 --- a/setupattempt.go +++ b/setupattempt.go @@ -85,15 +85,52 @@ type SetupAttemptPaymentMethodDetailsCardThreeDSecure struct { Version string `json:"version"` } +// SetupAttemptPaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod. +type SetupAttemptPaymentMethodDetailsBancontact struct { + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` + IbanLast4 string `json:"iban_last4"` + PreferredLanguage string `json:"preferred_language"` + VerifiedName string `json:"verified_name"` +} + // SetupAttemptPaymentMethodDetailsCard represents details about the Card PaymentMethod. type SetupAttemptPaymentMethodDetailsCard struct { ThreeDSecure *SetupAttemptPaymentMethodDetailsCardThreeDSecure `json:"three_d_secure"` } +// SetupAttemptPaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod. +type SetupAttemptPaymentMethodDetailsIdeal struct { + Bank string `json:"bank"` + Bic string `json:"bic"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` + IbanLast4 string `json:"iban_last4"` + VerifiedName string `json:"verified_name"` +} + +// SetupAttemptPaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod. +type SetupAttemptPaymentMethodDetailsSofort struct { + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` + IbanLast4 string `json:"iban_last4"` + PreferredLanguage string `json:"preferred_language"` + VerifiedName string `json:"verified_name"` +} + // SetupAttemptPaymentMethodDetails represents the details about the PaymentMethod associated with the setup attempt. type SetupAttemptPaymentMethodDetails struct { - Card *SetupAttemptPaymentMethodDetailsCard `json:"card"` - Type SetupAttemptPaymentMethodDetailsType `json:"type"` + Bancontact *SetupAttemptPaymentMethodDetailsBancontact `json:"bancontact"` + Card *SetupAttemptPaymentMethodDetailsCard `json:"card"` + Ideal *SetupAttemptPaymentMethodDetailsIdeal `json:"ideal"` + Sofort *SetupAttemptPaymentMethodDetailsSofort `json:"sofort"` + Type SetupAttemptPaymentMethodDetailsType `json:"type"` } // SetupAttempt is the resource representing a Stripe setup attempt. From 9c51a861494c0ca35f41776d540b869b0769e039 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 6 Oct 2020 18:56:00 -0400 Subject: [PATCH 2/3] PaymentMethod & Mandate should be a pointer --- charge.go | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/charge.go b/charge.go index 0cba1639be..b3202d1948 100644 --- a/charge.go +++ b/charge.go @@ -274,14 +274,14 @@ type ChargePaymentMethodDetailsBACSDebit struct { // ChargePaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod. type ChargePaymentMethodDetailsBancontact struct { - BankCode string `json:"bank_code"` - BankName string `json:"bank_name"` - Bic string `json:"bic"` - IbanLast4 string `json:"iban_last4"` - PreferredLanguage string `json:"preferred_language"` - VerifiedName string `json:"verified_name"` - GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` - GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + IbanLast4 string `json:"iban_last4"` + PreferredLanguage string `json:"preferred_language"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsCardChecks represents the checks associated with the charge's Card @@ -430,12 +430,12 @@ type ChargePaymentMethodDetailsGiropay struct { // ChargePaymentMethodDetailsIdeal represents details about the Ideal PaymentMethod. type ChargePaymentMethodDetailsIdeal struct { - Bank string `json:"bank"` - Bic string `json:"bic"` - IbanLast4 string `json:"iban_last4"` - VerifiedName string `json:"verified_name"` - GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` - GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` + Bank string `json:"bank"` + Bic string `json:"bic"` + IbanLast4 string `json:"iban_last4"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsInteracPresent represents details about the InteracPresent PaymentMethod. @@ -501,14 +501,14 @@ type ChargePaymentMethodDetailsSepaDebit struct { // ChargePaymentMethodDetailsSofort represents details about the Sofort PaymentMethod. type ChargePaymentMethodDetailsSofort struct { - BankCode string `json:"bank_code"` - BankName string `json:"bank_name"` - Bic string `json:"bic"` - Country string `json:"country"` - IbanLast4 string `json:"iban_last4"` - VerifiedName string `json:"verified_name"` - GeneratedSepaDebit PaymentMethod `json:"generated_sepa_debit"` - GeneratedSepaDebitMandate Mandate `json:"generated_sepa_debit_mandate"` + BankCode string `json:"bank_code"` + BankName string `json:"bank_name"` + Bic string `json:"bic"` + Country string `json:"country"` + IbanLast4 string `json:"iban_last4"` + VerifiedName string `json:"verified_name"` + GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"` + GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"` } // ChargePaymentMethodDetailsStripeAccount represents details about the StripeAccount PaymentMethod. From 186a24b3170566f10d0e0c83fd85a6bbb6f98415 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 6 Oct 2020 19:15:34 -0400 Subject: [PATCH 3/3] One more pointer --- paymentmethod.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/paymentmethod.go b/paymentmethod.go index 44f635c216..c23247f86b 100644 --- a/paymentmethod.go +++ b/paymentmethod.go @@ -336,12 +336,12 @@ type PaymentMethodSepaDebitGeneratedFrom struct { // PaymentMethodSepaDebit represents the SEPA-debit-specific properties. type PaymentMethodSepaDebit struct { - BankCode string `json:"bank_code"` - BranchCode string `json:"branch_code"` - Country string `json:"country"` - Fingerprint string `json:"fingerprint"` - Last4 string `json:"last4"` - GeneratedFrom PaymentMethodSepaDebitGeneratedFrom `json:"generated_from"` + BankCode string `json:"bank_code"` + BranchCode string `json:"branch_code"` + Country string `json:"country"` + Fingerprint string `json:"fingerprint"` + Last4 string `json:"last4"` + GeneratedFrom *PaymentMethodSepaDebitGeneratedFrom `json:"generated_from"` } // PaymentMethodSofort represents the Sofort-specific properties.