Builds PgPayRequest with PayPage as the payment instrument.
Instrument Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
merchantId | mixed | Yes | The unique identifier of the merchant |
merchantTransactionId | mixed | Yes | Unique Transaction ID generated by the merchant to track requests to PhonePe. Note: – merchantTransactionId length should be less than 35 characters – No Special characters allowed except underscore “_” and hyphen “-“ |
amount | integer | Yes | The amount to be paid in paise [100 paise = 1 rupee]. |
paymentInstrument | PaymentInstrument | Yes | You can use the corresponding builder of the PaymentInstruments |
merchantUserId | str | Yes | 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 “-“ |
redirectUrl | str | Yes | The URL to which the user should be redirected after the payment is completed. |
redirectMode | str | Yes | The mode of redirection after the payment is completed. |
callbackUrl | str | Yes | The URL where PhonePe will send callback notifications after the payment is completed. |
callbackMode | str | Yes | The operating system of the device used for the payment. |
merchant_order_id | mixed | No | The unique identifier of the order |
deviceOS | PgDeviceContext | No | Represents which OS has been used by the User. |
buildPayPageInstrument
method from class InstrumentBuilder
This function directly returns the Instrument Object and no need to call the build() method on it.
Parameters
Example (Pay Page)
const $MERCHANTID="<merchantId>";
const $SALTKEY="<saltKey>";
const $SALTINDEX="<saltIndex>"
const $env=Env::UAT;
const $SHOULDPUBLISHEVENTS=true;
$phonePePaymentsClient = new PhonePePaymentClient(MERCHANTID, SALTKEY, SALTINDEX, Env::UAT, SHOLDPUBLISHEVENTS);
$merchantTransactionId = 'PHPSDK' . date("ymdHis") . "payPageTest";
$request = PgPayRequestBuilder::builder()
->mobileNumber("9999999999")
->callbackUrl("https://webhook.in/test/status")
->merchantId(MERCHANTID)
->merchantUserId("<merchantUserId>")
->amount(<amountInPaise>)
->merchantTransactionId($merchantTransactionId)
->redirectUrl("https://webhook.in/test/redirect")
->redirectMode("REDIRECT")
->paymentInstrument(InstrumentBuilder::buildPayPageInstrument())
->build();
$response = $phonePePaymentsClient->pay($request);
$url=$response->getInstrumentResponse()->getRedirectInfo()->getUrl();