javascript - concardis payengine.de 创建订单 将 JSON 发送到服务器
问题描述
我目前正在尝试在我的网站中实施 concardis payengine.de 支付网关,但遇到了一些问题。基本上我正在做的是
var xhr = new XMLHttpRequest();
var url = "https://apitest.payengine.de/v1/orders";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var json = JSON.parse(xhr.responseText);
console.log(json.email + ", " + json.password);
}
};
var data = JSON.stringify({
"initialAmount": 2000,
"currency": "EUR",
"transactionType": "DEBIT",
"ipAddress": null,
"async": {
"successUrl": "https://www.google.de/#newwindow=1&q=success",
"failureUrl": "https://www.google.de/#newwindow=1&q=failure",
"cancelUrl": "https://www.google.de/#newwindow=1&q=cancel",
"confirmUrl": "https://www.google.de/?newwindow=1&q=confirm"
},
"basket": [
{
"name": "usbstick",
"articleNumber": "sasdfas",
"totalPrice": 2000,
"totalPriceWithTax": 2000,
"unitPrice": 2000,
"unitPriceWithTax": 2000,
"tax": 0,
"quantity": 1
}
],
"terms": 1581795628694,
"privacy": 1581795628694
});
xhr.send(data);
因为这是他们在他们的网站上说要做的: 网站 这应该返回:
{
"createdAt": 1581796670114,
"modifiedAt": 1581796670114,
"merchantId": "merchant_gkdyunb7sd",
"terms": 1581796668646,
"privacy": 1581796668646,
"orderId": "qmmyzub4hx",
"merchantOrderId": null,
"paymentProviderTransactionId": null,
"description": null,
"statementDescription": null,
"initialAmount": 2000,
"preauthorizedAmount": 0,
"capturedAmount": 0,
"refundedAmount": 0,
"canceledAmount": 0,
"currency": "EUR",
"basket": [
{
"id": "Article-583499a2-ac99-4b6e-b689-d8218a07a833",
"name": "usbstick",
"articleNumber": "sasdfas",
"totalPrice": 2000,
"totalPriceWithTax": 2000,
"unitPrice": 2000,
"unitPriceWithTax": 2000,
"quantity": 1,
"tax": 0,
"discount": null,
"imageUrl": null,
"articleUrl": null,
"articleType": null
}
],
"customer": null,
"persona": null,
"billingAddress": null,
"shippingAddress": null,
"ipAddress": null,
"paymentInstrument": null,
"transactions": [],
"status": "CREATED",
"channel": "ECOM",
"source": null,
"settled": false,
"settlementDate": null,
"allowedProducts": [
"prepayment",
"postfinance-card",
"wechat-pay",
"sepa",
"giropay",
"creditcard",
"alipay",
"paydirekt",
"paypal",
"sofort",
"bancontact",
"ideal",
"eps"
],
"product": null,
"transactionType": "DEBIT",
"meta": null,
"async": null,
"deviceIdent": null,
"clientType": "BRW",
"asyncNotificationSubscriptionId": null,
"lastOperation": "ORDER_CREATED",
"locale": null
}
我的问题是我将如何获得该回报并从该响应中获取 MerchantId 和 OrderId 并将其输入
<option value="PayEngineWidget.initAsModal(
'merchant_gkdyunb7sd',
'undefined',
optionalParameters,
resultCallback
);">Size S</option>
而不是merchant_gkdyunb7sd 和未定义。我也想我必须做点什么,Authorization:Basic bWVyY2hhbnRfZ2tkeXVuYjdzZDo5T2F4RWRmMnliT2RyZTN2
但我被困住了。
解决方案
推荐阅读
- c++ - C ++:在push_back时迭代指针向量时出现分段错误
- javascript - 像图像旋转一样旋转 SVG 元素
- amazon-redshift - AWS Glue 小写列
- discord.js - 不和谐 js | 向在线会员发送消息
- qt - 所有网页内容到字符串
- azure - Sharepoint REST API 访问令牌不返回所有站点
- django - 如何根据模型中的值在 django admin 中添加编辑自己的权限?
- r - 当 x 中的 0 为奇数时,如何将这个零和下一个零之间的 id 值分配给新变量 ref
- python - 通过对最后 4 层求和的 BERT 句子嵌入
- tensorflow - 从 tensorflow 2.0 中保存的模型运行预测