ProductPayment

Get URL

URL

domain + /order/thirdFacade/balancePay/getUrlOfPaymentPage

REQUEST

PARAMETER TYPE REQUIRED MAX LENGTH DESCRIPTION EXAMPLE VALUE
merchantOrderNumber String true 64 Merchant order ID 2212150922229pch66654234
merchantUserId String true 32 Merchant's User ID 513006419990106131
amount Long true 20 Payment Amount (Currency in Kobo) 10000
reLogin String false 1 Is user re-authentication required? (Y or N) Y
businessInformation String false 255 Merchant business summary TENNPayment(0987)
merchantAppUrl String true N/A URL for frontend callback upon payment completion http://merchantAppUlr
expiryTimeInSeconds Integer false N/A If expiryTimeInSeconds is present, it will be the first. If this value is less than 300 seconds, it will be set to 300 seconds. 1200 (If the transaction is not completed within 1200 seconds, it will be closed.)
expiryTimeInHours Integer false N/A When both expiryTimeInSeconds and expiryTimeInHours are provided, expiryTimeInSeconds takes precedence. 24 (If the transaction is not completed within 24 hours, it will be closed.)

  1. 'amount': The unit of the amount parameter is in Kobo.
  2. 'reLogin': The 'reLogin' parameter defaults to 'N'. When the reLogin parameter is set to 'Y', the customer needs to login at TENN every-time. If it is 'N', after the customer completes their initial registration, their login status will be retained for 7 days. However, if the customer initiates a payment within the 7-day period, it will automatically extend the login status for another 7 days.
  3. 'merchantAppUrl': 'merchantAppUrl' is the URL we will callback in the frontend. Customers will be return to this URL after completing a payment, either by opening the merchant's application or redirecting to it. If it's an URL for HTML page, you can provide an HTTP URL. If it's a mobile APP, please provide the special URL to call it. Please note this URL is designed by the merchant. So any non-confidential information could be put in the URL for merchants better linking up to their own rest process. However, if some sensitive data needs to be presented in the URL, merchants should encrypt or confound these data by themselves to ensure data security.

RESPONSE

Implementation method

SDK

public static void main(String[] args) {
    // Create an instance of the PaymentBean with the DeepxinPayConfig implementation
    PaymentBean paymentBean = new PaymentBean(new DeepxinPayConfig() {
        @Override
        public String getMerchantCode() {
            return "Your merchant code";
        }

        @Override
        public String getPublicKey() {
            return "Your public key";
        }

        @Override
        public String getPrivateKey() {
            return "Your private key";
        }

        @Override
        public String getServerAddress() {
            return "https://tenn.deepxin.com";
        }
    });

    // Create a GetUrlOfPaymentPageParam instance
    GetUrlOfPaymentPageParam param = GetUrlOfPaymentPageParam.builder()
            .amount(10000L)
            .merchantOrderNumber("11112023101909873")
            .merchantUserId("11112023101909873008001")
            .merchantAppUrl("http://merchantappurl")
            .expiryTimeInSeconds(1200)
            .build();

    // Make a request to obtain the URL of the payment page
    R<GetUrlOfPaymentPageComplexModel> urlOfPaymentPage = paymentBean.getUrlOfPaymentPage(param);

    // Get the URL from the response data
    String url = urlOfPaymentPage.getData().getUrl();

    // Print the obtained URL
    System.out.println("Payment Page URL: " + url);
}

HTTP

public static Map<String, Object> getParamMap() {
    Map<String, Object> paramMap = new HashMap<>();
    //Required (true) the merchantOrderNumber should be unique
    paramMap.put("merchantOrderNumber", "test-20240722-105701");
    //Required (true)
    paramMap.put("merchantUserId", "test-20240722-1056-userId");
    //Required (true) Currency in Kobo
    paramMap.put("amount", 10000);
    //Required (true) URL for frontend callback upon payment completion
    paramMap.put("merchantAppUrl", "https://www.baidu.com");
    // Required (false) defalut N
    paramMap.put("reLogin", "N");
    // Required (false)
    paramMap.put("expiryTimeInSeconds", "120");
    paramMap.put("expiryTimeInHours", "1");
    paramMap.put("businessInformation", "sporty");
    return paramMap;
}
public static void main(String[] args) {
    // Replace with the merchant's public key for either the testing environment or the production environment
    String merchantPublicKey = "your public key";
    // Replace with the merchant's private key for either the testing environment or the production environment
    String merchantPrivateKey = "your private key";
    // MerchantCode
    String merchantCode = "your merchant code";
    // Parameters
    Map<String, Object> paramMap = getParamMap();
    // Encrypt the parameters using the merchant's public key.
    String encryptStr = encryptWithPublicKey(paramMap, merchantPublicKey);
    // Sign the encrypted parameters using the merchant's public key.
    String sign = sign(encryptStr, merchantPublicKey);
    // Get Request parameters
    Map<String, Object> requestMap = getRequestMap(encryptStr, merchantCode, sign);
    String requestStr = JSONUtil.toJsonStr(requestMap);
    String tennServerUrl = "https://tenn.deepxin.com/order/thirdFacade/balancePay/getUrlOfPaymentPage";
    try {
        String result = HttpUtil.post(tennServerUrl, requestStr);
        if (!JSONUtil.isTypeJSON(result)) {
            System.out.println("Result is not a JSON type.");
            return;
        }
        JSONObject entries = JSONUtil.parseObj(result);
        String toDecryptStr = entries.getStr("data");
        String responseSign = entries.getStr("sign");
        if (SUCCESS_CODE == entries.getInt("code")) {
            boolean verifySign = verify(responseSign, toDecryptStr, merchantPublicKey);
            if (verifySign) {
                String decryptStr = decryptWithPrivateKey(toDecryptStr, merchantPrivateKey);
                System.out.println(decryptStr);
            } else {
                System.out.println("Signature verification failed.");
            }
        }else{
            System.out.println(result);
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}