How do I integrate the ATOM payment gateway in my app?
Asked Answered
P

4

13

I am new to Android.
I want to know how can I integrate the ATOM payment gateway mobile checkout page in my application?

I want it so that the user should fill his credit card details and pay on-line.

If I use other payment gateways, like Paytm or Payu they provide an SDK, but Atom doesn't

Any help would be appreciated

Poree answered 19/6, 2015 at 11:3 Comment(1)
I also have the same issue AFAIK, Atom doesn't provide any mobile SDKs. its a web based gateway. so is there any way to implement this in a webview in android? also what is the callback method used (e.g. Oauth). I am not a pro and dont know where to start. Please help.Bounteous
P
4

Update: Android SDK is now provided by ATOM Payment gateway.Click this to get the SDK for various platform.

PREVIOUS METHOD

Call this asynctask on Payment button click

private class StartPayment extends AsyncTask<String, Void, String> {
    String Atom2Request;

    @Override
    protected String doInBackground(String... params) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String CurrDateTime = sdf.format(new Date()).toString();
            vVenderURL = "https://paynetzuat.atomtech.in/paynetz/epi/fts?login=160&pass=Test@123&ttype=NBFundTransfer&prodid=NSE&amt=50&txncurr=INR&txnscamt=0&clientcode=TkFWSU4%3d&txnid=123&date=03/07/2015&custacc=1234567890&udf1=Customer&[email protected]&udf3=8485835654&udf4=pune&ru=http://example.webservice/response.aspx?";

        Log.d("Vvendor URL", vVenderURL);
        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(vVenderURL); // getting XML
        Document doc = parser.getXMLElement(xml); // getting DOM element
        Log.d("XML URL", xml);
        NodeList nList = doc.getElementsByTagName(KEY_RESPONSE);

        for (int tempN = 0; tempN < nList.getLength(); tempN++) {
            Node nNode = nList.item(tempN);
            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;
                System.out.println("URL : " + eElement.getElementsByTagName("url").item(0).getChildNodes().item(0).getNodeValue());
                xmlURL = eElement.getElementsByTagName("url").item(0).getChildNodes().item(0).getNodeValue();

                NodeList aList = eElement.getElementsByTagName("param");
                String vParamName;
                for (int atrCnt = 0; atrCnt < aList.getLength(); atrCnt++) {
                    vParamName = aList.item(atrCnt).getAttributes().getNamedItem("name").getNodeValue();
                    System.out.println("<br>paramName : : " + vParamName);

                    if (vParamName.equals("ttype")) {
                        xmlttype = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("tempTxnId")) {
                        xmltempTxnId = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("token")) {
                        xmltoken = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("txnStage")) {
                        xmltxnStage = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    }
                }
                Log.d("XML URL", xmlURL);
                Log.d("XML TRANS TYPE", xmlttype);
                Log.d("tempTxnId : ", xmltempTxnId);
                Log.d("param : token     :", xmltoken);
                Log.d("param : txnStage  : ", xmltxnStage);
            }
        }//for

        Atom2Request = xmlURL + "?ttype=" + xmlttype + "&tempTxnId=" + xmltempTxnId + "&token=" + xmltoken + "&txnStage=" + xmltxnStage;
        Atom2Request = Atom2Request.replace(" ", "%20");
        Log.d("ATOM 2nd Request URl", Atom2Request);


        return Atom2Request;
    }

    @Override
    protected void onPostExecute(String result) {
        if (pDialog != null) {
            pDialog.dismiss();
            Intent intent = new Intent(Recharge_Activity.this, WebContent.class);
            intent.putExtra(KEY_ATOM2REQUEST, result);
            startActivityForResult(intent, 3);
        }

    }

    @Override
    protected void onPreExecute() {
        pDialog.setMessage("Processing Request...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
        super.onPreExecute();
    }


}

when we got response from web page we have form a url and transfer to

