首页 文章

如何在Android应用程序中集成TEST PayU Payment Gateway?

提问于
浏览
8

我是支付网关的新手 . 目前,我正在开发一个移动应用程序,我需要在Android应用程序中集成PayU支付网关 .

到目前为止,我已经为TEST url创建了一个代码,当我运行我的应用程序时,我得到以下异常:

An error occurred. Sorry, some problem occurred.

手机app的屏幕截图
enter image description here

这是我的代码:

public class PayMentGateWay extends Activity {
     private ArrayList<String> post_val = new ArrayList<String>();
     private String post_Data="";
     WebView webView ;
     final Activity activity = this;
     private String tag = "PayMentGateWay";
     private String hash,hashSequence;

     String merchant_key="JBZaLc";
        String salt="GQs7yium";
        String action1 ="";
        String base_url="https://test.payu.in";
        int error=0;
        String hashString="";
        Map<String,String> params;
        String txnid ="";

        Handler mHandler = new Handler();


    @SuppressLint("JavascriptInterface")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
         final ProgressDialog progressDialog = new ProgressDialog(activity);
         getWindow().requestFeature(Window.FEATURE_PROGRESS);
        webView = new WebView(this);
        setContentView(webView);

        post_val.add("key");
        post_val.add("JBZaLc");
        post_val.add("txnid");
        post_val.add("5d59dae66618a14f5020");
        post_val.add("amount");
        post_val.add("100.00");
        post_val.add("productinfo");

        post_val.add("{paymentParts:[{name:abc,description:abcd,value:500,isRequired:true,settlementEvent:EmailConfirmation}], paymentIdentifiers:[{field:CompletionDate, value:25/06/2015}]}");
        post_val.add("firstname");
        post_val.add("pqrs");
        post_val.add("email");
        post_val.add("xxxx@xxxmail.com");
        post_val.add("phone");
        post_val.add("xxxxxxxxxx");
        post_val.add("surl");
        post_val.add("https://www.google.com");
        post_val.add("furl");
        post_val.add("https://www.gmail.com");
        post_val.add("hash");
        post_val.add("");
        post_val.add("provider");
        post_val.add("payu_paisa");
        Log.d(tag, "post_val: "+post_val);
        params= new HashMap<String,String>();
        for(int i = 0;i<post_val.size();){
            params.put(post_val.get(i), post_val.get(i+1));

            i+=2;   
        }

        if(empty(params.get("txnid"))){
            Random rand = new Random();
            String rndm = Integer.toString(rand.nextInt())+(System.currentTimeMillis() / 1000L);
            txnid=hashCal("SHA-256",rndm).substring(0,20);
            popup("txnid : " + txnid);
            System.out.println("......txnid...... " + txnid);
        } else {
            txnid=params.get("txnid");
            System.out.println("....else.......txnid...... " + txnid);
        }

