Sequence
- Validate VPA
- Custom – UPI Collect
Validate VPA
Used to check if the given VPA is valid or not.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
vpa | str | Yes | The Virtual Payment Address (VPA) for the payment. |
For Java SDK Version <= 1.0.1, the imports should be:
from phonepe.sdk.pg.payments
For Java SDK Version > 1.0.1, the imports should be:
from phonepe.sdk.pg.payments.v1
Example – Valid VPA
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.http.PhonePeResponse;
import com.phonepe.sdk.pg.payments.v1.PhonePePaymentClient;
import com.phonepe.sdk.pg.payments.v1.models.response.VpaValidateResponse;
String merchantId = "<merchantId>";
String saltKey = "<saltKey>";
Integer saltIndex = "<saltIndex>";
Env env = Env.UAT;
boolean shouldPublishEvents = true;
PhonePePaymentClient phonepeClient = new PhonePePaymentClient(merchantId, saltKey, saltIndex, env, shouldPublishEvents);
String vpa = "abc@ybl";
PhonePeResponse<VpaValidateResponse> vpaValidateResponse = phonepeClient.validateVpa(vpa);
String vpaName = vpaValidateResponse.getData().getName();
Returns
The function returns a VpaValidateResponse object with the following properties:
Parameter | Type | Description |
---|---|---|
success | boolean | Success/failure of the request processing |
code | str | Response code explaining the reason for the status |
message | str | Message providing more information about the code |
data | VpaValidateResponse | Information about the VPA |
VpaValidateResponse Properties
Property | Type | Description |
---|---|---|
vpa | str | The VPA sent in the request. |
name | str | The name linked to the VPA. |
Custom – UPI Collect
This method is used to initiate a UPI Collect via the PhonePe PG Custom Checkout
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
merchant_transaction_id | str | Yes | The unique transaction ID assigned by the merchant. Note: – merchantTransactionId length should be less than 35 characters – No Special characters allowed except underscore “_” and hyphen “-“ |
amount | int | Yes | The amount of the payment. In paise. Minimum 100 i.e. 1 rupee |
vpa | str | Yes | The Virtual Payment Address (VPA) for the payment. |
merchant_user_id | str | No | The ID assigned to the user by the merchant. Note: – merchantUserId length should be less than 36 characters – No Special characters allowed except underscore “_” and hyphen “-“ |
redirect_url | str | No | The UI URL to redirect the user after a successful payment. |
redirect_mode | str | No | The mode of redirection after payment completion. |
callback_url | str | No | The S2S callback URL to which status notifications will be sent. |
callback_mode | str | No | The mode of callback handling. |
merchant_order_id | str | No | The ID of the order assigned by the merchant. |
device_os | str | No | The operating system of the device used for the payment. Possible values: ANDROID or IOS. |
Example (Custom – UPI Collect)
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.http.PhonePeResponse;
import com.phonepe.sdk.pg.payments.v1.PhonePePaymentClient;
import com.phonepe.sdk.pg.payments.v1.models.request.PgPayRequest;
import com.phonepe.sdk.pg.payments.v1.models.response.PgPayResponse;
import com.phonepe.sdk.pg.payments.v1.models.response.UpiCollectInstrumentResponse;
import java.util.UUID;
String merchantId = "<merchantId>";
String saltKey = "<saltKey>";
Integer saltIndex = "<saltIndex>";
Env env = Env.UAT;
boolean shouldPublishEvents = true;
PhonePePaymentClient phonepeClient = new PhonePePaymentClient(merchantId, saltKey, saltIndex, env, shouldPublishEvents);
long amount = 100;
String merchantTransactionId = UUID.randomUUID().toString().substring(0,34);
String redirecturl = "https://merchant.com/redirectUrl";
String callbackurl = "https://www.merchant.com/callback";
String merchantUserId = "merchantUserId";
String vpa="abc@ybl";
PgPayRequest pgPayRequest = PgPayRequest.UPICollectPayRequestBuilder()
.amount(amount)
.merchantId(merchantId)
.merchantTransactionId(merchantTransactionId)
.callbackUrl(callbackurl)
.redirectUrl(redirecturl)
.merchantUserId(merchantUserId)
.vpa(vpa)
.build();
PhonePeResponse<PgPayResponse> payResponse = phonepeClient.pay(pgPayRequest);
UpiCollectInstrumentResponse upiCollectInstrumentResponse = (UpiCollectInstrumentResponse) payResponse.getData().getInstrumentResponse();
Returns
The pay function returns a PgPayResponse object. With UpiCollectInstrumentResponse object in data.