first commit
This commit is contained in:
82
lib/Service/Aggpay/AggpayClientBuilder.php
Normal file
82
lib/Service/Aggpay/AggpayClientBuilder.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Aggpay;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\AuthorityReqRegistryImpl;
|
||||
use Yeepay\Yop\Sdk\Auth\AuthorizationReqRegistry;
|
||||
use Yeepay\Yop\Sdk\Auth\AuthorizationReqSupport;
|
||||
use Yeepay\Yop\Sdk\Client\ClientParams;
|
||||
use Yeepay\Yop\Sdk\Client\Support\ClientParamsSupport;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfig;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfigProvider;
|
||||
use Yeepay\Yop\Sdk\Config\DefaultAppSdkConfigProvider;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
|
||||
class AggpayClientBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AuthorizationReqRegistry
|
||||
*/
|
||||
private static $authorizationReqRegistry;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$authorizationReqRegistry = new AuthorityReqRegistryImpl();
|
||||
self::$authorizationReqRegistry->register('pay',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('prePay',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('violationWechatChannel',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('wechatConfigAdd',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('wechatConfigAdd_0',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('wechatConfigQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('wechatConfigQuery_0',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var ClientParams
|
||||
*/
|
||||
private $clientParams;
|
||||
|
||||
/**
|
||||
* AggpayClientBuilder constructor.
|
||||
* @param ClientParams $clientParams
|
||||
*/
|
||||
public function __construct(ClientParams $clientParams)
|
||||
{
|
||||
$this->clientParams = $clientParams;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return new AggpayClient($this->clientParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config AppSdkConfig|array|AppSdkConfigProvider
|
||||
* @return AggpayClientBuilder
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function builder($config)
|
||||
{
|
||||
$appSdkConfigProvider = null;
|
||||
if ($config instanceof AppSdkConfigProvider) {
|
||||
$appSdkConfigProvider = $config;
|
||||
} else {
|
||||
$appSdkConfigProvider = new DefaultAppSdkConfigProvider($config);
|
||||
}
|
||||
$clientParams = ClientParamsSupport::generateClientParams($appSdkConfigProvider);
|
||||
$clientParams->setAuthorizationReqRegistry(self::$authorizationReqRegistry);
|
||||
|
||||
return new AggpayClientBuilder($clientParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AggpayClientBuilder::__init();
|
||||
Reference in New Issue
Block a user