Builds PgPayRequest with UPI Intent as the payment instrument.
Instrument Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
targetApp | str | Yes | The target app identifier for the UPI Intent flow. For IOS: PHONEPE ,GPAY , PAYTM For Android: com.phonepe.app , net.one97.paytm |
Example (Custom – UPI Intent – ANDROID)
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") . "upiIntentPayTest";
$request = PgPayRequestBuilder::builder()
->mobileNumber("9090909090")
->callbackUrl("https://webhook.in/test")
->merchantId(MERCHANTID)
->merchantUserId("<merchantUserId>")
->amount(<amountInPaise>)
->deviceContext("Constants::IOS")
->merchantTransactionId($merchantTransactionId)
->paymentInstrument(
InstrumentBuilder::getUpiIntentInstrumentBuilder()
->targetApp("com.phonepe.com")
->build()
)
->build();
$response = $phonePePaymentsClient->pay($request);
$intentUrl = $response->getInstrumentResponse()->getIntentUrl();
Example (Custom – UPI Intent – iOS)
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);
$request = PgPayRequestBuilder::builder()
->mobileNumber("9090909090")
->callbackUrl("https://webhook.in/test")
->merchantId(MERCHANTID)
->merchantUserId("<merchantUserId>")
->amount(<amountInPaise>)
->deviceContext("Constants::IOS")
->merchantTransactionId($merchantTransactionId)
->paymentInstrument(
InstrumentBuilder::getUpiIntentInstrumentBuilder()
->targetApp("PHONEPE")
->build()
)
->build();
$response = $phonePePaymentsClient->pay($request);
$intentUrl = $response->getInstrumentResponse()->getIntentUrl();
Note
For the Intent instrument, you have to pass the deviceContext
(ANDROID[PgDeviceContextAndroid] or IOS[PgDeviceContextIos]) in the request to get app-specific intent URLs.