Sequence
- RSA Encrypt Data
- Custom – Card
RSA Encrypt Data
This method is used to RSA Encrypt the data with the provided public key. You need to pass two things to the encryptdata
function and returns the encrypted data using the public key shared.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
data | str | Yes | The data to encrypt, generally it is the token number or the card cvv. |
publicKey | str | Yes | The public key is provided by PhonePe that will be used for encryption. |
Example – RSA Encrypt Data
const PLUBLICKEY = "publickey"
$data= "105";
$encryptedData = $phonePePaymentsClient->encryptedData(PRODPUBLICKEY, $data);
Returns
The encrypted data.
Returns
Parameter | Description |
---|---|
data | The encrypted data |
Custom – Token
Builds PgPayRequest with Token as the payment instrument.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
authMode | str | Yes | The authentication mode for the token payment. Generally 3DS , example 3DS, H2H. |
encryptedCvv | str | Yes | The encrypted CVV of the tokenized card. You can use the EncryptedData function to encrypt unencrypted cvv. |
cryptogram | str | Yes | The cryptogram associated with the tokenized card. |
encryptedToken | str | Yes | The encrypted token representing the card. You can use the EncryptedData function to encrypt unencrypted token. |
encryptionKeyid | int | Yes | The ID of the encryption key used for the tokenized card. You can use the EncryptedData function to encrypt unencrypted encryption key id. |
expiryMonth | str | Yes | The expiry month of the tokenized card. |
expiryYear | str | Yes | The expiry year of the tokenized card. |
panSuffix | str | Yes | The last 4 digits of the tokenized card number. |
cardHolderName | str | Yes | The name of the cardholder associated with the tokenized card. |
Example (Custom – Token)
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);
$tokenCvv = "elsmatmiYs+ZzXwdO2/BXf96DoZQ2uGkkHfN34331edarer6LFhUN9GpkYYHH8ebPD4q8Fst4v4GAXAcwqzesvstaTkpfouOosWvXUR6wQDXV6yy8gwf88fR+GGMyUXjm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M0VeRXNAGRjxuo9cqWhgX5cJ7IILGycheBtEhgZli3Ji8tj6d39FHVZXq3NeKbPnyTyUU3LPUG2zuQqyxTwCNIP4LaYwf2bk8DcAIuOCK9GUxdYP3PsNPxQfuWYIHerYvAIbkPk37uzn2RndgOiMem3TP5Unnhd+f8Qo+5Qbfaw=";
$cryptogram = "69696181054119923371";
$expiryYear = "2026";
$expiryMonth = "01";
$panSuffix = "8209";
$encryptionKeyid = 20;
$authMode = "3DS";
$merchantTransactionId = "merchantTransactionId";
$request = PgPayRequestBuilder::builder()
->mobileNumber("9090909090")
->callbackUrl("https://webhook.in/test")
->merchantId(MERCHANTID)
->merchantUserId("<merchantUserId>")
->amount(<amountInPaise>)
->merchantTransactionId($merchantTransactionId)
->paymentInstrument(
InstrumentBuilder::getTokenInstrumentBuilder()
->authMode($authMode)
->encryptedCvv($tokenCvv)
->encryptedToken($encryptedToken)
->cryptogram($cryptogram)
->expiryYear($expiryYear)
->expiryMonth($expiryMonth)
->panSuffix($panSuffix)
->encryptionKeyId($encryptionKeyid)
->build()
)
->build();
$response = $phonePePaymentsClient->pay($request);
$url = $response->getInstrumentResponse()->getRedirectInfo()->getUrl();