WebContent.class

 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.util.Log;
 import android.webkit.JavascriptInterface;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;



 public class WebContent extends Activity {
  private static final String TAG = "WebContent";
  SharedPreferences sp;
  static Context mContext;
  public static final String KEY_ATOM2REQUEST = "Atom2Request";
  String Atom2Request;
Intent intent;
boolean loadingFinished = true;
boolean redirect = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webviewrecharge);
  //  Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    mContext = this;
    Bundle extras = getIntent().getExtras();
    if (extras != null)
        Atom2Request = extras.getString(KEY_ATOM2REQUEST);
    Log.d("ATOM2Request webview", Atom2Request);
    WebView webView = (WebView) findViewById(R.id.webView);
    webView.setWebViewClient(new MyWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.addJavascriptInterface(new WebAppInterface(this), "Android");

    webView.loadUrl(Atom2Request);
}

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
        if (!loadingFinished) {
            redirect = true;
        }

        loadingFinished = false;
        view.loadUrl(urlNewString);
        return true;
    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap facIcon) {
        loadingFinished = false;
        //SHOW LOADING IF IT ISNT ALREADY VISIBLE
        Log.w(TAG, "Loading");
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        if (!redirect) {
            loadingFinished = true;
        }

        if (loadingFinished && !redirect) {
            //HIDE LOADING IT HAS FINISHED
            Log.w(TAG, "Finish Loading");
        } else {
            redirect = false;
        }

    }
}
public class WebAppInterface {
    Context mContext;
    WebAppInterface(Context c) {
        mContext = c;
    }
    @JavascriptInterface
    public void onResponse(String reponseText) {
        Intent returnIntent = new Intent();
        returnIntent.putExtra("Result", reponseText);
        setResult(RESULT_OK, returnIntent);
        finish();

    }
}

}

//in vVendorURl you need a redirect url to fetch request from ATOM and send response to android Mobile

Just put this code inside redirect url

//reponseText is text recevied frm ATOM that is Okay or No

in vVendorUrl you have to pass a return url..make a page in server ..and put this java script code inside url.

<script type="text/javascript">
 function showAndroidToast(reponseText) {
 Android.onResponse(reponseText);
 }

Poree answered 22/1, 2016 at 5:37 Comment(8)
I'm doing payment using your code. But unable to get the response from atom. you have mention the javascript code here. I don't know how will i use it. Plz helpCoveney
that javascript code helps you to get response from server..put that code in a webpage ..and save it in live server ....in Vvendor url last parameter is ru put that server url in ru..thats itPoree
can i get ur email id or phone no plz. it will be a big favour.Coveney
I have kept your code inside a server and redirect to vVendorURI. But not getting anything.Only processing page ...Coveney
check your vVendor url in browser does it return any xml ...and than check Atom2Request does it forms urlPoree
yah Atom2Request forming url. And i'm getting the bank payment gateway with success transaction but with return url is creating problem. confused with that.Coveney
Hello I am getting same problem. I am not able to get how to put that javascript code and how to use it.. Can u please help me @Poree ?? Currently I am getting Simulate transaction page from where i can success or fail transaction. But after that I am stuck on Processing page. What is my mistake please help me..Mayne
@Poree we have created php page at server side and put this javascript code inside it. But the problem is from php side its not able to parse. If they pass simple static string, I am able to get android side but the response get from Atom is not able to parse at php side and even i m not able to get android side..Mayne
O
5

According to this,no java and/or android SDK is provided by them. You can still click the "contact us" button(in the bottom of the webpage) and ask them directly weather they provide any SDK for java/android or not.

Update: Android SDK is now provided by ATOM Payment gateway.Click this to get the same.

Olympe answered 30/6, 2015 at 6:7 Comment(2)
Now, the given link is provided the SDK of different platform including java and Android. You should Update your answerIsocracy
Thanks mate.Updated.Olympe
P
4

Update: Android SDK is now provided by ATOM Payment gateway.Click this to get the SDK for various platform.

PREVIOUS METHOD

Call this asynctask on Payment button click

private class StartPayment extends AsyncTask<String, Void, String> {
    String Atom2Request;

    @Override
    protected String doInBackground(String... params) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String CurrDateTime = sdf.format(new Date()).toString();
            vVenderURL = "https://paynetzuat.atomtech.in/paynetz/epi/fts?login=160&pass=Test@123&ttype=NBFundTransfer&prodid=NSE&amt=50&txncurr=INR&txnscamt=0&clientcode=TkFWSU4%3d&txnid=123&date=03/07/2015&custacc=1234567890&udf1=Customer&[email protected]&udf3=8485835654&udf4=pune&ru=http://example.webservice/response.aspx?";

        Log.d("Vvendor URL", vVenderURL);
        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(vVenderURL); // getting XML
        Document doc = parser.getXMLElement(xml); // getting DOM element
        Log.d("XML URL", xml);
        NodeList nList = doc.getElementsByTagName(KEY_RESPONSE);

