请求报关接口

请求报关接口,目前只针对支付成功的订单 charge id 进行报关请求,报关金额为订单金额。注意:此接口强制要求 签名 (Pingplusplus-Signature),需在管理平台上 配置商户公钥,但无须开启。

请求参数描述
app required string应用 ID,查看如何获取App ID
channel required string报关使用的第三方支付渠道。取值范围:1:支付宝类(alipayalipay_pc_directalipay_wapalipay_qrcb_alipaycb_alipay_wapcb_alipay_pc_direct),2:微信类(wxwx_pubwx_pub_qrwx_wapcb_wxcb_wx_pubcb_wx_pub_qrcb_wx_pub_scan),3:银联类(upacpupacp_wapupacp_pcapplepay_upacp)。
trade_no required string商户报关订单号,8 ~ 20 位,且不能与 charge 中的 order_no 相同。
customs_code required string海关编号,详情请参照海关编号说明
amount required int报关金额,取值范围:1~1000000000。
charge required stringcharge 对象 id
transport_amount optional int订单物流金额,默认为0,当 is_splittrue 时,此参数无效。
is_split optional boolean是否拆单,默认值为"false"。
sub_order_no conditional string商户子订单号,1~30位,当 is_splittrue 时此参数必填。
extra conditional map自定义参数,如果渠道为银联或者 Apple Pay 则需要额外参数 extra ,详情请参考下表的 extra 参数说明。
extra 参数描述
pay_account required string支付ID,1~60位,字母、数字和/或特殊符号字符。
certif_type required string证件类型,取值范围参考:"01":身份证;"02":军官证;"03":护照;"04":回乡证;"05":台胞证;"06":警官证 "07":士兵证; "99":其它证件。
customer_name required string姓名,1~20位,字母、数字和/或特殊符号字符。
certif_id required string证件号,1~30位,字母、数字和/或特殊符号字符。
tax_amount optional int税费的金额。

返回

返回一个 customs 报关对象,或者返回一个错误,详见 错误

定义

POST https://api.pingxx.com/v1/customs
$cus = \Pingpp\Customs::create();
Customs.create(params)
Pingpp::Customs.create(params)
此语言 SDK 暂不支持该接口。
customs = pingpp.Customs.create();
params := &pingpp.CustomsParams{}
Customs.Create(cuParams)

请求示例

curl https://api.pingxx.com/v1/customs \
-H "Pingplusplus-Signature: SIGNATURE" \
-H "Content-Type: application/json" \
-u sk_live_ibbTe5jLGCi5rzfH4OqPW9KC: \
-d '{
    "app":"App ID",
    "charge":"Charge ID",
    "channel": "upacp",
    "trade_no": "15112496832609",
    "customs_code":"GUANGZHOU",
    "amount":100,
    "transport_amount": 10,
    "is_split": true,
    "sub_order_no": "123456",
    "extra":{
        "pay_account": "1234567890",
        "certif_type": "02",
        "customer_name": "A Name",
        "certif_id": "ID Card No",
        "tax_amount":"10"
    }
}'
try {
    $cus = \Pingpp\Customs::create(
        [
            'app'               => APP_ID,
            'charge'            => 'ch_L8qn10mLmr1GS8e5OODmHaL4',
            'channel'           => 'alipay',
            'trade_no'          => '12332132131',         // 商户报关订单号,8~20位
            'customs_code'      => 'GUANGZHOU',
            'amount'            => 8000,
            'transport_amount'  => 10,
            'is_split'          => true,
            'sub_order_no'      => '123456',
            'extra'  => [
                'pay_account'   => '1234567890',
                'certif_type'   => '02',
                'customer_name' => 'A Name',
                'certif_id'     => 'ID Card No',
                'tax_amount'    => '10',
            ]
        ]
    );
    echo $cus;                                 // 输出 Ping++ 返回的 custom 对象
} catch (\Pingpp\Error\Base $e) {
    if ($e->getHttpStatus() != null) {
        header('Status: ' . $e->getHttpStatus());
        echo $e->getHttpBody();
    } else {
        echo $e->getMessage();
    }
}
public Customs createCustoms() {
        Customs obj = null;
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("channel", "alipay");
        String orderNo = new Date().getTime() + Main.randomString(7);
        params.put("trade_no", orderNo); // 8-20 位,要求数字或字母,不允许其他字符
        params.put("customs_code", "SHANGHAI"); // https://www.pingxx.com/api#海关编号说明
        params.put("amount", 10000); // 报关金额, 人民币单位:分(如金额为 100 元,此处请填 10000)
        params.put("charge", "<CH_ID>");
        params.put("app", appId);
        Map<String, Object> extra = new HashMap<String, Object>();
        // 根据不同渠道传不同参数
        // extra.put("pay_account", "<PAY_ACCOUNT>");
        // extra.put("certif_type", "01"); // https://www.pingxx.com/api#报关接口
        // extra.put("customer_name", "<NAME>");
        // extra.put("certif_id", "<CERTIF_ID>");
        params.put("extra", extra);

        try {
            //发起交易请求
            obj = Customs.create(params);
            System.out.println(obj);
        } catch (APIConnectionException e) {
            e.printStackTrace();
        } catch (ChannelException e) {
            e.printStackTrace();
        } catch (RateLimitException e) {
            e.printStackTrace();
        } catch (AuthenticationException e) {
            e.printStackTrace();
        } catch (APIException e) {
            e.printStackTrace();
        } catch (InvalidRequestException e) {
            e.printStackTrace();
        }
        return obj;
}
trade_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
params = {
  :app => APP_ID,
  :channel => 'upacp', # 支付使用的第三方支付渠道,取值范围:"alipay"(支付宝 APP 支付);"wx"(微信支付)和"upacp"(银联),"applepay_upacp"(Apple Pay)。
  :trade_no => trade_no, # 商户报关订单号,8~20位。
  :customs_code => 'GUANGZHOU',
  :amount => 50000,
  :charge => 'ch_TanbTO9OmjP4TGW5a1j1mPiL',
  :transport_amount => 10,
  :is_split => true,
  :sub_order_no => '201612250200',
  :extra => {
    :pay_account => '8022112223344',
    :certif_type => '02',
    :customer_name => 'Name',
    :certif_id => 'ID_CARD_NUMBER',
    :tax_amount  => 10
  }
}