            //String udf2 = txnid;
        String txn="abcd";
         hash="";
        String hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
        if(empty(params.get("hash")) && params.size()>0) {
            if( empty(params.get("key"))
                || empty(params.get("txnid"))
                || empty(params.get("amount"))
                || empty(params.get("firstname"))
                || empty(params.get("email"))
                || empty(params.get("phone"))
                || empty(params.get("productinfo"))
                || empty(params.get("surl"))
                || empty(params.get("furl"))
                || empty(params.get("service_provider"))

        ) {
                String[] hashVarSeq = hashSequence.split("\\|");
                for (int i = 0; i < hashVarSeq.length; i++) {
                    System.out.println("<<<<<>>>>>>>> " + hashVarSeq[i]);
                }

                for(String part : hashVarSeq)
                {
                    hashString= (empty(params.get(part))) ? hashString.concat("") : hashString.concat(params.get(part));
                    hashString=hashString.concat("|");
                    System.out.println("??????? " + hashString);
                }
                hashString=hashString.concat(salt);


                 hash=hashCal("SHA-512",hashString);
                 System.out.println(hashString + " /////~~~~~~ " + hash);
                action1=base_url.concat("/_payment");
            }
        }
        else if(!empty(params.get("hash")))
        {
            hash=params.get("hash");
            action1=base_url.concat("/_payment");
            System.out.println("!!!!!!!!HASHHHHHHH!!!!!! " + hash);
        }

        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 super.shouldOverrideUrlLoading(view, url);
            }

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


        });


        webView.setVisibility(0);
        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(activity), "PayUMoney");
        Map<String, String> mapParams = new HashMap<String, String>();
        mapParams.put("key",merchant_key);
        mapParams.put("hash",PayMentGateWay.this.hash);
        mapParams.put("txnid",(empty(PayMentGateWay.this.params.get("txnid"))) ? "" : PayMentGateWay.this.params.get("txnid"));
        Log.d(tag, "txnid: "+PayMentGateWay.this.params.get("txnid"));
        mapParams.put("service_provider","payu_paisa");

            mapParams.put("amount",(empty(PayMentGateWay.this.params.get("amount"))) ? "" : PayMentGateWay.this.params.get("amount"));
            mapParams.put("firstname",(empty(PayMentGateWay.this.params.get("firstname"))) ? "" : PayMentGateWay.this.params.get("firstname"));
            mapParams.put("email",(empty(PayMentGateWay.this.params.get("email"))) ? "" : PayMentGateWay.this.params.get("email"));
            mapParams.put("phone",(empty(PayMentGateWay.this.params.get("phone"))) ? "" : PayMentGateWay.this.params.get("phone"));

            mapParams.put("productinfo",(empty(PayMentGateWay.this.params.get("productinfo"))) ? "" : PayMentGateWay.this.params.get("productinfo"));
            mapParams.put("surl",(empty(PayMentGateWay.this.params.get("surl"))) ? "" : PayMentGateWay.this.params.get("surl"));
            mapParams.put("furl",(empty(PayMentGateWay.this.params.get("furl"))) ? "" : PayMentGateWay.this.params.get("furl"));
            mapParams.put("lastname",(empty(PayMentGateWay.this.params.get("lastname"))) ? "" : PayMentGateWay.this.params.get("lastname"));

            mapParams.put("address1",(empty(PayMentGateWay.this.params.get("address1"))) ? "" : PayMentGateWay.this.params.get("address1"));
            mapParams.put("address2",(empty(PayMentGateWay.this.params.get("address2"))) ? "" : PayMentGateWay.this.params.get("address2"));
            mapParams.put("city",(empty(PayMentGateWay.this.params.get("city"))) ? "" : PayMentGateWay.this.params.get("city"));
            mapParams.put("state",(empty(PayMentGateWay.this.params.get("state"))) ? "" : PayMentGateWay.this.params.get("state"));

            mapParams.put("country",(empty(PayMentGateWay.this.params.get("country"))) ? "" : PayMentGateWay.this.params.get("country"));
            mapParams.put("zipcode",(empty(PayMentGateWay.this.params.get("zipcode"))) ? "" : PayMentGateWay.this.params.get("zipcode"));
            mapParams.put("udf1",(empty(PayMentGateWay.this.params.get("udf1"))) ? "" : PayMentGateWay.this.params.get("udf1"));
            mapParams.put("udf2",(empty(PayMentGateWay.this.params.get("udf2"))) ? "" : PayMentGateWay.this.params.get("udf2"));

            mapParams.put("udf3",(empty(PayMentGateWay.this.params.get("udf3"))) ? "" : PayMentGateWay.this.params.get("udf3"));
            mapParams.put("udf4",(empty(PayMentGateWay.this.params.get("udf4"))) ? "" : PayMentGateWay.this.params.get("udf4"));
            mapParams.put("udf5",(empty(PayMentGateWay.this.params.get("udf5"))) ? "" : PayMentGateWay.this.params.get("udf5"));
            mapParams.put("pg",(empty(PayMentGateWay.this.params.get("pg"))) ? "" : PayMentGateWay.this.params.get("pg"));
            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;

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

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

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

        intent.putExtra("paymentId", paymentId);

        startActivity(intent);

        finish();

        }

        });

        }

    }
     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 void success(long id, final String paymentId) {

     mHandler.post(new Runnable() {

     public void run() {

     mHandler = null;

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

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

     intent.putExtra(Constants.ACCOUNT_NAME, "success");

     intent.putExtra(Constants._ID, paymentId);

     startActivity(intent);

     finish();

     }

     });

     }


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


    }

    public void popup(String msg) {
        Toast.makeText(PayMentGateWay.this, "" + msg, Toast.LENGTH_LONG).show();
    }


}

我真的不知道究竟是什么问题 . 为什么我无法看到下一页或者我错过了什么?