        for (int tempN = 0; tempN < nList.getLength(); tempN++) {
            Node nNode = nList.item(tempN);
            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;
                System.out.println("URL : " + eElement.getElementsByTagName("url").item(0).getChildNodes().item(0).getNodeValue());
                xmlURL = eElement.getElementsByTagName("url").item(0).getChildNodes().item(0).getNodeValue();

                NodeList aList = eElement.getElementsByTagName("param");
                String vParamName;
                for (int atrCnt = 0; atrCnt < aList.getLength(); atrCnt++) {
                    vParamName = aList.item(atrCnt).getAttributes().getNamedItem("name").getNodeValue();
                    System.out.println("<br>paramName : : " + vParamName);

                    if (vParamName.equals("ttype")) {
                        xmlttype = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("tempTxnId")) {
                        xmltempTxnId = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("token")) {
                        xmltoken = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    } else if (vParamName.equals("txnStage")) {
                        xmltxnStage = aList.item(atrCnt).getChildNodes().item(0).getNodeValue();
                    }
                }
                Log.d("XML URL", xmlURL);
                Log.d("XML TRANS TYPE", xmlttype);
                Log.d("tempTxnId : ", xmltempTxnId);
                Log.d("param : token     :", xmltoken);
                Log.d("param : txnStage  : ", xmltxnStage);
            }
        }//for

        Atom2Request = xmlURL + "?ttype=" + xmlttype + "&tempTxnId=" + xmltempTxnId + "&token=" + xmltoken + "&txnStage=" + xmltxnStage;
        Atom2Request = Atom2Request.replace(" ", "%20");
        Log.d("ATOM 2nd Request URl", Atom2Request);


        return Atom2Request;
    }

    @Override
    protected void onPostExecute(String result) {
        if (pDialog != null) {
            pDialog.dismiss();
            Intent intent = new Intent(Recharge_Activity.this, WebContent.class);
            intent.putExtra(KEY_ATOM2REQUEST, result);
            startActivityForResult(intent, 3);
        }

    }

    @Override
    protected void onPreExecute() {
        pDialog.setMessage("Processing Request...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
        super.onPreExecute();
    }


}

when we got response from web page we have form a url and transfer to

WebContent.class

 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.util.Log;
 import android.webkit.JavascriptInterface;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;



 public class WebContent extends Activity {
  private static final String TAG = "WebContent";
  SharedPreferences sp;
  static Context mContext;
  public static final String KEY_ATOM2REQUEST = "Atom2Request";
  String Atom2Request;
Intent intent;
boolean loadingFinished = true;
boolean redirect = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webviewrecharge);
  //  Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    mContext = this;
    Bundle extras = getIntent().getExtras();
    if (extras != null)
        Atom2Request = extras.getString(KEY_ATOM2REQUEST);
    Log.d("ATOM2Request webview", Atom2Request);
    WebView webView = (WebView) findViewById(R.id.webView);
    webView.setWebViewClient(new MyWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.addJavascriptInterface(new WebAppInterface(this), "Android");

    webView.loadUrl(Atom2Request);
}

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
        if (!loadingFinished) {
            redirect = true;
        }

        loadingFinished = false;
        view.loadUrl(urlNewString);
        return true;
    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap facIcon) {
        loadingFinished = false;
        //SHOW LOADING IF IT ISNT ALREADY VISIBLE
        Log.w(TAG, "Loading");
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        if (!redirect) {
            loadingFinished = true;
        }

        if (loadingFinished && !redirect) {
            //HIDE LOADING IT HAS FINISHED
            Log.w(TAG, "Finish Loading");
        } else {
            redirect = false;
        }

    }
}
public class WebAppInterface {
    Context mContext;
    WebAppInterface(Context c) {
        mContext = c;
    }
    @JavascriptInterface
    public void onResponse(String reponseText) {
        Intent returnIntent = new Intent();
        returnIntent.putExtra("Result", reponseText);
        setResult(RESULT_OK, returnIntent);
        finish();

    }
}

}

//in vVendorURl you need a redirect url to fetch request from ATOM and send response to android Mobile

Just put this code inside redirect url

//reponseText is text recevied frm ATOM that is Okay or No

in vVendorUrl you have to pass a return url..make a page in server ..and put this java script code inside url.

<script type="text/javascript">
 function showAndroidToast(reponseText) {
 Android.onResponse(reponseText);
 }

