4

请帮助我如何为我的离子应用程序设置或呈现成功 url。当我将 PayU 资金集成到 Ionic 应用程序时,它需要成功网址和失败网址,在完成付款后它会呈现为成功网址,但它不会返回到 Ionic 应用程序。

<form name="sendParam" method="post"    action="https://test.payu.in/_payment.php">
    <input type="text" name="key" value="P3kHif" />
    <input type="text" name="txnid" value="mdd0123" />
    <input type="text" name="amount" value="100" />
    <input type="text" name="productinfo" value="oxygenconcentrator" />
    <input type="text" name="firstname" value="test" />
    <input type="text" name="email" value="test@gmail.com" />
    <input type="text" name="phone" value="9999999999" />
    <input type="text" name="surl" value="http://example.com" />
    <input type="text" name="Furl" value="http://example.com/about-us/" />
    <input type="text" name="Hash" value="9a4c95b065ae294414e6a5b0b6e8e5d1a2ebf26074228eac6ff7c7d739c9cd4d021a9f70af8860ac369b1ccecfdaa60ba5839ee9dc1fd41e2848a3813677d520"/>
    <input type="submit" value="enter"/>
 </form >

来自 PayUmoney 的响应只是 HTML 格式,没有任何 JSON 对象格式。只是我遵循了以下链接PayU Money Rest API

4

4 回答 4

3

Payumoney 没有用于混合应用程序的 sdk。我们需要使用 Cordova inapp 浏览器来实现这一点。

第 1 步:创建 Payumoney 帐户并获取沙盒详细信息。

第 2 步:安装 Cordova 应用内浏览器

第 3 步:创建您的付款网址

第 4 步:在服务器中创建成功和失败 url,并将这些 url 添加到您的支付页面

第 5 步:在您的应用内浏览器中运行您的付款网址。

而已。它将执行付款过程并向给定的成功和失败 url 发送状态。

在这里,您可以找到在 ionic 中集成支付网关的代码。

于 2017-11-15T07:10:20.133 回答
2
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContextOver) throws JSONException {

    Intent intentScan = new Intent(this.cordova.getActivity().getBaseContext(), com.timepay.payu.activity.MainActivity.class);

    intentScan.putExtra("amount", "1000");

    intentScan.setPackage(this.cordova.getActivity().getApplicationContext().getPackageName());
    callbackContext = callbackContextOver;

    this.cordova.startActivityForResult(this, intentScan, 11);


    return true;
}
于 2019-06-27T10:16:39.907 回答
0

更新:2020 Payu 发布了用于集成到混合应用程序中的 Cordova 插件 https://developer.payumoney.com/payumoney-cordova-plugin/

他们还提供了 Wrapper JS 文件来调用 Native SDK 插件

于 2020-10-18T03:31:56.270 回答
0

我一直在寻找相同的东西,但没有运气。所以最终做了很多变通方法让它与我的 IONIC 1 应用程序一起工作。

我的方法可能并不完美,但我能够为我的 ionic 应用程序获得工作报酬。

首先,我想与你们分享我的应用程序,但我打包的凭据很少,所以在这里分享它是不安全的。是的,我的应用程序已在 Playstore 中运行,并且有 100 多个活跃用户(我上次检查时)

