Skip to content

支付中签约

通过此接口在支付的同时完成扣费服务的签约

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring请求appid
mch_idstring商户号
contract_mchidstring签约商户号
contract_appidstring签约appid
out_trade_nostring商户订单号
device_infostring设备号
bodystring商品描述
detailstring商品详情
attachstring附加数据
notify_urlstring回调通知ur
total_feeinteger总金额
spbill_create_ipstring终端IP
time_startstring交易起始时间
time_expirestring交易结束时间
goods_tagstring商品标记
trade_typestring交易类型
product_idstring商品ID
limit_paystring指定支付方式
openidstring用户标识
plan_idinteger模板id
contract_codestring签约协议号
contract_display_accountstring用户账户展示名称
contract_notify_urlstring签约信息通知url
php
$instance->v2->pay->contractorder->postAsync([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/pay/contractorder')->postAsync([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/pay/contractorder']->postAsync([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->pay->contractorder->post([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/pay/contractorder')->post([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/pay/contractorder']->post([
  'xml' => [
    'appid'                    => 'wxcbda96de0b165486',
    'mch_id'                   => '1200009811',
    'contract_mchid'           => '1200009811',
    'contract_appid'           => 'wxcbda96de0b165486',
    'out_trade_no'             => '123456',
    'device_info'              => '013467007045764',
    'body'                     => 'Ipadmini16G白色',
    'detail'                   => 'Ipadmini16G白色',
    'attach'                   => '深圳分店',
    'notify_url'               => 'http://yoursite.com',
    'total_fee'                => '888',
    'spbill_create_ip'         => '123.12.12.123',
    'time_start'               => '20091225091010',
    'time_expire'              => '20091227091010',
    'goods_tag'                => 'WXG',
    'trade_type'               => 'JSAPI',
    'product_id'               => '12235413214070356458058',
    'limit_pay'                => 'no_credit',
    'openid'                   => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'plan_id'                  => '123',
    'contract_code'            => '100001256',
    'contract_display_account' => '123',
    'contract_notify_url'      => 'http://yoursite.com',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
appidstring公众账号id
mch_idstring商户号
nonce_strstring随机字符串
signstring签名
err_codestring错误代码
err_code_desstring错误代码描述
contract_result_codestring预签约结果
contract_err_codestring预签约错误代码
contract_err_code_desstring预签约错误描述
prepay_idstring预支付交易会话标识
trade_typestring交易类型
code_urlstring二维码链接
plan_idinteger模板id
request_serialstring请求序列号
contract_codestring签约协议号
contract_display_accountstring用户账户展示名称
mweb_urlstring支付跳转链接
out_trade_nostring商户订单号

参阅 官方文档

Published on the GitHub by TheNorthMemory