Custom – NetBanking

  • Payment Options
  • Custom – NetBanking

Payment Options

This method is used to retrieve available payment options.

Parameters

ParameterTypeMandatoryDescription
include_net_banking_banks_listbooleanNoOptional. If set to True, the response will include the list of Net Banking banks. Default: False

For Java SDK Version <= 1.0.1, the imports should be:
from phonepe.sdk.pg.payments

For Java SDK Version > 1.0.1, the imports should be:
from phonepe.sdk.pg.payments.v1

Example – Payment Options

import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.http.PhonePeResponse;
import com.phonepe.sdk.pg.payments.v1.PhonePePaymentClient;
import com.phonepe.sdk.pg.payments.v1.models.response.PgOptionsResponse;

String merchantId = "<merchantId>";
String saltKey = "<saltKey>";
Integer saltIndex = "<saltIndex>";
Env env = Env.UAT;
boolean shouldPublishEvents = true;
PhonePePaymentClient phonepeClient = new PhonePePaymentClient(merchantId, saltKey, saltIndex, env, shouldPublishEvents);

PhonePeResponse<PgOptionsResponse> pgOptionsResponse = phonepeClient.getPaymentOptions(true);

Returns

The function returns a PhonePeResponse object with the following properties:

ParameterTypeDescription
successbooleanSuccess/failure of the request processing
codestrResponse code explaining the reason for the status
messagestrMessage providing more information about the code
dataPgOptionsResponseAvailable payment options

PgOptionsResponse Properties

PropertyTypeDescription
upi_collectPGUpiCollectUPI Collect options
intentPGIntentIntent options
cardsPGExternalCardsExternal cards options
net_bankingNetBankingOptionsResponseNet Banking options

Custom – NetBanking

This method is used to initiate a NetBanking via the PhonePe PG Custom Checkout

Parameters

ParameterTypeMandatoryDescription
merchant_transaction_idstrYesThe unique transaction ID assigned by the merchant.
Note:
– merchantTransactionId length should be less than 35 characters
– No Special characters allowed except underscore “_” and hyphen “-“
amountintYesThe amount of the payment. In paise. Minimum 100 i.e. 1 rupee
bank_idstrYesThe ID of the bank for Net Banking payment. You can find the possible values in get_payment_options response
merchant_user_idstrNoThe 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 “-“
redirect_urlstrNoThe UI URL to redirect the user after a successful payment.
redirect_modestrNoThe mode of redirection after payment completion.
callback_urlstrNoThe S2S callback URL to which status notifications will be sent.
callback_modestrNoThe mode of callback handling.
merchant_order_idstrNoThe ID of the order assigned by the merchant.
device_osstrNoThe operating system of the device used for the payment. Possible values: ANDROID or IOS.

Example (Custom – NetBanking)

import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.http.PhonePeResponse;
import com.phonepe.sdk.pg.payments.v1.PhonePePaymentClient;
import com.phonepe.sdk.pg.payments.v1.models.request.PgPayRequest;
import com.phonepe.sdk.pg.payments.v1.models.response.NetBankingInstrumentResponse;
import com.phonepe.sdk.pg.payments.v1.models.response.PgPayResponse;
import java.util.UUID;

String merchantId = "<merchantId>";
String saltKey = "<saltKey>";
Integer saltIndex = "<saltIndex>";
Env env = Env.UAT;
boolean shouldPublishEvents = true;
PhonePePaymentClient phonepeClient = new PhonePePaymentClient(merchantId, saltKey, saltIndex, env, shouldPublishEvents);

long amount = 100;
String merchantTransactionId = UUID.randomUUID().toString().substring(0,34);
String redirecturl = "https://merchant.com/redirectUrl";
String callbackurl = "https://www.merchant.com/callback";
String merchantUserId = "merchantUserId";
String bankId = "HDFC";

PgPayRequest pgPayRequest = PgPayRequest.NetBankingPayRequestBuilder()
        .amount(amount)
        .merchantId(merchantId)
        .merchantTransactionId(merchantTransactionId2)
        .callbackUrl(callbackurl)
        .redirectUrl(redirecturl)
        .merchantUserId(merchantUserId)
        .bankId(bankId)
        .build();

PhonePeResponse<PgPayResponse> payResponse = phonepeClient.pay(pgPayRequest);
NetBankingInstrumentResponse netBankingInstrumentResponse = (NetBankingInstrumentResponse) payResponse.getData().getInstrumentResponse();
String url = netBankingInstrumentResponse.getRedirectInfo().getUrl();

Returns

The pay function returns a PgPayResponse object. With NetBankingInstrumentResponse object in data.

Sample Response

{
  "success": true,
  "code": "SUCCESS",
  "message": "Your request has been successfully completed.",
  "data": {
    "upiCollect": {
      "enabled": true
    },
    "intent": {
      "enabled": true
    },
    "cards": {
      "enabled": true
    },
    "netBanking": {
      "enabled": true,
      "popularBanks": [
        {
          "bankId": "ICIC",
          "bankName": "ICICI Bank",
          "bankShortName": "ICICI",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 1
        },
        {
          "bankId": "KVBL",
          "bankName": "Karur Vysya Bank",
          "bankShortName": "Karur",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 2
        },
        {
          "bankId": "LAVB",
          "bankName": "Laxmi Vilas Bank",
          "bankShortName": "Laxmi",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 3
        }
      ],
      "allBanks": [
        {
          "bankId": "ICIC",
          "bankName": "ICICI Bank",
          "bankShortName": "ICICI",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 1
        },
        {
          "bankId": "KVBL",
          "bankName": "Karur Vysya Bank",
          "bankShortName": "Karur",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 2
        },
        {
          "bankId": "LAVB",
          "bankName": "Laxmi Vilas Bank",
          "bankShortName": "Laxmi",
          "available": "AVAILABLE",
          "accountConstraintSupported": false,
          "priority": 3
        }
      ]
    }
  }
}

Merchant’s should depend on the available parameter

  • Indicates whether the bank is currently available for Net Banking transactions. Its value will be one of the following:
    ● AVAILABLE
    ● UNAVAILABLE
    ● DEGRADED
  • Merchant’s should display the Bank to the user only if the available parameter has the value as “AVAILABLE” so avoid any know failures due to unavailability of the bank.