Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用android在Payu paymentgetway中完成Activity once响应重定向到成功URL 公共类付费活动扩展了AppCompative活动{ 网络视图; 字符串\u key=“i4auSw”; 字符串salt=“IW510xtG”_Javascript_Java_Android_Payu - Fatal编程技术网

Javascript 如何使用android在Payu paymentgetway中完成Activity once响应重定向到成功URL 公共类付费活动扩展了AppCompative活动{ 网络视图; 字符串\u key=“i4auSw”; 字符串salt=“IW510xtG”

Javascript 如何使用android在Payu paymentgetway中完成Activity once响应重定向到成功URL 公共类付费活动扩展了AppCompative活动{ 网络视图; 字符串\u key=“i4auSw”; 字符串salt=“IW510xtG”,javascript,java,android,payu,Javascript,Java,Android,Payu,如何使用android在Payu paymentgetway中完成Activity once响应重定向到成功URL 公共类付费活动扩展了AppCompative活动{ 网络视图; 字符串\u key=“i4auSw”; 字符串salt=“IW510xtG”; 字符串action1=“”; 字符串base_url=”https://test.payu.in"; 字符串txnid=“TXN8367286482920”; 字符串金额=“1000”; 字符串productInfo=“”; 字符串frst

如何使用android在Payu paymentgetway中完成Activity once响应重定向到成功URL
公共类付费活动扩展了AppCompative活动{
网络视图;
字符串\u key=“i4auSw”;
字符串salt=“IW510xtG”;
字符串action1=“”;
字符串base_url=”https://test.payu.in";
字符串txnid=“TXN8367286482920”;
字符串金额=“1000”;
字符串productInfo=“”;
字符串frstName;
字符串emailId;
私有字符串成功\u URL=”https://dl.dropboxusercontent.com/s/dtnvwz5p4uymjvg/success.html";
私有字符串失败\u URL=“https://dl.dropboxusercontent.com/s/z69y7fupciqzr7x/furlithParams.html";
私人电话;
私有字符串服务提供商=“payu_paisa”;
私有字符串哈希=”;
Handler mHandler=新的Handler();
MyDatabaseHelper dbhhelper;
字符串ID;
字符串emailAddress[];
字符串移动枚举器[];
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//getWindow().requestFeature(Window.FEATURE\u进度);
webView=新的webView(此);
setContentView(网络视图);
dbhhelper=newmydatabasehelper(payuactivity.this);
SharedPreferences=getSharedPreferences(
AppConstants.LOGIN\u PREFS,Context.MODE\u PRIVATE);
String coupanvalue=prefs.getString(AppConstants.COUPAN_Exit,“”);
if(coupanvalue.equals(“coupanexist”))
{
Bundle Bundle=getIntent().getExtras();
金额=bundle.getString(“finaltotatalamount”);
SharedReferences prefs1=GetSharedReferences(
AppConstants.COUPAN_退出,Context.MODE_私有);
SharedReferences.Editor=prefs1.edit();
编辑器.clear();
commit();
}否则{
Bundle Bundle=getIntent().getExtras();
金额=bundle.getString(“TotalPaybaleMount”);
}
试一试{
dbhhelp.open();
ID=prefs.getString(“Member_ID”,”);
frstName=prefs.getString(“用户名”,“用户名”);
mobilenumber=dbhhelper.UserMobileNumber(ID);
EmailAddress=dbhhelper.UserEmailAddress(ID);
电话=手机号码[0];
emailId=EmailAddress[0];
}捕获(NullPointerException e){
e、 printStackTrace();
}
JSONObject productInfoObj=新的JSONObject();
JSONArray productPartsArr=新的JSONArray();
JSONObject productPartsObj1=新的JSONObject();
JSONObject paymentidenfirparent=新的JSONObject();
JSONArray PaymentIdentifierSAR=新JSONArray();
JSONObject paymentPartsObj1=新JSONObject();
JSONObject paymentPartsObj2=新JSONObject();
试一试{
//付款部分
productPartsObj1.put(“名称”、“abc”);
productPartsObj1.put(“说明”、“abcd”);
productPartsObj1.put(“值”、“1000”);
productPartsObj1.put(“isRequired”、“true”);
productPartsObj1.put(“结算事件”、“电子邮件确认”);
productPartsArr.put(ProductPartsAbj1);
productInfoObj.put(“付款部分”,ProductPartsAR);
paymentPartsObj1.put(“字段”、“完成日期”);
付款部分的账面价值(“价值”,“2012年10月31日”);
PaymentIdentifierArr.put(PaymentPartsBj1);
paymentPartsObj2.put(“字段”、“TxnId”);
paymentPartsObj2.put(“价值”,txnid);
PaymentIdentifierArr.put(paymentPartsObj2);
paymentIdenfierParent.put(“paymentIdentifiers”,
paymentIdentifiersArr);
productInfoObj.put(“”,Paymentidenfirparent);
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
productInfo=productInfoObj.toString();
Log.e(“TAG”,productInfoObj.toString());
Random rand=新的Random();
字符串rndm=Integer.toString(rand.nextInt())
+(System.currentTimeMillis()/1000L);
txnid=hashCal(“SHA-256”,rndm)。子串(0,20);
hash=hashCal(“SHA-512”,商户密钥+“|”+txnid+“|”+金额
+“|”+productInfo+“|”+frstName+“|”+emailId
+|||||||||||+盐);
action1=基本url.concat(“/”付款”);
setWebViewClient(新的WebViewClient(){
@凌驾
接收错误时公共无效(WebView视图,int错误代码,
字符串说明,字符串失败(URL){
//TODO自动生成的方法存根
Toast.makeText(payUActivity.this,“噢,不!”+描述,
吐司。长度(短)。show();
}
@凌驾
接收到的文件上的公共无效(WebView视图,
SslError处理程序,SslError错误){
//TODO自动生成的方法存根
}
@凌驾
公共布尔值shouldOverrideUrlLoading(WebView视图,字符串url){
//Toast.makeText(payUActivity.this,“页面已启动!”+url,
//吐司。长度(短)。show();
if(url.equals(SUCCESS_url)){
Toast.makeText(payuactivity.this,“Success!”,
吐司。长度(短)。show();
SharedPreferences=getSharedPreferences(
AppConstants.PAYMENT\u success,Context.MODE\u PRIVATE);
SharedReferences.Editor=prefs.edit();
编辑器.putString(AppConstants.PAYMENT_success,“1”);
commit();
完成();
}否则{
}
返回super.shouldOverrideUrlLoading(视图、url);
}
//
@凌驾
公共无效页面已完成(我们
public class PayUActvity extends AppCompatActivity {
    WebView webView;

    String merchant_key = "i4auSw";
    String salt = "IW510xtG";
    String action1 = "";
    String base_url = "https://test.payu.in";
    String txnid = "TXN8367286482920";
    String amount = "1000";
    String productInfo = "";
    String frstName;
    String emailId;
    private String SUCCESS_URL = "https://dl.dropboxusercontent.com/s/dtnvwz5p4uymjvg/success.html";
    private String FAILED_URL = "https://dl.dropboxusercontent.com/s/z69y7fupciqzr7x/furlithParams.html";
    private String phone;
    private String serviceProvider = "payu_paisa";
    private String hash = "";
    Handler mHandler = new Handler();
    MyDatabaseHelper dbhhelper;
    String ID;
    String emailadress[];
    String mobilenumber[];


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getWindow().requestFeature(Window.FEATURE_PROGRESS);
        webView = new WebView(this);
        setContentView(webView);
        dbhhelper = new MyDatabaseHelper(PayUActvity.this);
        SharedPreferences prefs = getSharedPreferences(
                AppConstants.LOGIN_PREFS, Context.MODE_PRIVATE);

        String coupanvalue = prefs.getString(AppConstants.COUPAN_Exit, "");
        if (coupanvalue.equals("coupanexist"))

        {
            Bundle bundle = getIntent().getExtras();
            amount = bundle.getString("finaltotatalamount");

            SharedPreferences prefs1 = getSharedPreferences(
                    AppConstants.COUPAN_Exit, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = prefs1.edit();
            editor.clear();
            editor.commit();

        } else {
            Bundle bundle = getIntent().getExtras();
            amount = bundle.getString("totalpaybleamount");
        }

        try {
            dbhhelper.open();
            ID = prefs.getString("Member_id", "");
            frstName = prefs.getString("username", "");
            mobilenumber = dbhhelper.userMobilennumber(ID);
            emailadress = dbhhelper.useremailadress(ID);
            phone = mobilenumber[0];
            emailId = emailadress[0];

        } catch (NullPointerException e) {
            e.printStackTrace();

        }

        JSONObject productInfoObj = new JSONObject();
        JSONArray productPartsArr = new JSONArray();
        JSONObject productPartsObj1 = new JSONObject();
        JSONObject paymentIdenfierParent = new JSONObject();
        JSONArray paymentIdentifiersArr = new JSONArray();
        JSONObject paymentPartsObj1 = new JSONObject();
        JSONObject paymentPartsObj2 = new JSONObject();
        try {
            // Payment Parts
            productPartsObj1.put("name", "abc");
            productPartsObj1.put("description", "abcd");
            productPartsObj1.put("value", "1000");
            productPartsObj1.put("isRequired", "true");
            productPartsObj1.put("settlementEvent", "EmailConfirmation");
            productPartsArr.put(productPartsObj1);
            productInfoObj.put("paymentParts", productPartsArr);
            paymentPartsObj1.put("field", "CompletionDate");
            paymentPartsObj1.put("value", "31/10/2012");
            paymentIdentifiersArr.put(paymentPartsObj1);
            paymentPartsObj2.put("field", "TxnId");
            paymentPartsObj2.put("value", txnid);
            paymentIdentifiersArr.put(paymentPartsObj2);
            paymentIdenfierParent.put("paymentIdentifiers",
                    paymentIdentifiersArr);
            productInfoObj.put("", paymentIdenfierParent);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        productInfo = productInfoObj.toString();
        Log.e("TAG", productInfoObj.toString());
        Random rand = new Random();
        String rndm = Integer.toString(rand.nextInt())
                + (System.currentTimeMillis() / 1000L);
        txnid = hashCal("SHA-256", rndm).substring(0, 20);
        hash = hashCal("SHA-512", merchant_key + "|" + txnid + "|" + amount
                + "|" + productInfo + "|" + frstName + "|" + emailId
                + "|||||||||||" + salt);

        action1 = base_url.concat("/_payment");

        webView.setWebViewClient(new WebViewClient() {

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

            @Override
            public void onReceivedSslError(WebView view,
                                           SslErrorHandler handler, SslError error) {
                // TODO Auto-generated method stub

            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
//                Toast.makeText(PayUActvity.this, "Page Started! " + url,
//                        Toast.LENGTH_SHORT).show();
                if (url.equals(SUCCESS_URL)) {
                    Toast.makeText(PayUActvity.this, "Success! ",
                            Toast.LENGTH_SHORT).show();
                    SharedPreferences prefs = getSharedPreferences(
                            AppConstants.PAYMENT_SUCESS, Context.MODE_PRIVATE);


                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putString(AppConstants.PAYMENT_SUCESS, "1");
                    editor.commit();
                    finish();
                } else {


                }
                return super.shouldOverrideUrlLoading(view, url);
            }

            //
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

            }
        });

        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(false);
        webView.getSettings().setLoadWithOverviewMode(false);

        webView.addJavascriptInterface(new PayUJavaScriptInterface(PayUActvity.this),
                "PayUMoney");
        Map<String, String> mapParams = new HashMap<String, String>();
        mapParams.put("key", merchant_key);
        mapParams.put("hash", hash);
        mapParams.put("txnid", txnid);
        mapParams.put("service_provider", "payu_paisa");
        mapParams.put("amount", amount);
        mapParams.put("firstname", frstName);
        mapParams.put("email", emailId);
        mapParams.put("phone", phone);
        mapParams.put("productinfo", productInfo);
        mapParams.put("surl", SUCCESS_URL);
        mapParams.put("furl", FAILED_URL);
          webview_ClientPost(webView, action1, mapParams.entrySet());

    }

    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;

                }
            });
        }
    }

    public void webview_ClientPost(WebView webView, String url,
                                   Collection<Map.Entry<String, String>> postData) {
        StringBuilder sb = new StringBuilder();

        sb.append("<html><head></head>");
        sb.append("<body onload='form1.submit()'>");
        sb.append(String.format("<form id='form1' action='%s' method='%s'>",
                url, "post"));
        for (Map.Entry<String, String> item : postData) {
            sb.append(String.format(
                    "<input name='%s' type='hidden' value='%s' />",
                    item.getKey(), item.getValue()));
        }
        sb.append("</form></body></html>");
        Log.d("Tag", "webview_ClientPost called");
        webView.loadData(sb.toString(), "text/html", "utf-8");
    }

    public boolean empty(String s) {
        if (s == null || s.trim().equals(""))
            return true;
        else
            return false;
    }

    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();

    }

}
@Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            if (url.equals(SUCCESS_URL) {
                // finish activity here
            } else {
                // handle other urls here.
            }
        }
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
if (url.equals(SUCCESS_URL)) {
Toast.makeText(PayUActvity.this, "Success! ",
Toast.LENGTH_SHORT).show();
SharedPreferences prefs = getSharedPreferences(
AppConstants.PAYMENT_SUCESS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(AppConstants.PAYMENT_SUCESS, "1");
editor.commit();
finish();
} else {
Toast.makeText(PayUActvity.this, "Something Wrong! ",
Toast.LENGTH_SHORT).show();
}
}