Skip to content

Commit

Permalink
新增支付文件上传方法文档,Fixed #2622
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Nov 28, 2022
1 parent 6b04ca3 commit 558a58f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/src/6.x/pay/media.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## 文件上传

由于微信 v3 对文件类上传使用特殊的签名机制,参见:[微信支付 - 图片上传API](https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter2_1_1.shtml)

因此,我们提供了一个媒体上传方法,方便开发者使用。

```php
$path = '/path/to/your/files/demo.jpg';

$api->uploadMedia('/v3/marketing/favor/media/image-upload', $path);
```

## 自定义 meta 信息

部分接口使用的签名 meta 不一致,所以可以自行传入:

```php
$url = '/v3/...';
$path = '/path/to/your/files/demo.jpg';
$meta = [
'bank_type' => 'CFT',
'filename' => 'demo.jpg',
'sha256' => 'xxxxxxxxxxx',
];

$api->uploadMedia($url, $path, $meta);
```

## 关于 sha256

- 文件,用 `hash_file('sha256', $path)` 计算
- 字符串,用 `hash('sha256', $string)` 计算
1 change: 1 addition & 0 deletions docs/src/6.x/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports = module.exports = [
{ text: 'API 调用', link: '/6.x/client.html' },
{ text: '回调通知', link: '/6.x/pay/server.html' },
{ text: '工具', link: '/6.x/pay/utils.html' },
{ text: '文件上传', link: '/6.x/pay/media.html' },
{ text: '代码示例', link: '/6.x/pay/examples.html' }
]
},
Expand Down

0 comments on commit 558a58f

Please sign in to comment.