You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Command/JinlingCommand.php

83 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Command;
use App\Helper\Signer;
use App\Service\AppService;
use App\Service\MerchantService;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Hyperf\Contract\ContainerInterface;
/**
* @Command
*/
class JinlingCommand extends HyperfCommand
{
/**
* @var ContainerInterface
*/
protected $container;
protected $admin;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct('jinling');
}
public function configure()
{
parent::configure();
$this->setDescription('廖金灵测试');
}
public function handle()
{
$this->buildPayPrams();
return;
/**
* @var MerchantService
*/
$merchantService = $this->container->make(MerchantService::class);
/**
* @var AppService
*/
$appService = $this->container->make(AppService::class);
$merchant = $merchantService->createMerchant([
'username' => 'elf',
'password' => '123456',
'email' => '360197197@qq.com',
'mobile' => '18760419185',
'ip' => '127.0.0.1'
]);
$appService->createApp($merchant);
}
public function buildPayPrams() {
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O',
];
$data = [
'order_name' => '测试订单',
'currency' => 'CNY',
'amount' => '20',
'notify_url' => 'http://www.baidu.com',
'redirect_url' => 'http://www.google.com',
'out_order_no' => '1122',
'direct_pay' => 0,
'show_pc_pay_url' => 0,
];
$params['data'] = json_encode($data);
$sign = Signer::sign($params, 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O');
$params['sign'] = $sign;
var_dump(json_encode($params));
}
}