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 card 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 – Card
Builds PgPayRequest with CARD as the payment instrument.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
authMode | mixed | Yes | The authentication mode for the card payment. Generally 3DS is used [example 3DS, H2H] |
saveCard | bool | Yes | Whether to save the card for future use. |
encryptedCardNumber | mixed | Yes | The encrypted card number. You can use the EncryptedData function to encrypt unencrypted card number. |
encryptionKeyId | integer | Yes | The ID of the encryption key used for the card. |
cardHolderName | mixed | Yes | The name of the cardholder. |
expiryMonth | mixed | Yes | The expiry month of the card. |
expiryYear | mixed | Yes | The expiry year of the card. |
encryptedCvv | mixed | Yes | The encrypted CVV of the card. |
addressLine1 | mixed | No | The address line 1 for billing. |
addressLine2 | mixed | No | The address line 2 for billing. |
addressCity | mixed | No | The city for billing. |
addressState | mixed | No | The state for billing. |
addressZip | mixed | No | The ZIP code for billing. |
addressCountry | mixed | No | The country for billing. |
Example (Custom – Card)
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);
$authMode = "3DS";
$saveCard = true;
$encryptionKeyId = 20;
$encryptedCvv = $phonePePaymentsClient->encryptedData(PRODPUBLICKEY, "123");
$encryptedCardNumber = $phonePePaymentsClient->encryptedData(PRODPUBLICKEY, "5272559973463145");
$expiryMonth = "10";
$expiryYear = "2025";
$cardHolderName = "TEST USER";
$merchantTransactionId = "merchantTransactionId";
$request = PgPayRequestBuilder::builder()
->mobileNumber("9090909090")
->callbackUrl("https://webhook.in/test")
->merchantId(MERCHANTID)
->merchantUserId("<merchantUserId>")
->amount(<amountInPaise>)
->merchantTransactionId($merchantTransactionId)
->paymentInstrument(
InstrumentBuilder::getNewCardInstrumentBuilder()
->authMode($authMode)
->saveCard($saveCard)
->encryptedCvv($encryptedCvv)
->encryptedCardNumber($encryptedCardNumber)
->expiryMonth($expiryMonth)
->expiryYear($expiryYear)
->encryptionKeyId($encryptionKeyId)
->cardHolderName($cardHolderName)
->build()
)
->build();
$response = $phonePePaymentsClient->pay($request);
$url = $response->getInstrumentResponse()->getRedirectInfo()->getUrl();