swapwink/components

此包已被废弃且不再维护。未建议替代包。

与SwapWink核心通信的组件

安装: 429

依赖者: 0

建议者: 0

安全性: 0

类型:yii2-extension

0.2.10 2017-07-20 15:47 UTC

README

与SwapWink核心通信的组件

需求

  • Yii2
  • linslin/yii2-curl

安装

推荐使用composer进行安装 (http://getcomposer.org/download/)。

要么

composer require swapwink/components

在composer.json的require部分

"swapwink/components": "*"

安装完成后,您需要将以下代码添加到您的yii2项目组件列表中

SwapWink 用户

配置

'components' => [
	...
	'coreusers' => [
		'class' => '\swapwink\components\UsersComponent',
		'client_id' => 'client_id',
		'client_secret' => 'client_secret',
		'uri_api' => 'uri_api'
	],	
	...
],

使用

通过id获取用户

    $usercore = Yii::$app->coreusers->getUserById($id);

通过别名获取用户

    $usercore = Yii::$app->coreusers->getUserByAlias($alias);

通过别名或名称搜索用户

    $usercore = Yii::$app->coreusers->findUsers($alias)

SwapWink 合作伙伴

配置

'components' => [
	...
	'coreAffiliates' => [
		'class' => '\swapwink\components\AffiliatesComponent',
	],	
	...
],

使用

Yii::$app->coreAffiliates->getAffiliatesByUserId($user_id);

SwapWink 交易

配置

'components' => [
	...
	'coreTransactions' => [
		'class' => '\swapwink\components\TransactionsComponent',
	],	
	...
],

使用

Yii::$app->coreTransactions->create($data);

PayPal

配置

'components' => [
    ...
    'paypal' => [
            'class' => 'swapwink\components\PaypalComponent',
            'returnUrl' => 'paypal/confirm?success=true',
            'cancelUrl' => 'paypal/cancel?cancel=true',
            'clientId' => 'client_id',
            'isProduction' => false,
            'config' => [
                'mode' => \swapwink\components\PaypalComponent::MODE_SANDBOX
                'http.ConnectionTimeOut' => 30,
                'http.Retry' => 1,
                'log.LogEnabled' => 1,
                'log.LogLevel' => \swapwink\components\PaypalComponent::LOG_LEVEL_FINE
            ]
    ]
    ...
]

使用

$response = Yii::$app->paypal->executePaypalPayment($payment_id, $payer_id);