Ich versuche, eine Zahlungsanwendung mit PayU zu machen und weiß nicht, wie ich JSON-Daten an PayU-Server senden kann. Wie kann ich das machen ?? Bitte helfen Sie mir oder geben Sie mir einen Rat. Ich sollte die Informationen (von body: {...}
unten) POST https://secure.snd.payu.com/api/v2_1/orders
Senden Sie JSON-Daten an einen anderen Server (PayU) mit Express und eckig
Daten übergeben, die ich PayU (body: {...}
)
userFactory.paypalPayment = function(payment) {
return $http({
method: 'POST',
url: "/paynow",
headers: {
'Content-Type': 'application/json'
},
body: {
"notifyUrl": "https://your.eshop.com/notify",
"customerIp": "127.0.0.1",
"merchantPosId": "145227",
"description": "Toyota",
"currencyCode": "USD",
"totalAmount": "12",
"products":{
"name": "Wireless mouse",
"unitPrice": "15000",
"quantity": "1"
},
}
});
}
return userFactory
app.js (Express.js)
router.post('/paynow', function(req, res){
res.setHeader('Content-type', 'application/json; charset=utf-8');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, content-type');
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.json({ success: true})
})
Controller
senden sollapp.payment = function(payment){
User.paypalPayment().then(function(data){
console.log(data.data)
if(data.data.success) {
$window.location = 'https://secure.snd.payu.com/api/v2_1/orders'
} else {
console.log('Wrong way')
}
})
}
Vielen Dank für Tipps, ich analysiert npm Anfrage Ich löste dieses Problem. Danke noch einmal! –