﻿# 纯API-APM

纯API集成模式下，商户需要自行构建相关的支付页面，如：收银页、支付结果页等，因此，该模式需要商户投入更多的研发成本。
绝大部份的APM在纯API上的接入，跟指定支付方式的效果一样，都是返回渠道页面，在渠道页面上完成支付。少部分支付方式，需要商户自行采集支付要素传递给PayerMax，同时也需要商户具备PCI资质。

## 1. 支持的支付方式

支持纯API的支付方式可以在支付方式列表看到，下面举例几个通用的APM支付方式的接入类型:

| **地区代码** | **地区** | **支付方式** | **支付要素**            | **交互方式** | **返回示例**                                            |
| ------------ | -------- | ------------ | ----------------------- | ------------ | ------------------------------------------------------- |
| DE           | 德国     | Klarna       | 无                      | 渠道链接     | https://pay.klarna.com/eu/xxxxx                         |
| SG           | 新加坡   | PayNow       | 无                      | QRCode       | "qrCode": "00020101021226580009SG.PAYNOW010120213xxxxx" |
| ID           | 印尼     | OVO          | accountNo,accountNoType | 渠道链接     | 用户收到短信-->打开渠道链接-->输入验证码-->支付成功     |

## 2. 接口介绍

### 2.1 接口列表

| 关联交互时序     | 调用方向             | 接口类型   | 接口PATH                                                                                                                                          |
| ---------------- | -------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| 创建支付         | `商户` -> `PayerMax` | `后端接口` | [/orderAndPay](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderAndPay/post) |
| 支付结果异步通知 | `PayerMax` -> `商户` | `后端接口` | [/collectResultNotifyUrl](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/collectResultNotifyUrl/post)     |
| 查询支付交易     | `商户` -> `PayerMax` | `后端接口` | [/orderQuery](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderQuery/post)   |

#### 2.1.1 环境信息

- **测试环境**：https:// `pay-gate-uat.payermax.com`/aggregate-pay/api/gateway/ `<接口PATH>`

- **集成环境**：https:// `pay-gate.payermax.com`/aggregate-pay/api/gateway/ `<接口PATH>`

#### 2.1.2 请求header

``` json
"headers": {
        "Accept": "application/json",
        "sign": "请参考签名规则：https://docs-v2.payermax.com/202606-version/developer/config-settings.html",//必须
        "Content-Type": "application/json"
}
```

## 3. 开始集成

### 方式一：返回渠道链接

商户服务端：调用[/orderAndPay API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderAndPay(for-drop-dont-copy-me)/post) 接口发起HTTP POST请求，创建支付。

[/orderAndPay](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderAndPay(for-drop-dont-copy-me)/post) 接口请求示例：

``` json
{
  requestTime: '2026-02-27T10:27:58.936+08:00',
  keyVersion: '1',
  data: {
    totalAmount: '1',
    country: 'DE',
    currency: 'EUR',
    expireTime: '3600',
    paymentDetail: {
      paymentMethodType: 'PAY_LATER',
      targetOrg: 'KLARNA',
      buyerInfo: {
          'clientIp': '146.75.136.237',
          'userAgent': 'Chrome',
          'email':'payermaxtest@gmail.com'
      }
    },
    frontCallbackUrl: 'https://',
    subject: 'River Game HK Limited',
    outTradeNo: 'jemy1772159278936',
    notifyUrl: 'https://',
    userId: 'jemy123123',
    integrate: 'Direct_Payment',
    terminalType: 'WEB'
  },
  merchantNo: '010113827355079',
  appId: '04d20279df374af8871d1da97c673894',
  version: '1.5'
}

```

返回：直接返回渠道支付页面，前端打开给用户完成支付即可

``` json
{
        "msg": "Success.",
        "code": "APPLY_SUCCESS",
        "data": {
                "redirectUrl": "https://pay.klarna.com/eu/hpp/payments/2e2p3LJ",
                "outTradeNo": "jemy1772159278936",
                "tradeToken": "T2026022702039087822428",
                "status": "PENDING"
        }
}
```

### 方式二：返回qrCode

商户服务端：调用[/orderAndPay API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderAndPay(for-drop-dont-copy-me)/post) 接口发起HTTP POST请求，创建支付。

[/orderAndPay](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-orderAndPay(for-drop-dont-copy-me)/post) 接口请求示例：

``` json
{
  requestTime: '2026-02-27T10:55:36.747+08:00',
  keyVersion: '1',
  data: {
    totalAmount: '1',
    country: 'SG',
    currency: 'SGD',
    expireTime: '3600',
    paymentDetail: {
      paymentMethodType: 'REALTIME_PAYMENT',
      targetOrg: 'PAYNOW',
      buyerInfo: {
          'clientIp': '146.75.136.237',
          'userAgent': 'Chrome',
          'email':'payermaxtest@gmail.com'
      }
    },
    frontCallbackUrl: 'https://',
    subject: 'River Game HK Limited',
    outTradeNo: 'jemy1772160936746',
    notifyUrl: 'https://',
    userId: 'jemy123123',
    integrate: 'Direct_Payment',
    terminalType: 'WEB'
  },
  merchantNo: '010113827355079',
  appId: '04d20279df374af8871d1da97c673894',
  version: '1.5'
}
```

返回：需要将qrCode解码成二维码展示在前端，用户扫码完成支付

``` json
{
        "msg": "Success.",
        "code": "APPLY_SUCCESS",
        "data": {
                "contentExpireTime": "2026-02-27T03:50:38.218Z",
                "qrCode": "00020101021226580009SG.PAYNOW010120213202038734WIPY0301004142026022711503852040000530370254041.005802SG5925SMART MEDIA4U TECHNOLOGY 6009Singapore62200116PPC33920008096756304401D",
                "outTradeNo": "jemy1772160936746",
                "tradeToken": "T2026022702339289832484",
                "status": "PENDING"
        }
}
```
