Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Commit b587978

Browse files
author
phx
committed
增加线下渠道的支持和线下扫码撤销接口
1 parent 4001c80 commit b587978

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ try {
8282
| `$gateway->purchase()` | 创建 Charge |
8383
| `$gateway->fetchTransaction()` | 查询单笔 Charge |
8484
| `$gateway->fetchTransactionList()` | 查询 Charge 列表 |
85+
| `$gateway->reverse()` | Charge 撤销(仅支持isv线下渠道,如已支付会退款) |
8586
| `$gateway->refund()` | 创建退款 |
8687
| `$gateway->fetchRefund()` | 查询单笔退款 |
8788
| `$gateway->fetchRefundList()` | 查询退款列表 |
@@ -152,6 +153,16 @@ $transaction->setTransactionReference('ch_DaHuXHjHeX98GO84COzbfTiP');
152153
$response = $transaction->send();
153154
```
154155

156+
### Reverse Charge (撤销单笔 Charge,只支持isv_*线下渠道。如已付款,则撤销会退款)
157+
```php
158+
/**
159+
* @var \Omnipay\Pingpp\Message\ReverseTransactionRequest $transaction
160+
*/
161+
$transaction = $gateway->reverse();
162+
$transaction->setTransactionReference('ch_DaHuXHjHeX98GO84COzbfTiP');
163+
$response = $transaction->send();
164+
```
165+
155166
### Fetch Charge List (查询 Charge 列表)
156167
```php
157168
/**

src/Common/Channels.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,20 @@ abstract class Channels
164164
* 通联代付(Transfer)
165165
*/
166166
const ALLINPAY = 'allinpay';
167+
168+
/**
169+
* 线下扫码(主扫)
170+
*/
171+
const ISV_QR = 'isv_qr';
172+
173+
/**
174+
* 线下扫码(被扫)
175+
*/
176+
const ISV_SCAN = 'isv_scan';
177+
178+
/**
179+
* 线下扫码(固定码)
180+
*/
181+
const ISV_WAP = 'isv_wap';
182+
167183
}

src/Gateway.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ public function refund(array $parameters = array())
143143
return $this->createRequest(\Omnipay\Pingpp\Message\RefundRequest::class, $parameters);
144144
}
145145

146+
/**
147+
* Reverse Charge Request (ISV_* channels supported only)
148+
*
149+
* @param array $parameters
150+
* @return \Omnipay\Common\Message\AbstractRequest
151+
*/
152+
public function reverse(array $parameters = array())
153+
{
154+
return $this->createRequest(\Omnipay\Pingpp\Message\ReverseTransactionRequest::class, $parameters);
155+
}
156+
146157
/**
147158
* Fetch Transaction Request.
148159
*
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Pingpp Reverse Transaction Request.
4+
*/
5+
namespace Omnipay\Pingpp\Message;
6+
7+
/**
8+
* Pingpp Reverse Transaction Request.
9+
*/
10+
class ReverseTransactionRequest extends AbstractRequest
11+
{
12+
/**
13+
* @return array
14+
* @throws \Omnipay\Common\Exception\InvalidRequestException
15+
*/
16+
public function getData()
17+
{
18+
$this->validate('transactionReference');
19+
20+
$data = array();
21+
22+
return $data;
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function getEndpoint()
29+
{
30+
return $this->endpoint.'/charges/'.$this->getTransactionReference().'/reverse';
31+
}
32+
33+
}

0 commit comments

Comments
 (0)