-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds instant transfer integration as apm (#164)
* Adds instant transfer with Compay integration as apm * Update
- Loading branch information
Showing
9 changed files
with
104 additions
and
0 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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ public enum ApmType { | |
KLARNA, | ||
AFTERPAY, | ||
KASPI, | ||
INSTANT_TRANSFER, | ||
STRIPE, | ||
TOMPAY, | ||
MASLAK, | ||
|
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ public enum PaymentMethod { | |
KLARNA, | ||
AFTERPAY, | ||
KASPI, | ||
INSTANT_TRANSFER, | ||
TOMPAY, | ||
STRIPE | ||
} |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ public enum PaymentProvider { | |
PAYONEER, | ||
SODEXO, | ||
EDENRED, | ||
INSTANT_TRANSFER, | ||
ALIPAY, | ||
PAYPAL, | ||
KLARNA, | ||
|
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
11 changes: 11 additions & 0 deletions
11
src/main/java/io/craftgate/response/InstantTransferBank.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,11 @@ | ||
package io.craftgate.response; | ||
|
||
import lombok.*; | ||
|
||
@Data | ||
public class InstantTransferBank { | ||
|
||
private String bankCode; | ||
private String bankName; | ||
private String bankLogoUrl; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/io/craftgate/response/InstantTransferBanksResponse.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,12 @@ | ||
package io.craftgate.response; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
public class InstantTransferBanksResponse { | ||
|
||
private List<InstantTransferBank> items; | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
src/test/java/io/craftgate/sample/InstantTransferPaymentSample.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,70 @@ | ||
package io.craftgate.sample; | ||
|
||
import io.craftgate.Craftgate; | ||
import io.craftgate.model.*; | ||
import io.craftgate.request.InitApmPaymentRequest; | ||
import io.craftgate.request.dto.PaymentItem; | ||
import io.craftgate.response.ApmPaymentInitResponse; | ||
import io.craftgate.response.InstantTransferBank; | ||
import io.craftgate.response.InstantTransferBanksResponse; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class InstantTransferPaymentSample { | ||
|
||
private final Craftgate craftgate = new Craftgate("api-key", "secret-key", "https://sandbox-api.craftgate.io"); | ||
|
||
@Test | ||
void retrieve_active_banks() { | ||
InstantTransferBanksResponse response = craftgate.payment().retrieveActiveBanks(); | ||
assertNotNull(response.getItems()); | ||
InstantTransferBank instantTransferBank = response.getItems().get(0); | ||
assertNotNull(instantTransferBank); | ||
} | ||
|
||
@Test | ||
void init_instant_transfer_apm_payment() { | ||
List<PaymentItem> items = new ArrayList<>(); | ||
|
||
items.add(PaymentItem.builder() | ||
.name("item 1") | ||
.externalId(UUID.randomUUID().toString()) | ||
.price(BigDecimal.valueOf(0.60)) | ||
.build()); | ||
|
||
items.add(PaymentItem.builder() | ||
.name("item 2") | ||
.externalId(UUID.randomUUID().toString()) | ||
.price(BigDecimal.valueOf(0.40)) | ||
.build()); | ||
|
||
InitApmPaymentRequest request = InitApmPaymentRequest.builder() | ||
.apmType(ApmType.INSTANT_TRANSFER) | ||
.price(BigDecimal.valueOf(1)) | ||
.paidPrice(BigDecimal.valueOf(1)) | ||
.currency(Currency.TRY) | ||
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION) | ||
.conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5") | ||
.externalId("optional-externalId") | ||
.callbackUrl("https://www.your-website.com/craftgate-apm-callback") | ||
.additionalParams(new HashMap() {{ | ||
put("bankCode", "0"); | ||
}}) | ||
.items(items) | ||
.build(); | ||
|
||
ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request); | ||
assertNotNull(response.getPaymentId()); | ||
assertNull(response.getRedirectUrl()); | ||
assertNotNull(response.getHtmlContent()); | ||
assertEquals(PaymentStatus.WAITING, response.getPaymentStatus()); | ||
assertEquals(ApmAdditionalAction.SHOW_HTML_CONTENT, response.getAdditionalAction()); | ||
} | ||
} |