# 4.1. Converge Payment API

{% hint style="info" %}
Our converge payment supports all scenarios ​except for​ WeChat Mini Program payment. For Mini Program payment, please ​refer to section [4.2 Wechat Payment APIs](https://newpay-api-document.gitbook.io/newpay-api-document/4.-apis-v1-deprecated/4.2.-wechat-payment-apis)
{% endhint %}

## 1. Overview <a href="#id-1overview" id="id-1overview"></a>

Use this API to get the cashier page address. After getting the cashier page address, you can redirect the user to the cashier page to make a payment.

## 2. Request Info <a href="#id-2request-info" id="id-2request-info"></a>

* **Method: post**
* **Path**

```html
For Website: https://prod-openapi.newpay.la/api/open/converge/pay/v1/createOrder
For Mobile: https://prod-openapi.newpay.la/api/open/converge/pay/v1/m/createOrder
```

### **2.1 Request Header** <a href="#id-21-request-header" id="id-21-request-header"></a>

| Key          | Value            |
| ------------ | ---------------- |
| Content-Type | application/json |
| version      | 1.0              |

### **2.2 Request Data** <a href="#id-22-request-data" id="id-22-request-data"></a>

| Name           | Description                                                                                                | Type      | Required |
| -------------- | ---------------------------------------------------------------------------------------------------------- | --------- | -------- |
| appId          | Unique identifier assigned to a third-party application platform                                           | string    | true     |
| merchantId     | Unique identifier assigned to a third-party merchant                                                       | string    | true     |
| timestamp      | Request timestamp                                                                                          | timestamp | true     |
| sign           | [Data signature](https://newpay-api-document.gitbook.io/newpay-api-document/8.-signature-and-verification) | string    | true     |
| payMethod      | Payment method: 1.NewPay; 3.VISA; 5 WeChat; 6 Alipay                                                       | int       | true     |
| currency       | Payment currency, LAK/USD                                                                                  | string    | true     |
| orderAmt       | Payment amount                                                                                             | string    | true     |
| orderNo        | Order number,The unique number assigned by a merchant to identify a payment request.                       | string    | true     |
| callBackUrl    | Payment result notification URL                                                                            | string    | true     |
| successPageUrl | Transfer address of successful payment                                                                     | string    | true     |
| failurePageUrl | Payment failed to jump address                                                                             | string    | true     |
| cancelPageUrl  | Cancel the payment redirect address                                                                        | string    | true     |
| subject        | Commodity title, ***if alipay, it is required.***                                                          | string    | false    |
| extra          | Third party order supplementary fields, ***if alipay, the alphabet should include ANDROID or IOS”***       | string    | false    |

### **2.3 Response Data** <a href="#id-23-response-data" id="id-23-response-data"></a>

| Name            | Description                                                                                               | Type    |
| --------------- | --------------------------------------------------------------------------------------------------------- | ------- |
| success         | Success flag: true/false                                                                                  | boolean |
| message         | Response message                                                                                          | string  |
| code            | [Reponse code](https://newpay-api-document.gitbook.io/newpay-api-document/9.-business-code#response-code) | string  |
| timestamp       | Response timestamp                                                                                        | long    |
| data            | Result                                                                                                    | object  |
| > appId         | Unique identifier assigned to a third-party application platform                                          | string  |
| > sign          | Data signature                                                                                            | string  |
| > tranAbbr      | Transaction Type                                                                                          | string  |
| > tranNo        | Transaction Number                                                                                        | string  |
| > orderAmt      | Payment amount                                                                                            | string  |
| > payUrl        | Payment address                                                                                           | string  |
| > orderNo       | Order number                                                                                              | string  |
| > newpayOrderNo | NewPay order number                                                                                       | string  |

## 3. Example Data <a href="#id-3-example-data" id="id-3-example-data"></a>

### **3.1 Request** <a href="#id-31-request" id="id-31-request"></a>

```json
{
    "appId": "3514d69403bc4ce1a8fafb6415a31018",
    "timestamp": {{current_timestamp}},
    "sign": "{{sign}}",
    "payMethod": 1,
    "extra": "",
    "currency": "LAK",
    "orderAmt": 50000,
    "merchantId": "876266cdc7154dd08a022fd1f2eace55",
    "orderNo": "ORDERNO000000000A104",
    "subject": "name002",
    "callBackUrl": "www.1231123.com",
    "successPageUrl": "https://prod.newpay.la:8071/jdb/success.html",
    "failurePageUrl": "https://prod.newpay.la:8071/jdb/failure.html",
    "cancelPageUrl": "https://prod.newpay.la:8071/jdb/cancel.html"
}
```

### **3.2 Response** <a href="#id-32-response" id="id-32-response"></a>

```json
{
    "success": true,
    "message": "success",
    "data": {
        "appId": "3514d69403bc4ce1a8fafb6415a31018",
        "sign": "ALa4W6EDAKpZGEuCfpmemOA346bZw6CGrbsy6Xo6J2wYLOldSUrUVyEI0DLpZmHU9tIVp4gi/DENq3rj/nZtXn9grXWhLbX4G+IMEVb3TKEIwTDWZ++I1OfgtuUxOHof711p6A4ga95Xm645Qly/HV8YHoogI7SOw/w352TElhw37o/pIKsSWfeTpXtpfjRs3o69x4EVpDQ0DmYW5zVBCEriBqHvLqjbacOl3HGTa93oALbgQKa5ftAENBOmxi1zNxCOsY+Ecq4apK3tdma1RL+AmrBgmQu8O2vEIWBmlSxg1CY1ZUw2IHixV8D2HHHAn7RQjoDDFePelyB+CLS3GA==",
        "tranAbbr": "FP1005",
        "tranNo": "00012022090700000015",
        "orderAmt": "50000",
        "payUrl": "http://192.168.10.105:8072/BECLPay/page.html?orderNo=202209076000000321",
        "orderNo": "ORDERNO000000000A104",
        "newpayOrderNo": "202209076000000321"
    },
    "code": "0",
    "timestamp": "1662521235625"
}
```

## 4. Wake Up NewPay App <a href="#id-5-wake-up-newpay-app" id="id-5-wake-up-newpay-app"></a>

Invoke NewPay payment through AppLink open, which is the payUrl field in the order response data

### **4.1 iOS** <a href="#id-51-ios" id="id-51-ios"></a>

objective-c eg:

```objective-c
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:response.data.payUrl] options:@{} completionHandler:nil];
```

swift eg:

```swift
let url = URL(string: response.data.payUrl)!
UIApplication.shared.open(url, options: [:], completionHandler: nil)
```

### **4.2 Android** <a href="#id-52-android" id="id-52-android"></a>

Java eg:

```java
String payUrl= response.getData().getPayUrl();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(payUrl));
startActivity(intent);
```

Kotlin eg:

```java
val payUrl = response?.data?.payUrl!!;
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(payUrl))
startActivity(intent)
```
