如何将PayU支付网关与PhoneGap应用程序集成?
哪种方法正确?
如果是Android
如果有人在此提供一些意见,那将会很有帮助。
答案 0 :(得分:-1)
这是sample app,用于将payu集成到手机差距中 你可以找到html和javascript代码here。 此示例应用程序使用的是payu而没有SDK。
<强>更新强> 如果你使用角度
$scope.payuOrder = function(form) {
$scope.payu_params = {
key: "xx@#EX",
salt: "Dda3dqCx",
txnid:"qw"+Math.floor(Math.random() * 100000000000),
amount:"1230",
productinfo:"Product info",
firstname:"Ankit",
email:customer."sf.ankit@gmail.com",
user_credentials:"xx@#EX:unique_id",
udf1:"",
udf2:"",
udf3:"",
udf4:"",
udf5:"",
offer_key:"",
card_bin:"",
surl: encodeURI("https://payu.herokuapp.com/success"), //url needs to be encode
furl: encodeURI("https://payu.herokuapp.com/failure") // url needs to be encode
};
var hash_string = $scope.payu_params.key+"|"+$scope.payu_params.txnid+"|"+$scope.payu_params.amount+"|"+
$scope.payu_params.productinfo+"|"+$scope.payu_params.firstname+"|"+
$scope.payu_params.email+"|"+$scope.payu_params.udf1+"|"+$scope.payu_params.udf2+"|"+
$scope.payu_params.udf3+"|"+$scope.payu_params.udf4+"|"+$scope.payu_params.udf5+"||||||"+$scope.payu_params.salt;
console.log("HashString = "+hash_string);
$scope.payu_params.hash = CryptoJS.SHA512(hash_string).toString(CryptoJS.enc.Base64);
console.log("Hash = "+$scope.payu_params.hash);
var payu_params_string = '';
for (var key in $scope.payu_params) {
payu_params_string += key + "=" + $scope.payu_params[key] + "&";
}
payu_params_string = payu_params_string.slice(0,-1);
console.log(payu_params_string);
var bytes = [];
for (var i = 0; i < payu_params_string.length; ++i) {
bytes.push(payu_params_string.charCodeAt(i));
}
payu_params_string.toString().getBytes());
var winURL = "https://test.payu.in/_payment";
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", winURL);
for (var i in $scope.payu_params) {
if ($scope.payu_params.hasOwnProperty(i)) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = i;
input.value = $scope.payu_params[i];
form.appendChild(input);
}
}
var options = {
location: 'no',
clearcache: 'yes',
toolbar: 'no'
};
$cordovaInAppBrowser.open(winURL, '_blank', options)
.then(function(event) {
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
// insert form on loaded window
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
});
})
.catch(function(event) {
// error
});
}