Standard – Pay Page

This method is used to initiate a payment via the PhonePe PG Standard Checkout

Parameters

ParameterTypeMandatoryDescription
merchant_transaction_idstrYesThe unique transaction ID assigned by the merchant.
Note:
– merchantTransactionId length should be less than 35 characters
– No Special characters allowed except underscore “_” and hyphen “-“
amountintYesThe amount of the payment. In paise. Minimum 100 i.e. 1 rupee
merchant_user_idstrYesThe 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_urlstrYesThe UI URL to redirect the user after a successful payment.
redirect_modestrYesredirectMode should be:
● REDIRECT
● POST (Should be used only if the Merchant’s URL can handle the POST method)
callback_urlstrYesThe S2S callback URL to which status notifications will be sent.
callback_modestrYesThe mode of callback handling.
merchant_order_idstrNoThe ID of the order assigned by the merchant.

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 (Pay Page)

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.PayPageInstrumentResponse;
import com.phonepe.sdk.pg.payments.v1.models.response.PgPayResponse;
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);

String merchantTransactionId = UUID.randomUUID().toString().substring(0,34);
long amount = 100;
String callbackurl = "https://www.merchant.com/callback";
String merchantUserId = "merchantUserId";
String redirecturl="https://www.merchant.com/redirect";
String redirectMode="REDIRECT";

PgPayRequest pgPayRequest = PgPayRequest.PayPagePayRequestBuilder()
        .amount(amount)
        .merchantId(merchantId)
        .merchantTransactionId(merchantTransactionId)
        .callbackUrl(callbackurl)
        .merchantUserId(merchantUserId)
        .redirectUrl(redirectUrl)
        .redirectMode(redirectmode)
        .build();

PhonePeResponse<PgPayResponse> payResponse = phonepeClient.pay(pgPayRequest);
PayPageInstrumentResponse payPageInstrumentResponse = (PayPageInstrumentResponse) payResponse.getData().getInstrumentResponse();
String url = payPageInstrumentResponse.getRedirectInfo().getUrl();

Returns

The function returns a PhonePeResponse object with the following properties:

ParameterTypeDescription
successbooleanSuccess/failure of the request processing
codestrResponse code explaining the result
messagestrAdditional information about the response
dataPgPayResponseAvailable payment options

PgPayResponse properties

Here is the response property table for the given model:

PropertyTypeDescription
merchant_idstrThe ID of the merchant associated with the transaction.
merchant_transaction_idstrThe unique identifier of the merchant transaction.
transaction_idstrThe unique identifier of the transaction.
InstrumentResponseInstrumentResponseInstrument data used in initiating the request.