首页 > 解决方案 > 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但我被困住了。

标签: javascripthtmljsonpostget

解决方案


推荐阅读