customs = Pingpp::Customs.create(params)
puts customs
此语言 SDK 暂不支持该接口。
# 商户报关订单号,8~20位
trade_no = ''.join(random.sample(string.ascii_letters + string.digits, 8))

try:
    customs = pingpp.Customs.create(
        app=app_id,
        charge='ch_i2PKhP1qDWNPK9CoqTKQsqb5',
        channel='alipay',
        amount=100,  # 报关金额, 人民币单位:分
        customs_code='GUANGZHOU',
        trade_no=trade_no
    )
    print(customs)  # // 输出 Ping++ 返回的报关对象 Transfer
except Exception as e:
    print(e.http_body)
func ExampleCustoms_new() {
  params := &pingpp.CustomsParams{
    App:          "app_1Gqj58ynP0mHeX1q",
    Charge:       "ch_avbPyT4aDCe1r9W1eHfv1SuP",
    Trade_no:     "123456",
    Customs_code: "GUANGZHOU",
    Amount:       1,
    Is_split:     false,
    Extra: map[string]interface{}{
      "pay_account":   "123456",
      "certif_type":   "02",
      "customer_name": "customer name",
      "certif_id":     "62148502",
      "tax_amount":    10,
    },
  }

  customs, err := customs.New(params)
  if err != nil {
    log.Fatal(err)
    return
  }
  content, _ := json.Marshal(customs)
  fmt.Println(string(content))
}
public static void Example(string appId, string chId)
{
    var cuParams = new Dictionary<string, object>
    {
        {"app", appId},
        {"charge", chId},
        {"channel", "upacp_pc"},
        {"trade_no", new Random().Next(1, 999999999).ToString()},
        {"customs_code", "GUANGZHOU"},
        {"amount", 1},
        {"is_split", true},
        {"sub_order_no", new Random().Next(1, 999999).ToString()},
        {"extra", new Dictionary<string, object>{
            {"pay_account", "123456"},
            {"certif_type", "02"},
            {"customer_name", "customer name"},
            {"certif_id", "62148502"},
            {"tax_amount", 10}
        }}
    };

    Console.WriteLine("****发起海关报关请求****");
    var cu = Customs.Create(cuParams);
    Console.WriteLine(cu);
    Console.WriteLine();

    Console.WriteLine("****查询海关报关对象****");
    Console.WriteLine(Customs.Retrieve(cu.Id));
    Console.WriteLine();
}

返回示例

{
    "id": "14201607013878045463",
    "object": "customs",
    "app": "app_LibTW1n1SOq9Pin1",
    "charge_id": "ch_L8qn10mLmr1GS8e5OODmHaL4",
    "channel": "alipay",
    "trade_no": "15112496832609",
    "customs_code": "GUANGZHOU",
    "amount": 100,
    "status": "succeeded",
    "created": 1410834527,
    "time_succeeded": 1410838127,
    "failure_code": null,
    "failure_msg": null,
    "transaction_no": "201609061456194799218",
    "extra":{}
}