8 回答

  • 0

    我认为你的代码没问题,我也是这样做的,并且从payu那里了解到 test merchant_keysalt 目前无效 . 尝试 生产环境 模式 .

    如果要从服务器使用(postUrl)加载数据:

    post_Data = "hash="+PayMentGateWay.this.hash+"&key="+merchant_key+"&txnid="+PayMentGateWay.this.params.get("txnid")+"&amount="+PayMentGateWay.this.params.get("amount")+
                    "&productinfo="+PayMentGateWay.this.params.get("productinfo")+"&firstname="+PayMentGateWay.this.params.get("firstname")+
                    "&email="+PayMentGateWay.this.params.get("email")+"&phone="+PayMentGateWay.this.params.get("phone")+
                    "&surl="+PayMentGateWay.this.params.get("surl")+"&furl="+ PayMentGateWay.this.params.get("furl")+
                    "&service_provider="+ "payu_paisa";
    
     webView.postUrl("https://secure.payu.in/_payment", EncodingUtils.getBytes(post_Data, "base64"));
    

    我希望这有帮助 .

  • 0

    Hey guys I have successfully implemented payment Gateway

    在drawable for progress对话框中使用的图像

    l_icon

    l_icon

    l_icon

    l_icon

    PayUMoneyActivity

    public class PayUMoneyActivity extends AppCompatActivity {
    
    WebView webView;
    Context activity;
    /**
     * Order Id
     * To Request for Updating Payment Status if Payment Successfully Done
     */
    int mId;
    private String mMerchantKey = "JBZaLc";//For merchant and salt key you need to contact payu money tech support otherwise you get error
    private String mSalt = "GQs7yium";//copy and paste works fine 
    private String mBaseURL = "https://test.payu.in";
    private String mAction = ""; // For Final URL
    private String mTXNId; // This will create below randomly
    private String mHash; // This will create below randomly
    private String mProductInfo; // From Previous Activity
    private String mFirstName; // From Previous Activity
    private String mEmailId; // From Previous Activity
    private double mAmount; // From Previous Activity
    private String mPhone; // From Previous Activity
    private String mServiceProvider = "payu_paisa";
    private String mSuccessUrl = "https://payu.herokuapp.com/success";
    private String mFailedUrl = "https://payu.herokuapp.com/failure";
    
    
    boolean isFromOrder;
    /**
     * Handler os handler
     */
    Handler mHandler = new Handler();
    private String TAG = "User info";
    private ProgressDialog progressDialog;
    
    
    /**
     * @param savedInstanceState
     */
    @SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled", "JavascriptInterface"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // getWindow().requestFeature(Window.FEATURE_PROGRESS);
        super.onCreate(savedInstanceState);
       /**
         * Setting WebView to Screen
         */
        setContentView(R.layout.activity_payumoney);
        /**
         * start processing Payu dialog
         */
        progressBarVisibilityPayuChrome(View.VISIBLE);
    
        /**
         * Creating WebView
         */
        webView = (WebView) findViewById(R.id.payumoney_webview);
    
        /**
         * Context Variable
         */
        activity = getApplicationContext();
        /**
         * Getting Intent Variables...
         */
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            mFirstName = bundle.getString("name");
            mEmailId = bundle.getString("email");
            mProductInfo = bundle.getString("productInfo");
            mAmount = Double.parseDouble(bundle.getString("amount"));//in my case amount getting as String so i parse it double
            mPhone = bundle.getString("phone");
            mId = bundle.getInt("id");
            isFromOrder = bundle.getBoolean("isFromOrder");
    
            Log.i(TAG, "" + mFirstName + " : " + mEmailId + " : " + mAmount + " : " + mPhone);
    
            /**
             * Creating Transaction Id
             */
            Random rand = new Random();
            String randomString = Integer.toString(rand.nextInt()) + (System.currentTimeMillis() / 1000L);
            mTXNId = hashCal("SHA-256", randomString).substring(0, 20);
    
            mAmount = new BigDecimal(mAmount).setScale(0, RoundingMode.UP).intValue();
    
            /**
             * Creating Hash Key
             */
            mHash = hashCal("SHA-512", mMerchantKey + "|" +
                    mTXNId + "|" +
                    mAmount + "|" +
                    mProductInfo + "|" +
                    mFirstName + "|" +
                    mEmailId + "|||||||||||" +
                    mSalt);
    
            /**
             * Final Action URL...
             */
            mAction = mBaseURL.concat("/_payment");
    
            /**
             * WebView Client
             */
            webView.setWebViewClient(new WebViewClient() {
    
                @Override
                public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                    super.onReceivedError(view, request, error);
                    Toast.makeText(activity, "Oh no! " + error, Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onReceivedSslError(WebView view,
                                               SslErrorHandler handler, SslError error) {
                    Toast.makeText(activity, "SSL Error! " + error, Toast.LENGTH_SHORT).show();
                    handler.proceed();
                }
    
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    return super.shouldOverrideUrlLoading(view, url);
                }
    
                @Override
                public void onPageStarted(WebView view, String url, Bitmap favicon) {
                    super.onPageStarted(view, url, favicon);
                }
    
                @Override
                public void onPageFinished(WebView view, String url) {
    
                    if (url.equals(mSuccessUrl)) {
    
                        Intent intent = new Intent(PayUMoneyActivity.this, PaymentStatusActivity.class);
                        intent.putExtra("status", true);
                        intent.putExtra("transaction_id", mTXNId);
                        intent.putExtra("id", mId);
                        intent.putExtra("isFromOrder", isFromOrder);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                    } else if (url.equals(mFailedUrl)) {
                        Intent intent = new Intent(PayUMoneyActivity.this, PaymentStatusActivity.class);
                        intent.putExtra("status", false);
                        intent.putExtra("transaction_id", mTXNId);
                        intent.putExtra("id", mId);
                        intent.putExtra("isFromOrder", isFromOrder);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                    }
                    /**
                     * wait 10 seconds to dismiss payu money processing dialog in my case
                     */
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            progressBarVisibilityPayuChrome(View.GONE);
                        }
                    }, 10000);
    
                    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(PayUMoneyActivity.this), "PayUMoney");
    
            /**
             * Mapping Compulsory Key Value Pairs
             */
            Map<String, String> mapParams = new HashMap<>();
            mapParams.put("key", mMerchantKey);
            mapParams.put("txnid", mTXNId);
            mapParams.put("amount", String.valueOf(mAmount));
            mapParams.put("productinfo", mProductInfo);
            mapParams.put("firstname", mFirstName);
            mapParams.put("email", mEmailId);
            mapParams.put("phone", mPhone);
            mapParams.put("surl", mSuccessUrl);
            mapParams.put("furl", mFailedUrl);
            mapParams.put("hash", mHash);
            mapParams.put("service_provider", mServiceProvider);
    
            webViewClientPost(webView, mAction, mapParams.entrySet());
    
        } else {
            Toast.makeText(activity, "Something went wrong, Try again.", Toast.LENGTH_LONG).show();
        }
    }
    
    /**
     * Posting Data on PayUMoney Site with Form
     *
     * @param webView
     * @param url
     * @param postData
     */
    public void webViewClientPost(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", "webViewClientPost called: " + sb.toString());
        webView.loadData(sb.toString(), "text/html", "utf-8");
    }
    
    
    /**
     * Hash Key Calculation
     *
     * @param type
     * @param str
     * @return
     */
    public String hashCal(String type, String str) {
        byte[] hashSequence = str.getBytes();
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest algorithm = MessageDigest.getInstance(type);
            algorithm.reset();
            algorithm.update(hashSequence);
            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 boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onPressingBack();
        }
        return super.onOptionsItemSelected(item);
    }
    
    @Override
    public void onBackPressed() {
        onPressingBack();
    }
    
    /**
     * On Pressing Back
     * Giving Alert...
     */
    private void onPressingBack() {
        final Intent intent;
        if (isFromOrder)
            intent = new Intent(PayUMoneyActivity.this, ProductInCartList.class);
        else
            intent = new Intent(PayUMoneyActivity.this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(PayUMoneyActivity.this);
        alertDialog.setTitle("Warning");
        alertDialog.setMessage("Do you cancel this transaction?");
        alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
                startActivity(intent);
            }
        });
        alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
    }
    
    public class PayUJavaScriptInterface {
        Context mContext;
    
        PayUJavaScriptInterface(Context c) {
            mContext = c;
        }
    
        public void success(long id, final String paymentId) {
    
            mHandler.post(new Runnable() {
    
                public void run() {
    
                    mHandler = null;
                    Toast.makeText(PayUMoneyActivity.this, "Payment Successfully.", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(PayUMoneyActivity.this, MainActivity.class);
    
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    
                    intent.putExtra("result", "success");
    
                    intent.putExtra("paymentId", paymentId);
    
                    startActivity(intent);
    
                    finish();
    
                }
    
            });
    
        }
    }
    
    
    public void progressBarVisibilityPayuChrome(int visibility) {
        if (getApplicationContext() != null && !isFinishing()) {
            if (visibility == View.GONE || visibility == View.INVISIBLE) {
                if (progressDialog != null && progressDialog.isShowing())
                    progressDialog.dismiss();
            } else if (progressDialog == null || !progressDialog.isShowing()) {
                progressDialog = showProgress(this);
            }
        }
    }
    
    public ProgressDialog showProgress(Context context) {
        if (getApplicationContext() != null && !isFinishing()) {
            LayoutInflater mInflater = LayoutInflater.from(context);
            final Drawable[] drawables = {getResources().getDrawable(R.drawable.l_icon1),
                    getResources().getDrawable(R.drawable.l_icon2),
                    getResources().getDrawable(R.drawable.l_icon3),
                    getResources().getDrawable(R.drawable.l_icon4)
            };
    
            View layout = mInflater.inflate(R.layout.prog_dialog, null);
            final ImageView imageView;
            imageView = (ImageView) layout.findViewById(R.id.imageView);
            ProgressDialog progDialog = new ProgressDialog(context, R.style.ProgressDialog);
    
            final Timer timer = new Timer();
            timer.scheduleAtFixedRate(new TimerTask() {
                int i = -1;
    
                @Override
                synchronized public void run() {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            i++;
                            if (i >= drawables.length) {
                                i = 0;
                            }
                            imageView.setImageBitmap(null);
                            imageView.destroyDrawingCache();
                            imageView.refreshDrawableState();
                            imageView.setImageDrawable(drawables[i]);
                        }
                    });
    
                }
            }, 0, 500);
    
            progDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    timer.cancel();
                }
            });
            progDialog.show();
            progDialog.setContentView(layout);
            progDialog.setCancelable(true);
            progDialog.setCanceledOnTouchOutside(false);
            return progDialog;
        }
        return null;
    }
    }
    

    prog_dialog.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/shape_progress"
        android:gravity="center_horizontal"
        android:orientation="vertical">
    
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:paddingTop="10dp"
            android:scaleType="centerInside"
            android:src="@drawable/l_icon1" />
    
        <TextView
            android:id="@+id/dialog_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:paddingTop="30dp"
            android:text="Processing Your Request"
            android:textSize="20dp"
            android:textStyle="normal"/>
    
        <TextView
            android:id="@+id/dialog_desc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:text="Please Wait..."
            android:textSize="15dp"
            android:textStyle="italic"/>
    </LinearLayout>
    </RelativeLayout>
    

    activity_payumoney.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/r_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal">
    
    <FrameLayout
        android:id="@+id/parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:visibility="gone" />
    
    <WebView
        android:id="@+id/payumoney_webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    
    <LinearLayout
        android:id="@+id/trans_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background_drawable"
        android:orientation="horizontal"/>
    </RelativeLayout>
    

    background_drawable.xml

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#10000000"></solid>
    <corners android:radius="0dp" />
    
  • 6

    他们尚未激活测试帐户 .

  • 1

    “抱歉,发生了一些问题”当您没有有效的商家密钥和Salt密钥时,会出现此错误 . 在这种情况下,您需要联系PayU Money客户服务支持团队获取有效的Merchant和Salt密钥 . 希望这会帮助你 .

  • 0

    我遇到了同样的问题,并且厌倦了这种集成 .

    但在与payumoney.com运动团队联系后,他们告诉我下载套件中显示的集成套件未激活,这是关键(JBZaLc)和盐(GQs7yium),它只是一个虚拟数据 . 因此,我们需要发送您的公司详细信息,包括银行详细信息,然后他们验证您的公司详细信息,然后他们将为我们提供新的集成套件 . 使用该套件,我们可以进行测试 .

  • 4

    这是因为PayUMoney的技术错误 . 需要联系支持团队以发布新的商家ID和密钥 .

  • 0

    从这里下载演示项目github project link

    并改变

    int env = PayuConstants.STAGING_ENV;
    

    这将适用于测试模式

  • 1

    PayUmoney商家仪表板 - 在右上方,您将看到“实时模式”只需将其切换为“测试模式” . PayUmoney的Android应用程序集成很简单 . 在gradle文件中添加这些依赖项

    implementation 'com.payumoney.core:payumoney-sdk:7.4.4'
        implementation  'com.payumoney.sdkui:plug-n-play:1.4.4'
    

    你可以找到PHP校验和哈希文件和android源代码in this reference link .

相关问题