You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
<?php
|
|
|
|
use UnifyPayment\Cores\Struct\CreateOrder;
|
|
use UnifyPayment\Factory;
|
|
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 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']));
|
|
}
|
|
} |