支付处理集成的android [英] Payment processing Integration android

查看:112
本文介绍了支付处理集成的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做我的第一个应用程序。现在我需要使用自定义浏览器payu一体化整合应用。我没有关于如何做这方面的知识。我搜索了这一点,但我失败了。请任何一个建议我还是给我提供链接的这种集成。预先感谢您。

I am doing my first application. Now i need to integrate payu integration in app using custom browser. i don't have knowledge on how to do this. I searched for this, but i failed. please any one suggest me or provide me links for this integration. thank you in advance.

是这样的:

<一个href=\"https://drive.google.com/folderview?id=0B4URmsDLhGXmfjFmbDQ5b2V0bVhjdTZMNExMVHRFMG1PRFFYeUV0LU9nSWU4U0pqaW00OU0&usp=drive_web&ddrp=1#\" rel=\"nofollow\">https://drive.google.com/folderview?id=0B4URmsDLhGXmfjFmbDQ5b2V0bVhjdTZMNExMVHRFMG1PRFFYeUV0LU9nSWU4U0pqaW00OU0&usp=drive_web&ddrp=1#

推荐答案

虽然我只好从自己至少尝试一次,有很多可用反正这是payu在app.It整合完整的解决方案做题很简单

Although u have to try at least once from yourself there are lot of SO questions available anyways this is complete solution to integrate payu in your app.It is very simple.

首先定义的变量喜欢这样的:

First define your variables likes this:

String hash,hashSequence;
String post_Data;
String merchant_key="your key";
String salt="your salt";
String surl = "your surl"; 
String furl = "your furl";
String productinfo = "your product info or you can put anything here";
String txnid ="";
String amount;
Handler mHandler = new Handler();
String firstname, email,phone;
WebView webView ;

定义值后您的CreateView的应该是这样的:

After defining values your on createview should be like this:

@SuppressLint("JavascriptInterface")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.web_view);

        webView = (WebView) findViewById(R.id.webView);

        String hashSequence1 = merchant_key + "|" + txnid + "|" + amount + "|" + productinfo + "|" +
                               firstname+  "|" + email + "|||||||||||" + salt;

        hash=hashCal("SHA-512",hashSequence1);

        webView.setWebViewClient(new WebViewClient() {


            @Override
            public void onReceivedError(WebView view, int errorCode,
                                        String description, String failingUrl) {
                // TODO Auto-generated method stub
                System.out.println(">>>>>>>>>>>>>>onReceivedError>>>>>>>>>>>>>>>>>>");
                Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onReceivedSslError(WebView view,
                                           SslErrorHandler handler, SslError error) {
                // TODO Auto-generated method stub
                System.out.println(">>>>>>>>>>>>>>onReceivedSslError>>>>>>>>>>>>>>>>>>");
                Toast.makeText(activity, "SslError! " + error, Toast.LENGTH_SHORT).show();
                handler.proceed();
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                System.out.println(">>>>>>>>>>>>>>shouldOverrideUrlLoading>>>>>>>>>>>>>>>>>>");
                return true;

            }

            @Override
            public void onPageFinished(WebView view, String url) {
                // TODO Auto-generated method stub
                System.out.println(">>>>>>>>>>>>>>onPageFinished>>>>>>>>>>>>>>>>>>");

                super.onPageFinished(view, url);

            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                System.out.println(">>>>>>>>>>>>>>onPageStarted>>>>>>>>>>>>>>>>>>");
            }
        });


        webView.setVisibility(View.VISIBLE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setCacheMode(2);
        webView.getSettings().setDomStorageEnabled(true);
        webView.clearHistory();
        webView.clearCache(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLoadWithOverviewMode(true);

        webView.addJavascriptInterface(new PayUJavaScriptInterface(this), "PayUMoney");

         post_Data = "hash="+hash+"&key="+merchant_key+"&txnid="+txnid+"&amount="+amount+
                "&productinfo="+productinfo+"&firstname="+firstname+ "&email="+email+"&phone="+phone+
                "&surl="+surl+"&furl="+ furl+ "&service_provider="+ "payu_paisa";

        webView.postUrl("https://secure.payu.in/_payment", EncodingUtils.getBytes(post_Data, "base64"));


    }

PayUJavaScriptInterface方式:

PayUJavaScriptInterface method:

    public class PayUJavaScriptInterface {
        Context mContext;

        /** Instantiate the interface and set the context */
        PayUJavaScriptInterface(Context c) {
            mContext = c;
        }


        public void success(long id, final String paymentId) {

            mHandler.post(new Runnable() {

                public void run() {

                    mHandler = null;

                    Intent intent = new Intent(PayMentGateWay.this, BoutiqueActivity.class);

                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

                    intent.putExtra("result", "success");

                    intent.putExtra("paymentId", paymentId);

                    startActivity(intent);

                    finish();

                }

            });

        }

    }

此方法计算哈希值:

Calculate hash from this method:

    public String hashCal(String type,String str){
        byte[] hashseq=str.getBytes();
        StringBuffer hexString = new StringBuffer();
        try{
            MessageDigest algorithm = MessageDigest.getInstance(type);
            algorithm.reset();
            algorithm.update(hashseq);
            byte messageDigest[] = algorithm.digest();



            for (int i=0;i<messageDigest.length;i++) {
                String hex=Integer.toHexString(0xFF & messageDigest[i]);
                if(hex.length()==1) hexString.append("0");
                hexString.append(hex);
            }

        }catch(NoSuchAlgorithmException nsae){ }

        return hexString.toString();


    }

}

这就是它。

这篇关于支付处理集成的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