Poree answered 22/1, 2016 at 5:37 Comment(8)
I'm doing payment using your code. But unable to get the response from atom. you have mention the javascript code here. I don't know how will i use it. Plz helpCoveney
that javascript code helps you to get response from server..put that code in a webpage ..and save it in live server ....in Vvendor url last parameter is ru put that server url in ru..thats itPoree
can i get ur email id or phone no plz. it will be a big favour.Coveney
I have kept your code inside a server and redirect to vVendorURI. But not getting anything.Only processing page ...Coveney
check your vVendor url in browser does it return any xml ...and than check Atom2Request does it forms urlPoree
yah Atom2Request forming url. And i'm getting the bank payment gateway with success transaction but with return url is creating problem. confused with that.Coveney
Hello I am getting same problem. I am not able to get how to put that javascript code and how to use it.. Can u please help me @Poree ?? Currently I am getting Simulate transaction page from where i can success or fail transaction. But after that I am stuck on Processing page. What is my mistake please help me..Mayne
@Poree we have created php page at server side and put this javascript code inside it. But the problem is from php side its not able to parse. If they pass simple static string, I am able to get android side but the response get from Atom is not able to parse at php side and even i m not able to get android side..Mayne
L
2

Now atom provide the SDK for various platform. You can download this from it's website atomtech

Loath answered 15/2, 2017 at 6:27 Comment(1)
I am not able to add .jar file in my ReferencesBeverie
S
1

How does a Merchant Integrate with atom Online Payment Gateway?

  1. A merchant first needs to Sign Up with atom Online Payment Gateway-atom Paynetz.
  2. Once a customer wants to make a payment to the merchant, the merchant sends an EPI request to atom Paynetz.
  3. The EPI request facilitates a transfer of funds between the customer and merchant via Paynetz.
  4. The Paynetz platform validates the merchant and responds with an XML payload if successful.
  5. Based on the parameters in the XML, the merchant site has to send a new EPI request to Paynetz by parsing the XML response.
  6. The list of banks approved for the merchant will be displayed for selection on the Paynetz system, which is redirected to the customer.
  7. The customer then chooses the bank through which he/she wishes to do the payment.
  8. The EPI redirects the customer to the corresponding bank’s net banking interface. The customer can now complete the transaction.

PHP code for ATOM integration :

1.Create a form

<?php
if ($testmode)
{
$url = ‘http://203.114.240.77/paynetz/epi/fts';// test bed URL
$port = 80;
$atom_prod_id = “NSE”;
}
else
{
$url = ‘https://payment.atomtech.in/paynetz/epi/fts';//live URL
$port = 443;
$atom_prod_id = “ESDS”;
}

// code to generate token
$param = “&login=”.$userid.”&pass=”.$password.”&ttype=NBFundTransfer&prodid=”.$atom_prod_id.”&amt=”.$amount.”&txncurr=INR&txnscamt=0&clientcode=”.$clientcode.”&txnid=”.$invoiceid.”&date=”.$today.”&custacc=12345″;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT , $port);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
$returnData = curl_exec($ch);

// Check if any error occured
if(curl_errno($ch))
{
echo ‘Curl error: ‘ . curl_error($ch);
}
curl_close($ch);

$xmlObj = new SimpleXMLElement($returnData);
$final_url = $xmlObj->MERCHANT->RESPONSE->url;
// eof code to generate token
// code to generate form action
$param = “”;
$param .= “&ttype=NBFundTransfer”;
$param .= “&tempTxnId=”.$xmlObj->MERCHANT->RESPONSE->param[1];
$param .= “&token=”.$xmlObj->MERCHANT->RESPONSE->param[2];
$param .= “&txnStage=1″;
$url = $url.”?”.$param;
// eof code to generate form action
?>
<form action='<?php echo $url?>’ method=’post’>
<input type=’submit’ value=’Pay Now’ name=’btn_pay’ />
</form>

Step 2. Handling Response

<?php
// log post data
$orgipn = ”;
foreach ($_POST as $key => $value)
{
$orgipn .= (” . $key . ‘ => ‘ . $value . ‘
‘);
}
// eof log post data

if($_POST[‘f_code’]==”Ok”) // atom status
{
$invoiceid = $_POST[‘mer_txn’];
$amount = $_POST[‘amt’];
$transid = $_POST[‘mmp_txn’];

// add your transaction

}
?>

There are extensions available which are paid as well as free ones whose codes are available.

Hope this was helpful !

Snide answered 30/6, 2015 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.