Custom – Card

  • 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

ParameterTypeMandatoryDescription
datastrYesThe data to encrypt, generally it is the card number or the card cvv.
publicKeystrYesThe 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

ParameterDescription
dataThe encrypted data

Custom – Card

Builds PgPayRequest with CARD as the payment instrument.

Parameters

ParameterTypeMandatoryDescription
authModemixedYesThe authentication mode for the card payment. Generally 3DS is used [example 3DS, H2H]
saveCardboolYesWhether to save the card for future use.
encryptedCardNumbermixedYesThe encrypted card number. You can use the EncryptedData function to encrypt unencrypted card number.
encryptionKeyIdintegerYesThe ID of the encryption key used for the card.
cardHolderNamemixedYesThe name of the cardholder.
expiryMonthmixedYesThe expiry month of the card.
expiryYearmixedYesThe expiry year of the card.
encryptedCvvmixedYesThe encrypted CVV of the card.
addressLine1mixedNoThe address line 1 for billing.
addressLine2mixedNoThe address line 2 for billing.
addressCitymixedNoThe city for billing.
addressStatemixedNoThe state for billing.
addressZipmixedNoThe ZIP code for billing.
addressCountrymixedNoThe 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();