kongoon / yii2-paypal
The PayPal extension for the Yii2 framework based on marciocamello/yii2-paypal
Installs: 1 101
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 38
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.3.0
- ext-curl: *
- ext-json: *
- paypal/rest-api-sdk-php: *
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-12-11 14:22:18 UTC
README
PayPal payment extension for the Yii2.
Installation
Add to the composer.json file following section:
php composer.phar require --prefer-dist kongoon/yii2-paypal "*"
"kongoon/yii2-paypal": "dev-master"
Add to to you Yii2 config file this part with component settings:
'paypal'=> [ 'class' => 'kongoon\yii2\paypal\Paypal', 'clientId' => 'you_client_id', 'clientSecret' => 'you_client_secret', 'isProduction' => false, // This is config file for the PayPal system 'config' => [ 'http.ConnectionTimeOut' => 30, 'http.Retry' => 1, 'mode' => \kongoon\yii2\Paypal::MODE_SANDBOX, // sandbox | live 'log.LogEnabled' => YII_DEBUG ? 1 : 0, 'log.FileName' => '@runtime/logs/paypal.log', 'log.LogLevel' => \kongoon\yii2\Paypal::LOG_LEVEL_FINE, // FINE | INFO | WARN | ERROR ] ],
How Use
private function pay() { Yii::$app->paypal->init(); $apiContext = Yii::$app->paypal->getApiContext(); // [..] $payment = new Payment(); try { $payment->create($apiContext); } catch (Exception $ex) { echo PaypalError($e); exit(1); } $approvalUrl = $payment->getApprovalLink(); }