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

95 lines
2.8 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Command;
use App\Helper\Signer;
use App\Service\AppService;
use App\Service\MerchantService;
2 years ago
use App\Service\PaymentService;
2 years ago
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Contract\ContainerInterface;
2 years ago
use Hyperf\Command\Annotation\Command;
2 years ago
/**
* @Command
*/
class JinlingCommand extends HyperfCommand
{
/**
* @var ContainerInterface
*/
protected $container;
protected $admin;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct('jinling');
}
2 years ago
public function configure(): void
2 years ago
{
parent::configure();
$this->setDescription('廖金灵测试');
}
2 years ago
public function handle(): void
2 years ago
{
2 years ago
/**
2 years ago
* @var PaymentService $paymentService
2 years ago
*/
$paymentService = $this->container->make(PaymentService::class);
$paramsJson = '{"return_code":"SUCCESS","nonce_str":"4a40481401bb47cc81411ab3a8181bad","timestamp":1682659313039,"sign":"5AD859576B783CB44D1FAA0E7DD4C463","order_no":"TR23042830042195760003775","out_order_no":"2023042813194700001","total_amount":2,"currency":"AUD","order_time":"20230428151948","pay_time":"20230428152021","exchange_rate":459899100,"cny_amount":9}';
2 years ago
$params = json_decode($paramsJson, true);
2 years ago
$ret = $paymentService->notify($params);
var_dump($ret);
return;
2 years ago
$this->buildPayPrams();
return;
/**
2 years ago
* @var MerchantService $merchantService
2 years ago
*/
$merchantService = $this->container->make(MerchantService::class);
/**
2 years ago
* @var AppService $appService
2 years ago
*/
$appService = $this->container->make(AppService::class);
$merchant = $merchantService->createMerchant([
'username' => 'elf',
'password' => '123456',
'email' => '360197197@qq.com',
'mobile' => '18760419185',
2 years ago
'ip' => '127.0.0.1',
2 years ago
]);
$appService->createApp($merchant);
}
2 years ago
public function buildPayPrams(): void
{
2 years ago
$params = [
'app_id' => '202304270000004',
'timestamp' => time(),
'nonce_str' => 'lSHKbuFngCXHN8Ue1s8QHAAzPvOL3u9O',
];
$data = [
'order_name' => '测试订单',
'currency' => 'CNY',
2 years ago
'amount' => '10',
2 years ago
'notify_url' => 'https://www.baidu.com',
'redirect_url' => 'https://www.google.com',
2 years ago
'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));
}
2 years ago
}