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

后端 未结 4 880
忘了有多久
忘了有多久 2020-12-09 04:55

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 u

相关标签:
4条回答
  • 2020-12-09 05:31

    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.

    0 讨论(0)
  • 2020-12-09 05:39

    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 !

    0 讨论(0)
  • 2020-12-09 05:44

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

    0 讨论(0)
  • 2020-12-09 05:48

    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&udf2=rajtufan@gmail.com&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);
     }
    

    0 讨论(0)
提交回复
热议问题