CreatePayment

POST /payment/{merchant}

Create a payment

Headers

  • The real IP address of client, e.g. 127.0.0.1

  • Client ID, that can be customer ID

Path parameters

  • merchant string Required

    Merchant name to payment company, e.g. weixinpay.test

application/json

Body

  • paymentMethod string Required

    Payment method, must be wechatpay or alipay

    Values are wechatpay or alipay.

  • paymentType string Required

    Payment companies have different payment types

    Values are NATIVE, H5, JSAPI, MINIPRO, or APP.

  • orderRef string Required

    Merchant system order number

  • actualAmount integer Required

    Order actual amount, which uses the base unit of current currency

  • total integer

    Order total amount, which uses the base unit of current currency

  • Subsidy amount, only works when profitSharing is True

  • costPrice integer

    When the original order price is not equal to the payment amount, the discount will not be enjoyed. This field is mainly used to prevent the same invoice from being paid multiple times to enjoy multiple discounts.

  • Merchant invoice ID, need to use with products data

  • currency string Required

    Must be CNY or GBP

  • Whether the order is going to share profit

    Default value is true.

  • products array[object] | null

    Payment product

    Hide products attributes Show products attributes
  • Order product description

  • attach string

    Payment attach data, which could be used by payment notifies

  • Payment due time

  • goodsTag string

    Coupon goods tag

  • payerId string

    Payer ID of customer in service provider side.

  • Payer ID of customer in merchant side.

  • Notify url, that is used by payment company.

  • Success url, that is used by alipay company.

  • Cancel url, that is used by alipay company.

  • spAppId string

    App ID of payment company.

Responses

  • 200

    Create a payment successfully.

    Hide response attributes Show response attributes object
    • code integer(int32)
    • message string | null

      Response message

    • payMessage string | null

      Payment message responsed from payment company

    • payInvokeMessage string | null

      Payment invoked message responsed from payment company

    • timeStamp string | null

      Timestamp, used to sign

    • nonceStr string | null

      Random string up to 32 characters, used to sign

  • 401

    Not Authenticated.

    Hide response attributes Show response attributes object
  • 422

    Request validation failure

    Hide response attributes Show response attributes object
  • 500

    Something wrong when making the payment.

    Hide response attributes Show response attributes object
POST /payment/{merchant}
curl \
 -X POST https://nomad.samarkand-global.cn/broker/v1/payment/wechat.sh_smk \
 -H "app-api-key: $API_KEY" \
 -H "Content-Type: application/json" \
 -H "X-Real-Ip: string" \
 -H "Client-Id: string" \
 -d '{"paymentMethod":"wechatpay","paymentType":"H5","orderRef":"O123456789","actualAmount":2200,"total":2200,"subsidyAmount":0,"costPrice":0,"invoiceId":"string","currency":"CNY","profitSharing":true,"products":[{"goodsName":"Orange","goodsCategory":"health-beauty/fragrance","goodsUnitPrice":12,"goodsQuantity":1,"merchantProductId":"barcode123456","paymentProductId":1246464644}],"description":"面膜 mask","attach":"Payment attach mark","timeExpire":"2022-02-24T14:02:38Z","goodsTag":"new","payerId":"osGEYs0HfdUF4R965HMmEPKqOSWw","merchantPayerId":"osGEYs0HfdUF4R965HMmEPKqOSWw","notifyUrl":"https://www.weixin.qq.com/wxpay/pay.php","successUrl":"https://www.weixin.qq.com/wxpay/pay.php","cancelUrl":"https://www.weixin.qq.com/wxpay/pay.php","spAppId":"string"}'
Request example
# Headers
X-Real-Ip: string
Client-Id: string

# Payload
{
  "paymentMethod": "wechatpay",
  "paymentType": "H5",
  "orderRef": "O123456789",
  "actualAmount": 2200,
  "total": 2200,
  "subsidyAmount": 0,
  "costPrice": 0,
  "invoiceId": "string",
  "currency": "CNY",
  "profitSharing": true,
  "products": [
    {
      "goodsName": "Orange",
      "goodsCategory": "health-beauty/fragrance",
      "goodsUnitPrice": 12,
      "goodsQuantity": 1,
      "merchantProductId": "barcode123456",
      "paymentProductId": 1246464644
    }
  ],
  "description": "面膜 mask",
  "attach": "Payment attach mark",
  "timeExpire": "2022-02-24T14:02:38Z",
  "goodsTag": "new",
  "payerId": "osGEYs0HfdUF4R965HMmEPKqOSWw",
  "merchantPayerId": "osGEYs0HfdUF4R965HMmEPKqOSWw",
  "notifyUrl": "https://www.weixin.qq.com/wxpay/pay.php",
  "successUrl": "https://www.weixin.qq.com/wxpay/pay.php",
  "cancelUrl": "https://www.weixin.qq.com/wxpay/pay.php",
  "spAppId": "string"
}
Response examples (200)
{
  "code": 200,
  "message": "success",
  "payMessage": "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx031",
  "payInvokeMessage": "weixin://wap/pay?prepayid%3Dwx03143347..",
  "timeStamp": 1414561699,
  "nonceStr": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS"
}
Response examples (401)
{
  "code": 200,
  "message": "success"
}
Response examples (422)
{
  "code": 200,
  "message": "success"
}
Response examples (500)
{
  "code": 200,
  "message": "success",
  "errors": "Something wrong when making the service."
}