|
|
|
<?php
|
|
|
|
|
|
|
|
use UnifyPayment\Cores\Struct\CreateMedicalInsuranceOrder;
|
|
|
|
use UnifyPayment\Cores\Struct\CreateOrder;
|
|
|
|
use UnifyPayment\Factory;
|
|
|
|
use UnifyPayment\Mock\CreateMedicalInsuranceOrderHandler;
|
|
|
|
use UnifyPayment\Mock\CreateOrderHandler;
|
|
|
|
|
|
|
|
class PayTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testMiniProgramJsapi()
|
|
|
|
{
|
|
|
|
$order = new CreateOrder('当天挂号', 'FD2022080310000055123451223', 0.01, '1', '002197|小程序', 'A', 'ovIGQwOy1e-Zptyug20l5hqI0P5Q', 'https://www.baidu.com');
|
|
|
|
|
|
|
|
$mockHandler = new CreateOrderHandler(true);
|
|
|
|
$response = Factory::pay($this->getConfig())->mini->setMockHandler([$mockHandler])->jsapi($order);
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('response', $response);
|
|
|
|
$this->assertEquals([
|
|
|
|
'appId',
|
|
|
|
'timeStamp',
|
|
|
|
'nonceStr',
|
|
|
|
'package',
|
|
|
|
'signType',
|
|
|
|
'paySign',
|
|
|
|
'merchantId',
|
|
|
|
'merchantName',
|
|
|
|
'channelId',
|
|
|
|
'channelName'
|
|
|
|
], array_keys($response['response']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMiniProgramMedicalPay()
|
|
|
|
{
|
|
|
|
$order = new CreateMedicalInsuranceOrder('DiagPay', 'ow_gnt5QQQ-Qby1234567890', '202204022005169952975171534816', '某某附属医院', '70', '1', 'https://kyey.test.com/pay/notify/wechatINSUNotify', '门诊缴费', 'https://kyey.test.com/wehospital/payment/paymentindex', '2', 'H53011234567', '20220402200530', '530100', '202204022005169952975171534816', '1', '0ef5c63f34237aeba58d0a6f97f66c13', '姓x', '4', '70', '0', '{"payAuthNo":"AUTH530100202204022006310000034","payOrdId":"ORD530100202204022006350000021","setlLatlnt":"102.682296,25.054260"}', 'AAGN9uhZc5EGyRdairKW7Qnu', 'bd787ae69021fbd7d0b86d080b007bad', '127.0.0.1');
|
|
|
|
|
|
|
|
$mockHandler = new CreateMedicalInsuranceOrderHandler(true);
|
|
|
|
$response = Factory::pay($this->getConfig())->mini->setMockHandler([$mockHandler])->medicalPay($order);
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('response', $response);
|
|
|
|
$this->assertEquals([
|
|
|
|
'payUrl',
|
|
|
|
'medTransId',
|
|
|
|
'payAppId',
|
|
|
|
'orderNo',
|
|
|
|
'merchantId',
|
|
|
|
'merchantName',
|
|
|
|
'channelId',
|
|
|
|
'channelName'
|
|
|
|
], array_keys($response['response']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOfficialAccountJsapi()
|
|
|
|
{
|
|
|
|
$order = new CreateOrder('当天挂号', 'FD2022080310000055123451223', 0.01, '1', '002197|公众号', 'A', 'ovIGQwOy1e-Zptyug20l5hqI0P5Q', 'https://www.baidu.com');
|
|
|
|
|
|
|
|
$mockHandler = new CreateOrderHandler(true);
|
|
|
|
$response = Factory::pay($this->getConfig())->official->setMockHandler([$mockHandler])->jsapi($order);
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('response', $response);
|
|
|
|
$this->assertEquals([
|
|
|
|
'appId',
|
|
|
|
'timeStamp',
|
|
|
|
'nonceStr',
|
|
|
|
'package',
|
|
|
|
'signType',
|
|
|
|
'paySign',
|
|
|
|
'merchantId',
|
|
|
|
'merchantName',
|
|
|
|
'channelId',
|
|
|
|
'channelName'
|
|
|
|
], array_keys($response['response']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOfficialAccountMedicalPay()
|
|
|
|
{
|
|
|
|
$order = new CreateMedicalInsuranceOrder('DiagPay', 'ow_gnt5QQQ-Qby1234567890', '202204022005169952975171534816', '某某附属医院', '70', '1', 'https://kyey.test.com/pay/notify/wechatINSUNotify', '门诊缴费', 'https://kyey.test.com/wehospital/payment/paymentindex', '2', 'H53011234567', '20220402200530', '530100', '202204022005169952975171534816', '1', '0ef5c63f34237aeba58d0a6f97f66c13', '姓x', '4', '70', '0', '{"payAuthNo":"AUTH530100202204022006310000034","payOrdId":"ORD530100202204022006350000021","setlLatlnt":"102.682296,25.054260"}', 'AAGN9uhZc5EGyRdairKW7Qnu', 'bd787ae69021fbd7d0b86d080b007bad', '127.0.0.1');
|
|
|
|
|
|
|
|
$mockHandler = new CreateMedicalInsuranceOrderHandler(true);
|
|
|
|
$response = Factory::pay($this->getConfig())->official->setMockHandler([$mockHandler])->medicalPay($order);
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('response', $response);
|
|
|
|
$this->assertEquals([
|
|
|
|
'payUrl',
|
|
|
|
'medTransId',
|
|
|
|
'payAppId',
|
|
|
|
'orderNo',
|
|
|
|
'merchantId',
|
|
|
|
'merchantName',
|
|
|
|
'channelId',
|
|
|
|
'channelName'
|
|
|
|
], array_keys($response['response']));
|
|
|
|
}
|
|
|
|
}
|