mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 03:07:38 +08:00
兼容 symfony/event-dispatcher 4.3 && 删除已废弃代码
This commit is contained in:
parent
9c1b3c0f98
commit
83fed108fd
@ -14,15 +14,15 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"php": ">=7.1.3",
|
||||
"ext-openssl": "*",
|
||||
"ext-simplexml":"*",
|
||||
"ext-libxml": "*",
|
||||
"ext-json": "*",
|
||||
"yansongda/supports": "^1.8",
|
||||
"monolog/monolog": "^1.23",
|
||||
"symfony/http-foundation": "^3.0|^4.0",
|
||||
"symfony/event-dispatcher": "^3.0|^4.0"
|
||||
"symfony/http-foundation": "^4.0",
|
||||
"symfony/event-dispatcher": "^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.2",
|
||||
|
@ -3,73 +3,24 @@
|
||||
namespace Yansongda\Pay;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @method static Event dispatch($eventName, Event $event = null) Dispatches an event to all registered listeners
|
||||
* @method static Event dispatch(Event $event) Dispatches an event to all registered listeners
|
||||
* @method static array getListeners($eventName = null) Gets the listeners of a specific event or all listeners sorted by descending priority.
|
||||
* @method static int|null getListenerPriority($eventName, $listener) Gets the listener priority for a specific event.
|
||||
* @method static int|void getListenerPriority($eventName, $listener) Gets the listener priority for a specific event.
|
||||
* @method static bool hasListeners($eventName = null) Checks whether an event has any registered listeners.
|
||||
* @method static addListener($eventName, $listener, $priority = 0) Adds an event listener that listens on the specified events.
|
||||
* @method static void addListener($eventName, $listener, $priority = 0) Adds an event listener that listens on the specified events.
|
||||
* @method static removeListener($eventName, $listener) Removes an event listener from the specified events.
|
||||
* @method static addSubscriber(EventSubscriberInterface $subscriber) Adds an event subscriber.
|
||||
* @method static removeSubscriber(EventSubscriberInterface $subscriber)
|
||||
* @method static void addSubscriber(EventSubscriberInterface $subscriber) Adds an event subscriber.
|
||||
* @method static void removeSubscriber(EventSubscriberInterface $subscriber)
|
||||
*/
|
||||
class Events
|
||||
{
|
||||
/**
|
||||
* Start pay.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\PayStarting")
|
||||
*/
|
||||
const PAY_STARTING = 'yansongda.pay.starting';
|
||||
|
||||
/**
|
||||
* Pay started.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\PayStarted")
|
||||
*/
|
||||
const PAY_STARTED = 'yansongda.pay.started';
|
||||
|
||||
/**
|
||||
* Api requesting.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\ApiRequesting")
|
||||
*/
|
||||
const API_REQUESTING = 'yansongda.pay.api.requesting';
|
||||
|
||||
/**
|
||||
* Api requested.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\ApiRequested")
|
||||
*/
|
||||
const API_REQUESTED = 'yansongda.pay.api.requested';
|
||||
|
||||
/**
|
||||
* Sign error.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\SignFailed")
|
||||
*/
|
||||
const SIGN_FAILED = 'yansongda.pay.sign.failed';
|
||||
|
||||
/**
|
||||
* Receive request.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\RequestReceived")
|
||||
*/
|
||||
const REQUEST_RECEIVED = 'yansongda.pay.request.received';
|
||||
|
||||
/**
|
||||
* Method called.
|
||||
*
|
||||
* @Event("Yansongda\Pay\Events\MethodCalled")
|
||||
*/
|
||||
const METHOD_CALLED = 'yansongda.pay.method.called';
|
||||
|
||||
/**
|
||||
* dispatcher.
|
||||
*
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace Yansongda\Pay\Events;
|
||||
|
||||
class Event extends \Symfony\Component\EventDispatcher\Event
|
||||
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;
|
||||
|
||||
class Event extends SymfonyEvent
|
||||
{
|
||||
/**
|
||||
* Driver.
|
||||
|
@ -12,7 +12,6 @@ use Yansongda\Pay\Exceptions\InvalidConfigException;
|
||||
use Yansongda\Pay\Exceptions\InvalidGatewayException;
|
||||
use Yansongda\Pay\Exceptions\InvalidSignException;
|
||||
use Yansongda\Pay\Gateways\Alipay\Support;
|
||||
use Yansongda\Pay\Log;
|
||||
use Yansongda\Supports\Collection;
|
||||
use Yansongda\Supports\Config;
|
||||
use Yansongda\Supports\Str;
|
||||
@ -117,7 +116,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
*/
|
||||
public function pay($gateway, $params = [])
|
||||
{
|
||||
Events::dispatch(Events::PAY_STARTING, new Events\PayStarting('Alipay', $gateway, $params));
|
||||
Events::dispatch(new Events\PayStarting('Alipay', $gateway, $params));
|
||||
|
||||
$this->payload['return_url'] = $params['return_url'] ?? $this->payload['return_url'];
|
||||
$this->payload['notify_url'] = $params['notify_url'] ?? $this->payload['notify_url'];
|
||||
@ -161,13 +160,13 @@ class Alipay implements GatewayApplicationInterface
|
||||
$data['fund_bill_list'] = htmlspecialchars_decode($data['fund_bill_list']);
|
||||
}
|
||||
|
||||
Events::dispatch(Events::REQUEST_RECEIVED, new Events\RequestReceived('Alipay', '', $data));
|
||||
Events::dispatch(new Events\RequestReceived('Alipay', '', $data));
|
||||
|
||||
if (Support::verifySign($data)) {
|
||||
return new Collection($data);
|
||||
}
|
||||
|
||||
Events::dispatch(Events::SIGN_FAILED, new Events\SignFailed('Alipay', '', $data));
|
||||
Events::dispatch(new Events\SignFailed('Alipay', '', $data));
|
||||
|
||||
throw new InvalidSignException('Alipay Sign Verify FAILED', $data);
|
||||
}
|
||||
@ -179,7 +178,6 @@ class Alipay implements GatewayApplicationInterface
|
||||
*
|
||||
* @param string|array $order
|
||||
* @param string $type
|
||||
* @param bool $transfer @deprecated since v2.7.3
|
||||
*
|
||||
* @throws GatewayException
|
||||
* @throws InvalidConfigException
|
||||
@ -187,22 +185,8 @@ class Alipay implements GatewayApplicationInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function find($order, $type = 'wap', $transfer = false): Collection
|
||||
public function find($order, $type = 'wap'): Collection
|
||||
{
|
||||
if ($type === true || $transfer) {
|
||||
Log::warning('DEPRECATED: In Alipay->find(), the REFUND/TRANSFER param is deprecated since v2.7.3, use TYPE param instead!');
|
||||
@trigger_error('In yansongda/pay Alipay->find(), the REFUND/TRANSFER param is deprecated since v2.7.3, use TYPE param instead!', E_USER_DEPRECATED);
|
||||
|
||||
$type = $type === true ? 'refund' : 'transfer';
|
||||
}
|
||||
|
||||
if ($type === false) {
|
||||
Log::warning('DEPRECATED: In Alipay->find(), the REFUND/TRANSFER param is deprecated since v2.7.3, use TYPE param instead!');
|
||||
@trigger_error('In yansongda/pay Alipay->find(), the REFUND/TRANSFER param is deprecated since v2.7.3, use TYPE param instead!', E_USER_DEPRECATED);
|
||||
|
||||
$type = 'wap';
|
||||
}
|
||||
|
||||
$gateway = get_class($this).'\\'.Str::studly($type).'Gateway';
|
||||
|
||||
if (!class_exists($gateway) || !is_callable([new $gateway(), 'find'])) {
|
||||
@ -215,7 +199,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
$this->payload['biz_content'] = $config['biz_content'];
|
||||
$this->payload['sign'] = Support::generateSign($this->payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Find', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Find', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi($this->payload);
|
||||
}
|
||||
@ -239,7 +223,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
$this->payload['biz_content'] = json_encode($order);
|
||||
$this->payload['sign'] = Support::generateSign($this->payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Refund', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Refund', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi($this->payload);
|
||||
}
|
||||
@ -263,7 +247,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
$this->payload['biz_content'] = json_encode(is_array($order) ? $order : ['out_trade_no' => $order]);
|
||||
$this->payload['sign'] = Support::generateSign($this->payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Cancel', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Cancel', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi($this->payload);
|
||||
}
|
||||
@ -287,7 +271,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
$this->payload['biz_content'] = json_encode(is_array($order) ? $order : ['out_trade_no' => $order]);
|
||||
$this->payload['sign'] = Support::generateSign($this->payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Close', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Close', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi($this->payload);
|
||||
}
|
||||
@ -311,7 +295,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
$this->payload['biz_content'] = json_encode(is_array($bill) ? $bill : ['bill_type' => 'trade', 'bill_date' => $bill]);
|
||||
$this->payload['sign'] = Support::generateSign($this->payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Download', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Download', $this->gateway, $this->payload));
|
||||
|
||||
$result = Support::requestApi($this->payload);
|
||||
|
||||
@ -327,7 +311,7 @@ class Alipay implements GatewayApplicationInterface
|
||||
*/
|
||||
public function success(): Response
|
||||
{
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Success', $this->gateway));
|
||||
Events::dispatch(new Events\MethodCalled('Alipay', 'Success', $this->gateway));
|
||||
|
||||
return Response::create('success');
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class AppGateway implements GatewayInterface
|
||||
));
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'App', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'App', $endpoint, $payload));
|
||||
|
||||
return Response::create(http_build_query($payload));
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class MiniGateway implements GatewayInterface
|
||||
$payload['method'] = 'alipay.trade.create';
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'Mini', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'Mini', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi($payload);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class PosGateway implements GatewayInterface
|
||||
));
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'Pos', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'Pos', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi($payload);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ScanGateway implements GatewayInterface
|
||||
));
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'Scan', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'Scan', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi($payload);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class Support
|
||||
*/
|
||||
public static function requestApi(array $data): Collection
|
||||
{
|
||||
Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data));
|
||||
Events::dispatch(new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data));
|
||||
|
||||
$data = array_filter($data, function ($value) {
|
||||
return ($value == '' || is_null($value)) ? false : true;
|
||||
@ -133,7 +133,7 @@ class Support
|
||||
|
||||
$result = json_decode($result, true);
|
||||
|
||||
Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Alipay', '', self::$instance->getBaseUri(), $result));
|
||||
Events::dispatch(new Events\ApiRequested('Alipay', '', self::$instance->getBaseUri(), $result));
|
||||
|
||||
return self::processingApiResult($data, $result);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class TransferGateway implements GatewayInterface
|
||||
));
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'Transfer', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'Transfer', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi($payload);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class WebGateway implements GatewayInterface
|
||||
$payload['biz_content'] = json_encode($biz_array);
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'Web/Wap', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Alipay', 'Web/Wap', $endpoint, $payload));
|
||||
|
||||
return $this->buildPayHtml($endpoint, $payload, $method);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function pay($gateway, $params = [])
|
||||
{
|
||||
Events::dispatch(Events::PAY_STARTING, new Events\PayStarting('Wechat', $gateway, $params));
|
||||
Events::dispatch(new Events\PayStarting('Wechat', $gateway, $params));
|
||||
|
||||
$this->payload = array_merge($this->payload, $params);
|
||||
|
||||
@ -173,7 +173,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
{
|
||||
$content = $content ?? Request::createFromGlobals()->getContent();
|
||||
|
||||
Events::dispatch(Events::REQUEST_RECEIVED, new Events\RequestReceived('Wechat', '', [$content]));
|
||||
Events::dispatch(new Events\RequestReceived('Wechat', '', [$content]));
|
||||
|
||||
$data = Support::fromXml($content);
|
||||
if ($refund) {
|
||||
@ -187,7 +187,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
return new Collection($data);
|
||||
}
|
||||
|
||||
Events::dispatch(Events::SIGN_FAILED, new Events\SignFailed('Wechat', '', $data));
|
||||
Events::dispatch(new Events\SignFailed('Wechat', '', $data));
|
||||
|
||||
throw new InvalidSignException('Wechat Sign Verify FAILED', $data);
|
||||
}
|
||||
@ -208,20 +208,6 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function find($order, $type = 'wap'): Collection
|
||||
{
|
||||
if ($type === true) {
|
||||
Log::warning('DEPRECATED: In Wechat->find(), the REFUND param is deprecated since v2.7.8, use TYPE param instead!');
|
||||
@trigger_error('In yansongda/pay Wechat->find(), the REFUND param is deprecated since v2.7.8, use TYPE param instead!', E_USER_DEPRECATED);
|
||||
|
||||
$type = 'refund';
|
||||
}
|
||||
|
||||
if ($type === false) {
|
||||
Log::warning('DEPRECATED: In Wechat->find(), the REFUND param is deprecated since v2.7.8, use TYPE param instead!');
|
||||
@trigger_error('In yansongda/pay Wechat->find(), the REFUND param is deprecated since v2.7.8, use TYPE param instead!', E_USER_DEPRECATED);
|
||||
|
||||
$type = 'wap';
|
||||
}
|
||||
|
||||
if ($type != 'wap') {
|
||||
unset($this->payload['spbill_create_ip']);
|
||||
}
|
||||
@ -236,7 +222,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
|
||||
$this->payload = Support::filterPayload($this->payload, $config['order']);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Find', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Find', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi(
|
||||
$config['endpoint'],
|
||||
@ -262,7 +248,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
{
|
||||
$this->payload = Support::filterPayload($this->payload, $order, true);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Refund', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Refund', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi(
|
||||
'secapi/pay/refund',
|
||||
@ -290,7 +276,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
|
||||
$this->payload = Support::filterPayload($this->payload, $order, true);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Cancel', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Cancel', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi(
|
||||
'secapi/pay/reverse',
|
||||
@ -318,7 +304,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
|
||||
$this->payload = Support::filterPayload($this->payload, $order);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Close', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Close', $this->gateway, $this->payload));
|
||||
|
||||
return Support::requestApi('pay/closeorder', $this->payload);
|
||||
}
|
||||
@ -334,7 +320,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function success(): Response
|
||||
{
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Success', $this->gateway));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Success', $this->gateway));
|
||||
|
||||
return Response::create(
|
||||
Support::toXml(['return_code' => 'SUCCESS', 'return_msg' => 'OK']),
|
||||
@ -361,7 +347,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
|
||||
$this->payload = Support::filterPayload($this->payload, $params, true);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'Download', $this->gateway, $this->payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'Download', $this->gateway, $this->payload));
|
||||
|
||||
$result = Support::getInstance()->post(
|
||||
'pay/downloadbill',
|
||||
|
@ -48,7 +48,7 @@ class AppGateway extends Gateway
|
||||
];
|
||||
$pay_request['sign'] = Support::generateSign($pay_request);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'App', $endpoint, $pay_request));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'App', $endpoint, $pay_request));
|
||||
|
||||
return JsonResponse::create($pay_request);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ abstract class Gateway implements GatewayInterface
|
||||
{
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Wechat', 'PreOrder', '', $payload));
|
||||
Events::dispatch(new Events\MethodCalled('Wechat', 'PreOrder', '', $payload));
|
||||
|
||||
return Support::requestApi('pay/unifiedorder', $payload);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class GroupRedpackGateway extends Gateway
|
||||
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Group Redpack', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Group Redpack', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi(
|
||||
'mmpaymkttransfers/sendgroupredpack',
|
||||
|
@ -45,7 +45,7 @@ class MpGateway extends Gateway
|
||||
];
|
||||
$pay_request['paySign'] = Support::generateSign($pay_request);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'JSAPI', $endpoint, $pay_request));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'JSAPI', $endpoint, $pay_request));
|
||||
|
||||
return new Collection($pay_request);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class PosGateway extends Gateway
|
||||
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Pos', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Pos', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi('pay/micropay', $payload);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class RedpackGateway extends Gateway
|
||||
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Redpack', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Redpack', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi(
|
||||
'mmpaymkttransfers/sendredpack',
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Yansongda\Pay\Gateways\Wechat;
|
||||
|
||||
use Yansongda\Pay\Exceptions\InvalidArgumentException;
|
||||
|
||||
class RefundGateway extends Gateway
|
||||
{
|
||||
/**
|
||||
@ -21,4 +23,35 @@ class RefundGateway extends Gateway
|
||||
'cert' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Pay an order.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param array $payload
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function pay ($endpoint, array $payload)
|
||||
{
|
||||
throw new InvalidArgumentException('Not Support Refund In Pay');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get trade type config.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getTradeType ()
|
||||
{
|
||||
throw new InvalidArgumentException('Not Support Refund In Pay');
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ScanGateway extends Gateway
|
||||
$payload['spbill_create_ip'] = Request::createFromGlobals()->server->get('SERVER_ADDR');
|
||||
$payload['trade_type'] = $this->getTradeType();
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Scan', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Scan', $endpoint, $payload));
|
||||
|
||||
return $this->preOrder($payload);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class Support
|
||||
*/
|
||||
public static function requestApi($endpoint, $data, $cert = false): Collection
|
||||
{
|
||||
Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data));
|
||||
Events::dispatch(new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data));
|
||||
|
||||
$result = self::$instance->post(
|
||||
$endpoint,
|
||||
@ -171,7 +171,7 @@ class Support
|
||||
);
|
||||
$result = is_array($result) ? $result : self::fromXml($result);
|
||||
|
||||
Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result));
|
||||
Events::dispatch(new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result));
|
||||
|
||||
return self::processingApiResult($endpoint, $result);
|
||||
}
|
||||
@ -427,7 +427,7 @@ class Support
|
||||
return new Collection($result);
|
||||
}
|
||||
|
||||
Events::dispatch(Events::SIGN_FAILED, new Events\SignFailed('Wechat', '', $result));
|
||||
Events::dispatch(new Events\SignFailed('Wechat', '', $result));
|
||||
|
||||
throw new InvalidSignException('Wechat Sign Verify FAILED', $result);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class TransferGateway extends Gateway
|
||||
|
||||
$payload['sign'] = Support::generateSign($payload);
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Transfer', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Transfer', $endpoint, $payload));
|
||||
|
||||
return Support::requestApi(
|
||||
'mmpaymkttransfers/promotion/transfers',
|
||||
|
@ -28,7 +28,7 @@ class WapGateway extends Gateway
|
||||
{
|
||||
$payload['trade_type'] = $this->getTradeType();
|
||||
|
||||
Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Wechat', 'Wap', $endpoint, $payload));
|
||||
Events::dispatch(new Events\PayStarted('Wechat', 'Wap', $endpoint, $payload));
|
||||
|
||||
$mweb_url = $this->preOrder($payload)->get('mweb_url');
|
||||
|
||||
|
@ -29,13 +29,13 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
Events::PAY_STARTING => ['writePayStartingLog', 256],
|
||||
Events::PAY_STARTED => ['writePayStartedLog', 256],
|
||||
Events::API_REQUESTING => ['writeApiRequestingLog', 256],
|
||||
Events::API_REQUESTED => ['writeApiRequestedLog', 256],
|
||||
Events::SIGN_FAILED => ['writeSignFailedLog', 256],
|
||||
Events::REQUEST_RECEIVED => ['writeRequestReceivedLog', 256],
|
||||
Events::METHOD_CALLED => ['writeMethodCalledLog', 256],
|
||||
Events\PayStarting::class => ['writePayStartingLog', 256],
|
||||
Events\PayStarted::class => ['writePayStartedLog', 256],
|
||||
Events\ApiRequesting::class => ['writeApiRequestingLog', 256],
|
||||
Events\ApiRequested::class => ['writeApiRequestedLog', 256],
|
||||
Events\SignFailed::class => ['writeSignFailedLog', 256],
|
||||
Events\RequestReceived::class => ['writeRequestReceivedLog', 256],
|
||||
Events\MethodCalled::class => ['writeMethodCalledLog', 256],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user