Skip to content

Add support for BACS Debit as a PaymentMethod #1036

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

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
15 changes: 15 additions & 0 deletions src/main/java/com/stripe/model/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,9 @@ public static class Errors extends StripeObject {
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Settings extends StripeObject {
@SerializedName("bacs_debit_payments")
BacsDebitPayments bacsDebitPayments;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't have the Settings prefix because it's nested inside the Settings class as it should. It's the other ones we missed unfortunately and would need to change in a future major


@SerializedName("branding")
SettingsBranding branding;

Expand All @@ -1039,6 +1042,18 @@ public static class Settings extends StripeObject {

@SerializedName("payouts")
SettingsPayouts payouts;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class BacsDebitPayments extends StripeObject {
/**
* The Bacs Direct Debit Display Name for this account. For payments made with Bacs Direct
* Debit, this will appear on the mandate, and as the statement descriptor.
*/
@SerializedName("display_name")
String displayName;
}
}

@Getter
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/com/stripe/model/Charge.java
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,9 @@ public static class PaymentMethodDetails extends StripeObject {
@SerializedName("au_becs_debit")
AuBecsDebit auBecsDebit;

@SerializedName("bacs_debit")
BacsDebit bacsDebit;

@SerializedName("bancontact")
Bancontact bancontact;

Expand Down Expand Up @@ -1193,6 +1196,30 @@ public static class AuBecsDebit extends StripeObject {
String mandate;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class BacsDebit extends StripeObject {
/**
* Uniquely identifies this particular bank account. You can use this attribute to check
* whether two bank accounts are the same.
*/
@SerializedName("fingerprint")
String fingerprint;

/** Last four digits of the bank account number. */
@SerializedName("last4")
String last4;

/** ID of the mandate used to make this payment. */
@SerializedName("mandate")
String mandate;

/** Sort code of the bank account. (e.g., {@code 10-20-30}) */
@SerializedName("sort_code")
String sortCode;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -1398,8 +1425,7 @@ public static class ThreeDSecure extends StripeObject {
Boolean authenticated;

/**
* For authenticated transactions: whether issuing bank authenticated the cardholder with a
* traditional challenge screen, or with device data via the 3DS2 frictionless flow.
* For authenticated transactions: how the customer was authenticated by the issuing bank.
*
* <p>One of {@code challenge}, or {@code frictionless}.
*/
Expand All @@ -1416,7 +1442,8 @@ public static class ThreeDSecure extends StripeObject {
String result;

/**
* Additional information about why 3D Secure succeeded or failed.
* Additional information about why 3D Secure succeeded or failed based on the {@code
* result}.
*
* <p>One of {@code abandoned}, {@code bypassed}, {@code canceled}, {@code
* card_not_enrolled}, {@code network_not_supported}, {@code protocol_error}, or {@code
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/stripe/model/Mandate.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ public static class AuBecsDebit extends StripeObject {
String url;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class BacsDebit extends StripeObject {
@SerializedName("network_status")
String networkStatus;

@SerializedName("reference")
String reference;

@SerializedName("url")
String url;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -184,6 +198,9 @@ public static class PaymentMethodDetails extends StripeObject {
@SerializedName("au_becs_debit")
AuBecsDebit auBecsDebit;

@SerializedName("bacs_debit")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inside PaymentMethodDetails but... the others are not, so I'll just ignore and we'll fix in a major.

BacsDebit bacsDebit;

@SerializedName("card")
Card card;

Expand Down
27 changes: 25 additions & 2 deletions src/main/java/com/stripe/model/PaymentMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class PaymentMethod extends ApiResource implements HasId, MetadataStore<P
@SerializedName("au_becs_debit")
AuBecsDebit auBecsDebit;

@SerializedName("bacs_debit")
BacsDebit bacsDebit;

@SerializedName("billing_details")
BillingDetails billingDetails;

Expand Down Expand Up @@ -89,8 +92,8 @@ public class PaymentMethod extends ApiResource implements HasId, MetadataStore<P
* The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name
* matching this value. It contains additional information specific to the PaymentMethod type.
*
* <p>One of {@code au_becs_debit}, {@code card}, {@code card_present}, {@code fpx}, {@code
* ideal}, or {@code sepa_debit}.
* <p>One of {@code au_becs_debit}, {@code bacs_debit}, {@code card}, {@code card_present}, {@code
* fpx}, {@code ideal}, or {@code sepa_debit}.
*/
@SerializedName("type")
String type;
Expand Down Expand Up @@ -415,6 +418,26 @@ public static class AuBecsDebit extends StripeObject {
String last4;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class BacsDebit extends StripeObject {
/**
* Uniquely identifies this particular bank account. You can use this attribute to check whether
* two bank accounts are the same.
*/
@SerializedName("fingerprint")
String fingerprint;

/** Last four digits of the bank account number. */
@SerializedName("last4")
String last4;

/** Sort code of the bank account. (e.g., {@code 10-20-30}) */
@SerializedName("sort_code")
String sortCode;
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/stripe/model/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ public class Person extends ApiResource implements HasId, MetadataStore<Person>
@SerializedName("requirements")
Requirements requirements;

/** Whether the last 4 digits of this person's SSN have been provided. */
/**
* Whether the last four digits of the person's Social Security number have been provided (U.S.
* only).
*/
@SerializedName("ssn_last_4_provided")
Boolean ssnLast4Provided;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/stripe/model/Plan.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ public static PlanCollection list(PlanListParams params, RequestOptions options)

/**
* You can create plans using the API, or in the Stripe <a
* href="https://dashboard.stripe.com/subscriptions/products">Dashboard</a>.
* href="https://dashboard.stripe.com/products">Dashboard</a>.
*/
public static Plan create(Map<String, Object> params) throws StripeException {
return create(params, (RequestOptions) null);
}

/**
* You can create plans using the API, or in the Stripe <a
* href="https://dashboard.stripe.com/subscriptions/products">Dashboard</a>.
* href="https://dashboard.stripe.com/products">Dashboard</a>.
*/
public static Plan create(Map<String, Object> params, RequestOptions options)
throws StripeException {
Expand All @@ -231,15 +231,15 @@ public static Plan create(Map<String, Object> params, RequestOptions options)

/**
* You can create plans using the API, or in the Stripe <a
* href="https://dashboard.stripe.com/subscriptions/products">Dashboard</a>.
* href="https://dashboard.stripe.com/products">Dashboard</a>.
*/
public static Plan create(PlanCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}

/**
* You can create plans using the API, or in the Stripe <a
* href="https://dashboard.stripe.com/subscriptions/products">Dashboard</a>.
* href="https://dashboard.stripe.com/products">Dashboard</a>.
*/
public static Plan create(PlanCreateParams params, RequestOptions options)
throws StripeException {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/stripe/model/checkout/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public class Session extends ApiResource implements HasId {
* If provided, this value will be used when the Customer object is created. If not provided,
* customers will be asked to enter their email address. Use this parameter to prefill customer
* data if you already have an email on file. To access information about the customer once a
* session is complete, use the {@code customer} field.
* session is complete, use the {@code customer} attribute.
*/
@SerializedName("customer_email")
String customerEmail;

/** The line items, plans, or SKUs purchased by the customer. */
/** The line items, plans, or SKUs purchased by the customer. Prefer using {@code line_items}. */
@SerializedName("display_items")
List<Session.DisplayItem> displayItems;

Expand Down
105 changes: 105 additions & 0 deletions src/main/java/com/stripe/param/PaymentMethodCreateParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public class PaymentMethodCreateParams extends ApiRequestParams {
@SerializedName("au_becs_debit")
AuBecsDebit auBecsDebit;

/**
* If this is a {@code bacs_debit} PaymentMethod, this hash contains details about the Bacs Direct
* Debit bank account.
*/
@SerializedName("bacs_debit")
BacsDebit bacsDebit;

/**
* Billing information associated with the PaymentMethod that may be used or required by
* particular types of payment methods.
Expand Down Expand Up @@ -105,6 +112,7 @@ public class PaymentMethodCreateParams extends ApiRequestParams {

private PaymentMethodCreateParams(
AuBecsDebit auBecsDebit,
BacsDebit bacsDebit,
BillingDetails billingDetails,
Object card,
String customer,
Expand All @@ -118,6 +126,7 @@ private PaymentMethodCreateParams(
SepaDebit sepaDebit,
Type type) {
this.auBecsDebit = auBecsDebit;
this.bacsDebit = bacsDebit;
this.billingDetails = billingDetails;
this.card = card;
this.customer = customer;
Expand All @@ -139,6 +148,8 @@ public static Builder builder() {
public static class Builder {
private AuBecsDebit auBecsDebit;

private BacsDebit bacsDebit;

private BillingDetails billingDetails;

private Object card;
Expand Down Expand Up @@ -167,6 +178,7 @@ public static class Builder {
public PaymentMethodCreateParams build() {
return new PaymentMethodCreateParams(
this.auBecsDebit,
this.bacsDebit,
this.billingDetails,
this.card,
this.customer,
Expand All @@ -190,6 +202,15 @@ public Builder setAuBecsDebit(AuBecsDebit auBecsDebit) {
return this;
}

/**
* If this is a {@code bacs_debit} PaymentMethod, this hash contains details about the Bacs
* Direct Debit bank account.
*/
public Builder setBacsDebit(BacsDebit bacsDebit) {
this.bacsDebit = bacsDebit;
return this;
}

/**
* Billing information associated with the PaymentMethod that may be used or required by
* particular types of payment methods.
Expand Down Expand Up @@ -445,6 +466,87 @@ public Builder putAllExtraParam(Map<String, Object> map) {
}
}

@Getter
public static class BacsDebit {
/** Account number of the bank account that the funds will be debited from. */
@SerializedName("account_number")
String accountNumber;

/**
* Map of extra parameters for custom features not available in this client library. The content
* in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
* key/value pair is serialized as if the key is a root-level field (serialized) name in this
* param object. Effectively, this map is flattened to its parent instance.
*/
@SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
Map<String, Object> extraParams;

/** Sort code of the bank account. (e.g., {@code 10-20-30}) */
@SerializedName("sort_code")
String sortCode;

private BacsDebit(String accountNumber, Map<String, Object> extraParams, String sortCode) {
this.accountNumber = accountNumber;
this.extraParams = extraParams;
this.sortCode = sortCode;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String accountNumber;

private Map<String, Object> extraParams;

private String sortCode;

/** Finalize and obtain parameter instance from this builder. */
public BacsDebit build() {
return new BacsDebit(this.accountNumber, this.extraParams, this.sortCode);
}

/** Account number of the bank account that the funds will be debited from. */
public Builder setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}

/**
* Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
* call, and subsequent calls add additional key/value pairs to the original map. See {@link
* PaymentMethodCreateParams.BacsDebit#extraParams} for the field documentation.
*/
public Builder putExtraParam(String key, Object value) {
if (this.extraParams == null) {
this.extraParams = new HashMap<>();
}
this.extraParams.put(key, value);
return this;
}

/**
* Add all map key/value pairs to `extraParams` map. A map is initialized for the first
* `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
* See {@link PaymentMethodCreateParams.BacsDebit#extraParams} for the field documentation.
*/
public Builder putAllExtraParam(Map<String, Object> map) {
if (this.extraParams == null) {
this.extraParams = new HashMap<>();
}
this.extraParams.putAll(map);
return this;
}

/** Sort code of the bank account. (e.g., {@code 10-20-30}) */
public Builder setSortCode(String sortCode) {
this.sortCode = sortCode;
return this;
}
}
}

@Getter
public static class BillingDetails {
/** Billing address. */
Expand Down Expand Up @@ -1291,6 +1393,9 @@ public enum Type implements ApiRequestParams.EnumParam {
@SerializedName("au_becs_debit")
AU_BECS_DEBIT("au_becs_debit"),

@SerializedName("bacs_debit")
BACS_DEBIT("bacs_debit"),

@SerializedName("card")
CARD("card"),

Expand Down
Loading