generate merchant reference in payfort payment gateway

3.5k views Asked by At

I am integrating payfort payment gateway in my android application. I have generate token using rest api https://sbpaymentservices.payfort.com/FortAPI/paymentApi and now I have to pass that token to fort sdk for the transaction.

But Merchant reference also needs to generated to pass into the fort sdk. I can't find anything on how to generate merchant reference as anything not given in the payfort documentation.

I have also talk to the support , they said we have to create merchant reference by our own alogrithm

Can anybody know how to create merchant reference ?? Any help would be greatly appreciated

String device_id = FortSdk.getDeviceId(this);
    Log.e("device_iddd",device_id+"");
    Map<String, String> map = new HashMap<>();
    map.put("command", "AUTHORIZATION");
    map.put("amount",String.valueOf(1));
    map.put("language", "en");
    map.put("merchant_reference", "r1FANA78-ok00tH0");
    map.put("currency","SAR");
    map.put("customer_name", "bharat");
    map.put("customer_email", "[email protected]");
    map.put("order_description", "Description");
    map.put("return_url", "http://faza.fazadigital.com/Faza_WS/payfortReturnPage.php");
    map.put("sdk_token", "441E41CFFF2E49F2E053321E320A4884");

    fortRequest.setRequestMap(map);
    try {
        FortSdk.getInstance().registerCallback(this, fortRequest, FortSdk.ENVIRONMENT.TEST, 10, fortCallback, new FortInterfaces.OnTnxProcessed() {
            @Override
            public void onCancel(Map<String, String> requestParamsMap, Map<String, String> responseMap) {
                showProgress(false);
                for (Map.Entry<String, String> entry : responseMap.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    Log.e("cancel", key + "////////" + value);
                    // do stuff
                }
            }

            @Override
            public void onSuccess(Map<String, String> requestParamsMap, Map<String, String> fortResponseMap) {
                for (Map.Entry<String, String> entry : fortResponseMap.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    Log.e("responsee", key + "////////" + value);
                    // do stuff
                }
            }

            @Override
            public void onFailure(Map<String, String> requestParamsMap, Map<String, String> fortResponseMap) {
                for (Map.Entry<String, String> entry : fortResponseMap.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    Log.e("failure", key + "////////" + value);
                    // do stuff
                }
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
1

There are 1 answers

8
Ready Android On BEST ANSWER

As in your code you are using merchant_reference as a static value but merchant_refernce should not be static it should be a unique value every time as system current time in milliseconds String.valueOf(System.currentTimeMillis());

Your merchant identifier and access code value should be same always which are generated at the time of registration at the PayFort. These are on the basis of merchant registration and unique for every registered user.