-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SEPA Direct Debit Core Support (#401)
- Loading branch information
1 parent
a5d1cea
commit 3cb3417
Showing
9 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/checkout/instruments/create/CreateInstrumentSepaRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.checkout.instruments.create; | ||
|
||
import com.checkout.common.AccountHolder; | ||
import com.checkout.common.AccountType; | ||
import com.checkout.common.InstrumentType; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
public final class CreateInstrumentSepaRequest extends CreateInstrumentRequest { | ||
|
||
@SerializedName("instrument_data") | ||
private InstrumentData instrumentData; | ||
|
||
@SerializedName("account_holder") | ||
private AccountHolder accountHolder; | ||
|
||
@Builder | ||
private CreateInstrumentSepaRequest(final InstrumentData instrumentData, | ||
final AccountHolder accountHolder) { | ||
super(InstrumentType.SEPA); | ||
this.instrumentData = instrumentData; | ||
this.accountHolder = accountHolder; | ||
} | ||
|
||
public CreateInstrumentSepaRequest() { | ||
super(InstrumentType.SEPA); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/checkout/instruments/create/CreateInstrumentSepaResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.checkout.instruments.create; | ||
|
||
import com.checkout.common.CardCategory; | ||
import com.checkout.common.CardType; | ||
import com.checkout.common.CountryCode; | ||
import com.checkout.common.InstrumentType; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
import java.time.Instant; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
public final class CreateInstrumentSepaResponse extends CreateInstrumentResponse { | ||
|
||
private final InstrumentType type = InstrumentType.SEPA; | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/checkout/instruments/create/InstrumentData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.checkout.instruments.create; | ||
|
||
import com.checkout.common.CountryCode; | ||
import com.checkout.common.Currency; | ||
import com.checkout.payments.PaymentType; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.Instant; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public final class InstrumentData { | ||
|
||
@SerializedName("account_number") | ||
private String accoountNumber; | ||
|
||
private CountryCode country; | ||
|
||
private Currency currency; | ||
|
||
@SerializedName("payment_type") | ||
private PaymentType paymentType; | ||
|
||
@SerializedName("mandate_id") | ||
private String mandateId; | ||
|
||
@SerializedName("date_of_signature") | ||
private Instant dateOfSignature; | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/checkout/instruments/get/GetSepaInstrumentResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.checkout.instruments.get; | ||
|
||
import com.checkout.common.InstrumentType; | ||
import com.checkout.instruments.create.InstrumentData; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
import java.time.Instant; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
public final class GetSepaInstrumentResponse extends GetInstrumentResponse { | ||
|
||
private final InstrumentType type = InstrumentType.SEPA; | ||
|
||
@SerializedName("created_on") | ||
private Instant createdOn; | ||
|
||
@SerializedName("modified_on") | ||
private Instant modifiedOn; | ||
|
||
@SerializedName("vault_id") | ||
private String vaultId; | ||
|
||
@SerializedName("instrument_data") | ||
private InstrumentData instrumentData; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/com/checkout/instruments/SepaInstrumentsTestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.checkout.instruments; | ||
|
||
import com.checkout.common.AccountHolder; | ||
import com.checkout.common.AccountHolderType; | ||
import com.checkout.common.Address; | ||
import com.checkout.common.CountryCode; | ||
import com.checkout.common.Currency; | ||
import com.checkout.common.Phone; | ||
import com.checkout.instruments.create.CreateInstrumentSepaRequest; | ||
import com.checkout.instruments.create.CreateInstrumentSepaResponse; | ||
import com.checkout.instruments.create.InstrumentData; | ||
import com.checkout.payments.AbstractPaymentsTestIT; | ||
import com.checkout.payments.PaymentType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class SepaInstrumentsTestIT extends AbstractPaymentsTestIT { | ||
|
||
@Test | ||
void shouldCreateInstrumentSepa() { | ||
|
||
final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() | ||
.instrumentData(InstrumentData.builder() | ||
.accoountNumber("FR7630006000011234567890189") | ||
.country(CountryCode.FR) | ||
.currency(Currency.EUR) | ||
.paymentType(PaymentType.RECURRING) | ||
.build()) | ||
.accountHolder(AccountHolder.builder() | ||
.type(AccountHolderType.INDIVIDUAL) | ||
.firstName("Ali") | ||
.lastName("Farid") | ||
.dateOfBirth("1986-01-01T00:00:00.000Z") | ||
.billingAddress(Address.builder() | ||
.addressLine1("Rue Exemple") | ||
.addressLine2("1") | ||
.city("Paris") | ||
.zip("1234") | ||
.country(CountryCode.FR) | ||
.build()) | ||
.phone(Phone.builder() | ||
.countryCode("33") | ||
.number("123456789") | ||
.build()) | ||
.build()) | ||
.build(); | ||
final CreateInstrumentSepaResponse response = blocking(() -> checkoutApi.instrumentsClient().create(request)); | ||
assertNotNull(response); | ||
assertNotNull(response.getId()); | ||
assertNotNull(response.getFingerprint()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters