文档控制台
文档首页/
Paynicorn 支付/
API 文档/
流量充值/

流量充值

更新时间:2024.06.25 09:52:42

流量充值

流量充值接口

接口说明

给指定手机充值流量

接口地址

post https://api.paynicorn.com/trade/topup/api/data/topup

请求参数

参数名参数类型填写说明描述
transIdstringM商户订单 ID
appKeystringM商户应用Appkey
benefitNostringM要充值的号码
goodsIdstringM产品ID(根据流量产品查询接口返回或者联系运营获取支持列表)
memostringO备注

响应参数

参数名参数类型填写要求描述
codeintM请求处理的标识
msgstringM请求处理信息
resultJsonObjO返回结果
result对象参数
参数名参数类型填写要求描述
transIdstringM商户订单 ID
orderIdstringM流量充值订单号
statusCodestringM交易状态
descriptionstringM描述

报文示例

Request

{
    "transId":"V3T1719295709739",
    "appKey": "T90B124766qU95d385O4",
    "benefitNo": "09027402327",
    "goodsId": "NG72815291251",
    "memo": "流量充值"
}

Response

{
      "code": 1200,
      "msg": "success",
      "result": {
              "transId": "V3T1712748436358",
              "statusCode": "0",
              "description": "transaction in process",
              "orderId": 12418205871439923
      }
}

注意:

  1. 若同步响应返回下述错误码和错误消息,商户可以主动关单:
code 错误代码msg 错误消息
4001invalid signature
4002invalid appId
4003unsupported business
4004unsupported amount
4005invalid packageId
4006invalid benefitNo
4007invalid transId
4008transId is null
4009transId already exist
4010phone number is empty
4011unknown operator
4012no active wallet of this currency
4013Insufficient balance
4014Exceed the minute limit
4015Exceed the daily times limit
4016channel disable
4017channelCode is null
4018channelCode is error
4019sp product is null
4020appKey is null
4021callbackUrl is null
4022callback url error
4023secret key is null
4024unknown appKey
4025sp order mapping error
4027Pleas check product information
4027Please activate the product function
4028Paynicorn CP Insufficient balance
4030Recharge phone error
4031Recharge country error
4032Recharge operator error
4033Exceed operator the minute limit
  1. 若同步响应返回的结果如下,则可以结合业务逻辑进行判断或者查询此订单的状态来决定是否要关闭此订单:
code 错误代码msg 错误消息
4026merchant Overbooking

上述两种情况的示例报文响应:

{
  "code": 4028, "msg": "Paynicorn CP Insufficient balance"
}

流量充值交易查询接口

接口说明

查询流量充值状态及交易详情信息

接口地址

post https://api.paynicorn.com/trade/topup/api/data/query

请求参数

参数名参数类型填写要求描述
appKeystringM商户应用ID
transIdstringM商户交易号

响应参数

参数名参数类型填写要求描述
codeintM请求处理的标识
msgstringM请求处理信息
resultJsonObjO返回结果
result参数
参数名参数类型填写要求描述
transIdstringM交易ID
statusCodestringM交易状态
countryCodestringM国家码
operatorCodestringM运营商编码
benefitNostringM要充值的号码
goodsIdstringM流量套餐ID
goodsDescstringM流量套餐描述
memostringM备注

报文示例

Request

{
  "appKey": "p3k0Y312LzX6Dv87lVa1",
  "transId": "1234567890"
}

Response

{
    "code": 1200,
    "msg": "success",
    "result": {
        "transId": "1234567890",
        "statusCode":"1",
        "countryCode": "NG",
        "operatorCode": "9mobile",
        "benefitNo": "08184123954",
        "goodsId": "NG72347153587",
        "goodsDesc": "100MB/7Day"
    }
}

若返回的响应如下,本订单可以被主动关闭:

{
  "code": 4007,
  "msg": "invalid transId"
}

查询流量充值产品接口

接口说明

查询paynicorn支持的流量充值产品

接口地址

post https://api.paynicorn.com/trade/topup/api/data/queryGoods

请求参数

参数名参数类型填写要求描述
appKeystringM商户应用Appkey
countryCodestringO国家码,查询指定国家流量产品
productCodestringM产品类型(冗余字段,固定data_topup 流量充值)
operatorCodestringO运营商编码,查询指定运营商流量产品

响应参数

参数名参数类型填写要求描述
codeintM请求处理的标识
msgstringM请求处理信息
resultJsonObjO返回结果
result对象参数
参数名参数类型填写要求描述
productCodestringM产品类型
countryCodestringM国家
operatorCodestringM运营商编码
goodsIdstringM产品ID
goodsDescstringM产品描述
amountstringM产品售价

报文示例

RequestBody

{
    "appKey": "T90B124766qU95d385O4",
    "countryCode": "NG",
    "productCode": "data_topup",
    "operatorCode": "NG_AIRTEL" //选填
}

Response

{
        "code": 1200,
        "msg": "success",
        "result": [{
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815042640",
                "goodsDesc": "40.00MB/1Dayly",
                "amount": 0.13,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815064968",
                "goodsDesc": "100.00MB/1Dayly",
                "amount": 0.26,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815097509",
                "goodsDesc": "200.00MB/3Dayly",
                "amount": 0.53,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815128394",
                "goodsDesc": "350.00MB/7Dayly",
                "amount": 0.79,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815227536",
                "goodsDesc": "750.00MB/14Dayly",
                "amount": 1.33,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815291251",
                "goodsDesc": "1.50G/30Dayly",
                "amount": 2.66,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815309907",
                "goodsDesc": "4.50G/30Dayly",
                "amount": 5.33,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG72815332470",
                "goodsDesc": "10.00G/30Dayly",
                "amount": 7.99,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG77059542091",
                "goodsDesc": "200.00MB/3Dayly",
                "amount": 0.50,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG77059599237",
                "goodsDesc": "750.00MB/14Dayly",
                "amount": 1.25,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG77059651850",
                "goodsDesc": "2.00G/30Dayly",
                "amount": 3.00,
                "currency": "USD"
        }, {
                "productCode": "data_topup",
                "countryCode": "NG",
                "operatorCode": "NG_AIRTEL",
                "goodsId": "NG77059699998",
                "goodsDesc": "10.00G/30Dayly",
                "amount": 7.15,
                "currency": "USD"
        }]
}

手机号查询充值运营商

接口说明

根据手机号查询手机号归属的运营商

接口地址

https://api.paynicorn.com/trade/topup/api/queryOperatorCode

请求方法:post

请求参数

参数名参数类型填写要求描述
nationalPhoneNostringM手机号
countryCodestringM国家码

响应参数

参数名参数类型填写要求描述
codeintM请求处理的标识
msgstringM请求处理信息
resultJsonObjM返回结果

result对象参数

参数名参数类型填写要求描述
countryCodestringM国家编码
currencystringM币种编码
areaCodestringM国家区号
operatorCodestringMPAYNICORN运营商编码
operatorNamestringM运营商全程

报文示例

Request

  {
  "countryCode": "NG",
  "nationalPhoneNo": "07012345678"
  }

Response

  {
  "code": 1200,
  "msg": "success",
      "result": {
        "countryCode": "NG",
        "currency": "NGN",
        "areaCode": "234",
        "operatorCode": "NG_AIRTEL",
        "operatorName": "Airtel Nigeria"
      }
  }

充值异步通知(recharge_callback)

接口说明

充值系统完成充值流程后,会回调商户在后台配置的商户回调接口,通知商户充值结果以及充值详情。

请注意:

  1. 回调接口URL须为外部可正常访问,且不带后缀参数的URL地址,接收请求类型为 POST 。
  2. 本接口只对成功的 流量充值 交易发起回调通知,其余状态的交易需要商户主动查询交易结果

接口地址

商户提供,通过商户平台配置,参见设置应用回调地址

请求参数

响应参数

参数名类型填写要求备注
orderNoStringM充值订单ID
originOrderNoStringM源订单ID(接入方订单ID)
statusIntegerM回调状态(0.充值中,1.成功,2.失败)
timestampIntegerM订单完成时间

充值完成后,充值后台会把充值相关信息发送给商户,商户需要接收处理该回调通知请求,并返回正确应答。 HttpsStatus=200代表接受到通知并返回字符串success,其他代表通知失败。

针对通知失败的订单,没有重试机制。商户可主动通过充值交易查询接口查询最终结果。

报文示例

{
        "deductionAmount": 0.2400,
        "deductionCurrency": "USD",
        "orderNo": "12428686363427123",
        "originOrderNo": "9242868607189027501",
        "status": 1, //0: 充值处理中,1: 充值成功,2:充值失败
        "timestamp": 1717745928,
        "verified": false
}