Skip to content

Commit

Permalink
Adds Paymob and EGP currency (#202)
Browse files Browse the repository at this point in the history
* Adds Paymob and EGP currency

* Add PaymentProvider
  • Loading branch information
reywyn authored Oct 15, 2024
1 parent 72b721f commit dda5e9a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/java/io/craftgate/model/ApmType.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ public enum ApmType {
INSTANT_TRANSFER,
STRIPE,
TOMPAY,
TOM_FINANCE,
MASLAK,
ALFABANK,
TOM_FINANCE,
PAYCELL,
HASO,
FUND_TRANSFER,
CASH_ON_DELIVERY,
METROPOL,
MULTINET,
MULTINET_GIFT,
ISPAY,
CHIPPIN
CHIPPIN,
PAYMOB,
FUND_TRANSFER,
CASH_ON_DELIVERY
}
3 changes: 2 additions & 1 deletion src/main/java/io/craftgate/model/Currency.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public enum Currency {
SAR,
BHD,
RUB,
JPY
JPY,
EGP
}
2 changes: 2 additions & 0 deletions src/main/java/io/craftgate/model/PaymentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ public enum PaymentProvider {
METROPOL,
MULTINET,
ISPAY,
CHIPPIN,
PAYMOB,
OFFLINE,
}
32 changes: 32 additions & 0 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,38 @@ void init_chippin_apm_payment() {
assertEquals(ApmAdditionalAction.WAIT_FOR_WEBHOOK, response.getAdditionalAction());
}


@Test
void init_paymob_apm_payment() {
List<PaymentItem> items = new ArrayList<>();

items.add(PaymentItem.builder()
.name("item 1")
.externalId(UUID.randomUUID().toString())
.price(BigDecimal.TEN)
.build());

InitApmPaymentRequest request = InitApmPaymentRequest.builder()
.apmType(ApmType.PAYMOB)
.price(BigDecimal.TEN)
.paidPrice(BigDecimal.TEN)
.currency(Currency.EGP)
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.conversationId("conversationId")
.externalId("externalId")
.callbackUrl("https://www.your-website.com/craftgate-apm-callback")
.items(items)
.additionalParams(new HashMap() {{
put("integrationId", "11223344");
}})
.build();

ApmPaymentInitResponse response = craftgate.payment().initApmPayment(request);
assertNotNull(response.getPaymentId());
assertEquals(PaymentStatus.WAITING, response.getPaymentStatus());
assertEquals(ApmAdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction());
}

@Test
void init_ykb_world_pay_pos_apm_payment() {
List<PaymentItem> items = new ArrayList<>();
Expand Down

0 comments on commit dda5e9a

Please sign in to comment.