Skip to content

Commit

Permalink
新增JSAPI下单服务商示例 (#2850)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsc020915 authored Oct 16, 2024
1 parent 976c602 commit 540aa1c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/src/6.x/pay/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,35 @@ $response = $api->post('/mmpaymkttransfers/promotion/transfers', [
print_r($response->toArray());
```
</details>


<details>
<summary>JSAPI下单(服务商)</summary>

> 官方文档:<[https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_1.shtml](https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/partner-jsons/partner-jsapi-prepay.html)>
```php
$response = $app->getClient()->postJson("v3/pay/partner/transactions/jsapi", [
"sp_appid" => $appId, // 服务商应用ID
"sp_mchid" => '********', // 服务商户号
'sub_mchid' => '*********', // 子商户号/二级商户号
"sub_appid" => '********', // 子商户/二级商户应用ID(选填)
"description" => $this->payDesc($from), // 商品描述
"out_trade_no" => $order['pay_sn'], // 商户订单号
"notify_url" => $this->config['notify_url'], // 通知地址
"amount" => [
"total" => intval($order['order_amount'] * 100), // 总金额
], // 订单金额信息
"payer" => [
"sp_openid" => $this->auth['openid'], // 用户服务标识,户在服务商AppID下的唯一标识
"sub_openid" => $this->auth['openid'] // 用户子标识,用户在子商户AppID下的唯一标识。若传sub_openid,那sub_appid必填。下单前需获取到用户的OpenID
], // 支付者,(sp_openid 和 sub_openid 二选一)
'attach' => $from
]);

print_r($response->toArray());
```
</details>

<!--
<details>
Expand Down

0 comments on commit 540aa1c

Please sign in to comment.