Skip to content

Commit

Permalink
postponing payment param added (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
beratallahverdi authored Jan 8, 2025
1 parent 80da92c commit 0040ce9
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/io/craftgate/model/Loyalty.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public class Loyalty {
private LoyaltyType type;
private Reward reward;
private String message;
private LoyaltyParams loyaltyParams;
private LoyaltyData loyaltyData;
}
11 changes: 11 additions & 0 deletions src/main/java/io/craftgate/model/LoyaltyData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.craftgate.model;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class LoyaltyData {
private Integer maxPostponingPaymentCount;
private String unitType;
}
10 changes: 10 additions & 0 deletions src/main/java/io/craftgate/model/LoyaltyParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.craftgate.model;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class LoyaltyParams {
private Integer postponingPaymentCount;
}
3 changes: 2 additions & 1 deletion src/main/java/io/craftgate/model/LoyaltyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum LoyaltyType {
POSTPONING_INSTALLMENT,
EXTRA_POINTS,
GAINING_MINUTES,
POSTPONING_STATEMENT
POSTPONING_STATEMENT,
POSTPONING_PAYMENT
}
74 changes: 74 additions & 0 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,80 @@ void create_payment_with_loyalty() {
assertEquals(new BigDecimal("3.88"), response.getLoyalty().getReward().getFirmRewardMoney());
}

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

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

items.add(PaymentItem.builder()
.name("item 2")
.externalId(UUID.randomUUID().toString())
.price(BigDecimal.valueOf(50))
.build());

items.add(PaymentItem.builder()
.name("item 3")
.externalId(UUID.randomUUID().toString())
.price(BigDecimal.valueOf(20))
.build());

CreatePaymentRequest request = CreatePaymentRequest.builder()
.price(BigDecimal.valueOf(100))
.paidPrice(BigDecimal.valueOf(100))
.walletPrice(BigDecimal.ZERO)
.installment(1)
.currency(Currency.TRY)
.conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5")
.paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION)
.paymentPhase(PaymentPhase.AUTH)
.card(Card.builder()
.cardHolderName("Haluk Demir")
.cardNumber("9792675000000002")
.expireYear("2025")
.expireMonth("06")
.cvc("000")
.loyalty(Loyalty.builder()
.type(LoyaltyType.POSTPONING_PAYMENT)
.loyaltyParams(LoyaltyParams.builder()
.postponingPaymentCount(90)
.build())
.build())
.build())
.items(items)
.build();

PaymentResponse response = craftgate.payment().createPayment(request);
assertNotNull(response.getId());
assertEquals(request.getPrice(), response.getPrice());
assertEquals(request.getPaidPrice(), response.getPaidPrice());
assertEquals(request.getWalletPrice(), response.getWalletPrice());
assertEquals(request.getCurrency(), response.getCurrency());
assertEquals(request.getInstallment(), response.getInstallment());
assertEquals(PaymentSource.API, response.getPaymentSource());
assertEquals(request.getPaymentGroup(), response.getPaymentGroup());
assertEquals(request.getPaymentPhase(), response.getPaymentPhase());
assertEquals(false, response.getIsThreeDS());
assertEquals(BigDecimal.ZERO, response.getMerchantCommissionRate());
assertEquals(BigDecimal.ZERO, response.getMerchantCommissionRateAmount());
assertEquals(false, response.getPaidWithStoredCard());
assertEquals("97926750", response.getBinNumber());
assertEquals("0002", response.getLastFourDigits());
assertEquals(CardType.CREDIT_CARD, response.getCardType());
assertEquals(CardAssociation.TROY, response.getCardAssociation());
assertEquals("KuveytTürk CC", response.getCardBrand());
assertEquals(3, response.getPaymentTransactions().size());
assertNull(response.getCardUserKey());
assertNull(response.getCardToken());
assertNull(response.getPaymentError());
assertNotNull(response.getLoyalty());
assertEquals(LoyaltyType.POSTPONING_PAYMENT, response.getLoyalty().getType());
}

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

0 comments on commit 0040ce9

Please sign in to comment.