Невозможно создать и отправить ссылку на запрос с помощью PayTM Создать ссылку API - PullRequest
0 голосов
/ 18 октября 2019

https://developer.paytm.com/docs/create-link-api/

Спасибо заранее, я пытаюсь создать и отправить ссылку на запрос платежа PayTM с помощью API PayTM Crate Link, но я всегда получаю это:

{"head":{"version":"v2","timestamp":"18/10/2019 19:44:05","channelId":null,"signature":null,"tokenType":null,"clientId":null},"body":{"resultInfo":{"resultStatus":"FAILED","resultCode":"502","resultMessage":"Something bad happened."}}}

    String MERCHANT_MID = "xxxxxxxxx";
    String MERCHANT_KEY = "xxxxxxxxxx";

    TreeMap<String,String> customerParams = new TreeMap<>();
    TreeMap<String,String> paytmParams = new TreeMap<>();
    TreeMap<String,String> headDataParams = new TreeMap<>();
    TreeMap<String,String> postDataParams = new TreeMap<>();

    customerParams.put("customerName","xxxxxxxx");
    customerParams.put("customerMobile","xxxxxxxx");
    customerParams.put("customerEmail","xxxxxxxx");


    paytmParams.put("linkDescription", "this is only testing link");
    paytmParams.put("amount", "100.00");
    paytmParams.put("MID", "xxxxxxxx");
    paytmParams.put("sendEmail", "true");
    paytmParams.put("isActive", "true");
    paytmParams.put("merchantRequestId", "1001");
    paytmParams.put("customerContact",customerParams.toString());
    paytmParams.put("linkName", "ProTest");
    paytmParams.put("linkType", "FIXED");
    paytmParams.put("sendSms", "true");
    paytmParams.put("expiryDate",LocalDateTime.now().plusDays(1).toString());

    String checksum = CheckSumServiceHelper.getCheckSumServiceHelper().genrateCheckSum(MERCHANT_KEY,paytmParams.toString());

    headDataParams.put("version","v1");
    headDataParams.put("clientId","C11");
    headDataParams.put("tokenType","AES");
    headDataParams.put("channelId","WEB");
    headDataParams.put("timestamp",Instant.now().toEpochMilli()+"");
    headDataParams.put("signature",checksum);

    postDataParams.put("body",paytmParams.toString());
    postDataParams.put("head",headDataParams.toString());

    String postData = postDataParams.toString();

    //      String paytmParams = "{"+"linkDescription"+":"+"this is only testing link..."+","+"amount"+":"+ "1.00"+","+"sendEmail"+":"+"true"+","+"isActive"+":"+"true"+","+"mid"+":"+"rXuOZS03944105540972"+","+"merchantRequestId"+":"+"1001"+","+"customerContact"+": {"+"customerName"+":"+"chandan"+","+"customerMobile"+":"+"+919583632512"+","+"customerEmail"+":"+"chandan.nayak777@gmail.com"+"},"+"linkName"+":"+"ProTest"+","+"linkType"+":"+"FIXED"+","+"sendSms"+":"+"true"+","+"expiryDate"+":"+"11/04/2020"+"}";
    //      String checksum = CheckSumServiceHelper.getCheckSumServiceHelper().genrateCheckSum(MERCHANT_KEY, paytmParams);
    //      String post_data = "{"+"body"+":"+paytmParams+","+"head"+":"+"{"+"version"+":"+"v1"+","+"clientId"+":"+"C11"+","+"tokenType"+":"+"AES"+","+"channelId"+":"+"WEB"+","+"timestamp"+":"+"1571387225179"+","+"signature"+":"+checksum+"}}";

    //  for staging
    URL url = new URL("https://securegw-stage.paytm.in/link/create");
    //  for production
    //  URL url = new URL("https://securegw.paytm.in/link/create");

    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setRequestMethod("POST");
        connection.connect();

        System.out.println("//////////"+postData.toString());

        byte[] outputBytes = postData.toString().getBytes("UTF-8");
        OutputStream os = connection.getOutputStream();
        os.write(outputBytes);
        os.close();

        String response = "";
        InputStream is = connection.getInputStream();
        BufferedReader responseReader = new BufferedReader(new InputStreamReader(is));
        if ((response = responseReader.readLine()) != null) {
            System.out.append("Response : " + response+"");
        }
        responseReader.close();
    } catch (Exception exception) {
        exception.printStackTrace();
    }
...