Skip to content
Open
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PhonePe B2B Payment Gateway SDK for Java

[![Maven Central](https://img.shields.io/badge/Maven%20Central-v2.2.1-blue)](https://maven-badges.herokuapp.com/maven-central/com.phonepe/pg-sdk-java)
[![Maven Central](https://img.shields.io/badge/Maven%20Central-v2.2.4-blue)](https://maven-badges.herokuapp.com/maven-central/com.phonepe/pg-sdk-java)
![Java](https://img.shields.io/badge/Java-17%2B-orange)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)

Expand Down Expand Up @@ -36,7 +36,7 @@ Add the dependency to your project's POM file:
<dependency>
<groupId>com.phonepe</groupId>
<artifactId>pg-sdk-java</artifactId>
<version>2.2.3</version>
<version>2.2.4</version>
</dependency>
```

Expand All @@ -46,7 +46,7 @@ Add the following to your project's build.gradle file:

```gradle
dependencies {
implementation 'com.phonepe:pg-sdk-java:2.2.3'
implementation 'com.phonepe:pg-sdk-java:2.2.4'
}
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.phonepe</groupId>
<artifactId>pg-sdk-java</artifactId>
<version>2.2.3</version>
<version>2.2.4</version>
<name>B2B JAVA SDK</name>
<url>https://github.com/PhonePe/phonepe-pg-sdk-java</url>
<description>Phonepe PG JAVA SDK</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.phonepe.sdk.pg.common.models.response.paymentinstruments;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class CreditLinePaymentInstrumentV2 extends PaymentInstrumentV2 {

private String maskedAccountNumber;
private String ifsc;
private String accountHolderName;
private String bankId;
private String providerAccountType;

public CreditLinePaymentInstrumentV2() {
super(PaymentInstrumentType.CREDIT_LINE);
}

@Builder
public CreditLinePaymentInstrumentV2(
String maskedAccountNumber,
String ifsc,
String accountHolderName,
String bankId,
String providerAccountType) {
super(PaymentInstrumentType.CREDIT_LINE);
this.maskedAccountNumber = maskedAccountNumber;
this.ifsc = ifsc;
this.accountHolderName = accountHolderName;
this.bankId = bankId;
this.providerAccountType = providerAccountType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
@JsonSubTypes.Type(name = "NET_BANKING", value = NetBankingPaymentInstrumentV2.class),
@JsonSubTypes.Type(name = "ACCOUNT", value = AccountPaymentInstrumentV2.class),
@JsonSubTypes.Type(name = "CREDIT_CARD", value = CreditCardPaymentInstrumentV2.class),
@JsonSubTypes.Type(name = "DEBIT_CARD", value = DebitCardPaymentInstrumentV2.class)
@JsonSubTypes.Type(name = "DEBIT_CARD", value = DebitCardPaymentInstrumentV2.class),
@JsonSubTypes.Type(name = "CREDIT_LINE", value = CreditLinePaymentInstrumentV2.class)
})
@NoArgsConstructor
@Data
Expand All @@ -41,6 +42,6 @@ public PaymentInstrumentV2(PaymentInstrumentType type) {
}

public enum PaymentInstrumentType {
WALLET, EGV, ACCOUNT, CREDIT_CARD, DEBIT_CARD, NET_BANKING
WALLET, EGV, ACCOUNT, CREDIT_CARD, DEBIT_CARD, NET_BANKING, CREDIT_LINE
}
}
69 changes: 69 additions & 0 deletions src/test/CallbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.phonepe.sdk.pg.common.models.response.PaymentDetail;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.AccountPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.CreditCardPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.CreditLinePaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.DebitCardPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.EGVPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.NetBankingPaymentInstrumentV2;
Expand Down Expand Up @@ -186,6 +187,74 @@ void testPG_ORDER_FAILED() {
Assertions.assertEquals(expected, actual);
}

@Test
void testPG_ORDER_COMPLETED_withCreditLineInstrument() {
String jsonString =
"{\"event\":\"pg.order.completed\",\"payload\":"
+ "{\"orderId\":\"OMOxx\",\"paymentDetails\":"
+ "[{\"paymentMode\":\"UPI_INTENT\",\"splitInstruments\":"
+ "[{\"rail\":{\"type\":\"UPI\",\"utr\":\"utr12313\","
+ "\"upiTransactionId\":\"upi12313\","
+ "\"vpa\":\"abcd@ybl\"},\"instrument\":{\"type\":\"CREDIT_LINE\","
+ "\"ifsc\":\"AABE0000000\",\"accountHolderName\":\"accountHolderName\","
+ "\"bankId\":\"bankId\",\"maskedAccountNumber\":\"121212121212\","
+ "\"providerAccountType\":\"providerAccountType\"},\"amount\":10000}]}]}}";

CallbackResponse expected =
CallbackResponse.builder()
.event("pg.order.completed")
.payload(
CallbackData.builder()
.orderId("OMOxx")
.paymentDetails(
Arrays.asList(
PaymentDetail.builder()
.paymentMode(
PgV2InstrumentType
.UPI_INTENT)
.splitInstruments(
Arrays.asList(
InstrumentCombo
.builder()
.instrument(
CreditLinePaymentInstrumentV2
.builder()
.ifsc(
"AABE0000000")
.accountHolderName(
"accountHolderName")
.bankId(
"bankId")
.maskedAccountNumber(
"121212121212")
.providerAccountType(
"providerAccountType")
.build())
.rail(
UpiPaymentRail
.builder()
.utr(
"utr12313")
.upiTransactionId(
"upi12313")
.vpa(
"abcd@ybl")
.build())
.amount(
10000)
.build()))
.build()))
.build())
.build();
CallbackResponse actual =
standardCheckoutClient.validateCallback(
"username",
"password",
"bc842c31a9e54efe320d30d948be61291f3ceee4766e36ab25fa65243cd76e0e",
jsonString);
Assertions.assertEquals(expected, actual);
}

@Test
void testPG_TRANSACTION_ATTEMPT_FAILED() {
String jsonString =
Expand Down
74 changes: 74 additions & 0 deletions src/test/OrderStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.phonepe.sdk.pg.common.models.response.PaymentDetail;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.AccountPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.CreditCardPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.CreditLinePaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.EGVPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.NetBankingPaymentInstrumentV2;
import com.phonepe.sdk.pg.common.models.response.paymentinstruments.WalletPaymentInstrumentV2;
Expand Down Expand Up @@ -145,6 +146,79 @@ void orderStatusForSplitInstruments() {
Assertions.assertEquals(actual, responeToObject);
}

@Test
void orderStatusForCreditLineInstrument() {
Map<String, String> headers = getHeaders();
String url = String.format(StandardCheckoutConstants.ORDER_STATUS_API, merchantOrderId);
String response =
"{\"orderId\":\"OMO2402281351151884090310\",\"state\":\"COMPLETED\",\"amount\":100,"
+ "\"expireAt\":1709108893,\"paymentDetails\":[{\"transactionId\":"
+ "\"OM2402281351157894090178\",\"paymentMode\":\"UPI_INTENT\",\"timestamp\":"
+ "1709108475,\"amount\":100,\"state\":\"COMPLETED\",\"splitInstruments\":"
+ "[{\"instrument\":{\"type\":\"CREDIT_LINE\",\"ifsc\":\"AABE0000000\","
+ "\"accountHolderName\":\"accountHolderName\",\"bankId\":\"bankId\","
+ "\"maskedAccountNumber\":\"121212121212\",\"providerAccountType\":"
+ "\"providerAccountType\"},\"rail\":{\"type\":\"UPI\",\"utr\":\"utr12313\","
+ "\"upiTransactionId\":\"upi12313\",\"vpa\":"
+ "\"abcd@ybl\"},\"amount\":100}]}]}";
addStubForGetRequest(
url,
ImmutableMap.of(StandardCheckoutConstants.ORDER_DETAILS, "true"),
headers,
HttpStatus.SC_OK,
ImmutableMap.of(),
response);

OrderStatusResponse responeToObject =
OrderStatusResponse.builder()
.orderId("OMO2402281351151884090310")
.state("COMPLETED")
.amount(100)
.expireAt(1709108893L)
.paymentDetails(
Arrays.asList(
PaymentDetail.builder()
.transactionId("OM2402281351157894090178")
.paymentMode(PgV2InstrumentType.UPI_INTENT)
.timestamp(1709108475L)
.amount(100)
.state("COMPLETED")
.splitInstruments(
Arrays.asList(
InstrumentCombo.builder()
.instrument(
CreditLinePaymentInstrumentV2
.builder()
.ifsc(
"AABE0000000")
.accountHolderName(
"accountHolderName")
.bankId(
"bankId")
.maskedAccountNumber(
"121212121212")
.providerAccountType(
"providerAccountType")
.build())
.rail(
UpiPaymentRail
.builder()
.utr(
"utr12313")
.upiTransactionId(
"upi12313")
.vpa(
"abcd@ybl")
.build())
.amount(100)
.build()))
.build()))
.build();

OrderStatusResponse actual = standardCheckoutClient.getOrderStatus(merchantOrderId, true);
Assertions.assertEquals(actual, responeToObject);
}

@Test
void testTokenSuccess() {
Map<String, String> headers = getHeaders();
Expand Down
Loading
Loading