任何方式让我向您展示我是如何在我的应用程序中做到这一点的。下面是我的代码。请看看是否有人有更好的方法请分享..` $scope.pay = function (address) {

        sharedUtils.showLoading("Processing Payment...");
        // sending data from app to server for preprocessing 
        var req = {
            method: 'POST',
            url: 'https://xyx.com/payment/getmobilepaymentdata',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            },
            // below data contains all info collected form device page transitions like user address , order details etc. 
            data: data
        }
        var serverRes = {};
        if (datatobeshared !== undefined)
        //Note: response data will have all the required info we need to send it to payumoney
            $http(req).then(function (response) {
                serverRes = response.data;
                var data = 'key=' + serverRes.key
                    + '&txnid=' + serverRes.txnid
                    + '&amount=' + serverRes.amount
                    + '&productinfo=' + serverRes.productinfo
                    + '&firstname=' + serverRes.firstname
                    + '&email=' + serverRes.email
                    + '&phone=' + serverRes.phone
                    + '&surl=' + serverRes.surl
                    + '&furl=' + serverRes.furl
                    + '&hash=' + serverRes.hash
                    + '&service_provider='+serverRes.service_provider
                    + '&udf3=' + serverRes.udf3
                    + '&udf1=' + serverRes.udf1;

               // Note: check below option.This will be set in browser
                var options = {
                    "location": "no",
                    "toolbar": "no",
                    "hardwareback": "no",
                    "clearcache": "no"
                };
                $rootScope.paymentwindow = window.open('templates/payuBiz.html?' + data, '_blank', 'location=no');
                sharedUtils.hideLoading();



// here I am updating a status flag i.e -1 on server side which my server will update to 0(on failure) or 1(on Success)                   fireBaseData.refOrderStatus().child(serverRes.txnid).update({
                    status: -1,
                });
         // once window with payumoney will open in our app we will keep checking status flag that we have set above and put a timeout for session incase user let device and didn't perform any action on payment page
                $rootScope.timesRun = 0;
                $rootScope.interval = setInterval(function () {
                    console.log($rootScope.timesRun);
                    $rootScope.timesRun += 1;

                    if ($rootScope.timesRun >= 50) {
                        clearInterval($rootScope.interval);
                        clearInterval($rootScope.interval);
                        $rootScope.paymentwindow.close();
                        sharedUtils.showAlert('Payment Session Time out', 'Payment gateway session got time out.');

                        $ionicHistory.nextViewOptions({
                            historyRoot: true
                        });
                        $state.go('lastOrders', {}, {location: "replace", reload: true});
                        return;
                    }

                    if ($rootScope.paymentwindow.closed) {
                        clearInterval($rootScope.interval);
                        sharedUtils.showAlert('Payment error', 'Payment got interrupted unexpectedly. Please try again.');
                        $ionicHistory.nextViewOptions({
                            historyRoot: true
                        });
                        $state.go('lastOrders', {}, {location: "replace", reload: true});
                        return;
                    }


                    fireBaseData.refOrderStatus().child($rootScope.txnid).child('status').once("value", function (snapshot) {


                        if (snapshot.val() != -1) {
                            $rootScope.paymentwindow.close();

                            if (snapshot.val() == 1) {
                                clearInterval($rootScope.interval);

                                $scope.orderSuccess(address, $rootScope.txnid);

                                return;
                            } else {
                                clearInterval($rootScope.interval);
                                $scope.orderFailure(address);
                                return;

                            }
                        }
                    });
                }, 5000);


            }, function (error) {
                $ionicPopup.alert({
                    title: 'Error',
                    template: 'This is some error in processing your order Please retry ' + JSON.stringify(error.data)
                });
                return;

            });
        sharedUtils.hideLoading();

    }`

其余代码是不言自明的。

希望这会有所帮助。

这是我的支付宝模板`

<h2 style="text-align: center">Your will be taken to paytment gateway </br> Please dont use back button or move app in background</h2>
<div align="center">
<div class="loader" ></div></div>

<form id = "payuForm" name="payuForm" method="post" action="https://secure.payu.in/_payment">
  <!--<form id = "payuForm" name="payuForm" method="post" action="https://test.payu.in/_payment">-->

  <input type="hidden" name="key" value=""/>
  <input type="hidden" name="txnid" value=""/>
  <input type="hidden" name="amount" value=""/>
  <input type="hidden" name="productinfo" value=""/>
  <input type="hidden" name="firstname" value=""/>
  <input type="hidden" name="email" value=""/>
  <input type="hidden" name="phone" value=""/>
  <input type="hidden" name="surl" value=""/>
  <input type="hidden" name="furl" value=""/>
  <input type="hidden" name="hash" value=""/>
  <input type="hidden" name="udf3" value=""/>
  <input type="hidden" name="udf1" value=""/>
  <input type="hidden" name="service_provider" value=""/>
  <input type="hidden" name="productinfo" value=""/>
  <input type="submit" value="enter" style="position: absolute; left: -9999px"/>
</form>

<script>

  function findGetParameter(parameterName) {
    var result = null,
      tmp = [];
    location.search
      .substr(1)
      .split("&")
      .forEach(function (item) {
        tmp = item.split("=");
        if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
      });
    return result;
  }

  try {
    $('form[name="payuForm"] input[name="firstname"]').val(findGetParameter('firstname'));
    $('form[name="payuForm"] input[name="email"]').val(findGetParameter('email'));
    $('form[name="payuForm"] input[name="hash"]').val(findGetParameter('hash'));
    $('form[name="payuForm"] input[name="phone"]').val(findGetParameter('phone'));
    $('form[name="payuForm"] input[name="productinfo"]').val(findGetParameter('productinfo'));
    $('form[name="payuForm"] input[name="amount"]').val(findGetParameter('amount'));
    $('form[name="payuForm"] input[name="key"]').val(findGetParameter('key'));
    $('form[name="payuForm"] input[name="txnid"]').val(findGetParameter('txnid'));
    $('form[name="payuForm"] input[name="surl"]').val(findGetParameter('surl'));
    $('form[name="payuForm"] input[name="furl"]').val(findGetParameter('furl'));
    $('form[name="payuForm"] input[name="udf3"]').val(findGetParameter('udf3'));
    $('form[name="payuForm"] input[name="udf1"]').val(findGetParameter('udf1'));
    $('form[name="payuForm"] input[name="service_provider"]').val(findGetParameter('service_provider'));

    setTimeout(function () {
      document.payuForm.submit();
    }, 1000);
  }catch (e)
  {
    alert(e);
  }
</script>

`

于 2017-06-09T15:08:35.893 回答