PHPackages                             kun391/yii2-paypal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kun391/yii2-paypal

ActiveLibrary[API Development](/categories/api)

kun391/yii2-paypal
==================

Process with Paypal

v1.0.1(10y ago)161.6k5[2 issues](https://github.com/kun391/yii2-paypal/issues)[1 PRs](https://github.com/kun391/yii2-paypal/pulls)MITPHP

Since Jul 31Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kun391/yii2-paypal)[ Packagist](https://packagist.org/packages/kun391/yii2-paypal)[ Docs](https://github.com/kun391/yii2-paypal)[ RSS](/packages/kun391-yii2-paypal/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Process Payment with paypal for Yii2
====================================

[](#process-payment-with-paypal-for-yii2)

[![Build Status](https://camo.githubusercontent.com/ad583b7948b9a3f900b14b1915d692d3302ac9dc21bc3aa4d7cf5ba22fbcc703/68747470733a2f2f7472617669732d63692e6f72672f6b756e3339312f796969322d70617970616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kun391/yii2-paypal)[![Latest Stable Version](https://camo.githubusercontent.com/dc66a9ae6b245da682bcc8a4f5a41f7e086a8dcbe80a6095a64ab344514eba72/68747470733a2f2f706f7365722e707567782e6f72672f6b756e3339312f796969322d70617970616c2f762f737461626c65)](https://packagist.org/packages/kun391/yii2-paypal)[![Total Downloads](https://camo.githubusercontent.com/8985667d63645e71934df672d653b9c232bfd6b8a35a702dc756b79ce5763717/68747470733a2f2f706f7365722e707567782e6f72672f6b756e3339312f796969322d70617970616c2f646f776e6c6f616473)](https://packagist.org/packages/kun391/yii2-paypal)[![Monthly Downloads](https://camo.githubusercontent.com/2931ae71d90dea9a260f59ca63c36172447e5fb1b22f9a44dee654692422de9c/68747470733a2f2f706f7365722e707567782e6f72672f6b756e3339312f796969322d70617970616c2f642f6d6f6e74686c79)](https://packagist.org/packages/kun391/yii2-paypal)[![Daily Downloads](https://camo.githubusercontent.com/5b6f27b70d721061f7932eeb5b94a95d1932191fa8c06c0a88f21ec74a8e95af/68747470733a2f2f706f7365722e707567782e6f72672f6b756e3339312f796969322d70617970616c2f642f6461696c79)](https://packagist.org/packages/kun391/yii2-paypal)

Requirements
============

[](#requirements)

- PHP &gt;= 5.4
- php5-curl (System)

Installation
============

[](#installation)

Add to the composer.json file following section:

```
php composer.phar require --prefer-dist kun391/yii2-paypal:"*"

```

or

```
"kun391/yii2-paypal":"dev-master"

```

Add to to you Yii2 config file this part with component settings:

> Create file config.php for RESTAPI and config.php for Classic API every where:

- ClassicAPI

```
/**
 * Information PAYPAL's enviroments for classic API
 * @var string
 */

// E.g:
// If enviroment is Development you should use mode = sandbox and endpoint = api.sandbox.paypal.com
// [
//     'acct1.UserName'  => 'nguyentruongthanh.dn-facilitator-1_api1.gmail.com',
//     'acct1.Password'  => 'GRHYUV2DJHNBFTAA',
//     'acct1.Signature' => 'APP9kKh6roKmPNKj6yBK5oSwdD39ADujX4sfPXjr.hGf1wjRi1THwoVq',
//     'mode'            => 'sandbox',
// ];

// E.g:
// If enviroment is live you should use mode = live
// [
//     'acct1.UserName'  => 'nguyentruongthanh.dn-facilitator-1_api1.gmail.com',
//     'acct1.Password'  => 'GRHYUV2DJHNBFTAA',
//     'acct1.Signature' => 'APP9kKh6roKmPNKj6yBK5oSwdD39ADujX4sfPXjr.hGf1wjRi1THwoVq',
//     'mode'            => 'live',
// ];

return  [
    'acct1.UserName'  => 'nguyentruongthanh.dn-facilitator-1_api1.gmail.com',
    'acct1.Password'  => 'GRHYUV2DJHNBFTAA',
    'acct1.Signature' => 'APP9kKh6roKmPNKj6yBK5oSwdD39ADujX4sfPXjr.hGf1wjRi1THwoVq',
    'mode'            => 'sandbox',
];
```

- RestAPI

```
/**
 * Information PAYPAL's enviroments
 * @var string
 */

// E.g:
// If enviroment is Development you should use mode = sandbox and endpoint = api.sandbox.paypal.com
// $setting = [
//     'endpoint'       => 'api.sandbox.paypal.com',
//     'client_id'      => 'AV92BhCOYzF4Vejrbphu1ksMn4KYSlvbzCTcbLdOMixBvAS7sQZhOvMNkMoG',
//     'secret'         => 'EDdjYm7i8w2XZwWGyTqPfPDJim2dUV1hX_3dhY0fR-HulrENli6043rY_0GO1ro1gnkxVe3bMWNDikvq',
//     'business_owner' => 'nguyentruongthanh.dn-facilitator-1@gmail.com',
// ];

// E.g:
// If enviroment is live you should use mode = live and endpoint = api.paypal.com
// $setting = [
//     'endpoint'       => 'api.paypal.com',
//     'client_id'      => 'AV92BhCOYzF4Vejrbphu1ksMn4KYSlvbzCTcbLdOMixBvAS7sQZhOvMNkMoG',
//     'secret'         => 'EDdjYm7i8w2XZwWGyTqPfPDJim2dUV1hX_3dhY0fR-HulrENli6043rY_0GO1ro1gnkxVe3bMWNDikvq',
//     'business_owner' => 'nguyentruongthanh.dn-facilitator-1@gmail.com',
// ];

$setting = [
    'endpoint'       => 'api.sandbox.paypal.com',
    'client_id'      => 'AX9sEz0g3cCzD_heoGyedx7LKSuEx1Lx7H8aGXIrzQmDhqV-V5bV0sbVFc195mNKbE81OkAPZZi_7dfa',
    'secret'         => 'EDdjYm7i8w2XZwWGyTqPfPDJim2dUV1hX_3dhY0fR-HulrENli6043rY_0GO1ro1gnkxVe3bMWNDikvq',
    'business_owner' => 'nguyentruongthanh.dn-facilitator-1@gmail.com',
];

return \yii\helpers\ArrayHelper::merge(['config' => [
        'mode'                   => 'sandbox',
        'http.ConnectionTimeOut' => 60,
        'log.LogEnabled'         => false,
        'log.FileName'           => '@api/runtime/PayPal.log',
        'log.LogLevel'           => 'FINE',
    ]
], $setting);
```

> Add to config to component of file main.php:

```
...
'payPalClassic'    => [
    'class'        => 'kun391\paypal\ClassicAPI',
    'pathFileConfig' => '',
],
'payPalRest'               => [
    'class'        => 'kun391\paypal\RestAPI',
    'pathFileConfig' => '',
    'successUrl' => '' //full url action return url
    'cancelUrl' => '' //full url action return url
],
...
```

=========

Usage
=====

[](#usage)

> REST API

- Create a invoice with paypal

```
//define params for request
$params = [
    'currency' => 'Usd', // only support currency same PayPal
    'email' => 'nguyentruongthanh.dn@gmail.com',
    'items' => [
        [
            'name' => 'Vinamilk',
            'quantity' => 2,
            'price' => 100
        ],
        [
            'name' => 'Pepsi',
            'quantity' => 3,
            'price' => 90
        ]
    ]
];

// information invoice response
$response = Yii::$app->payPalRest->createInvoice($params);
```

- Get link checkout on PayPal

```
//define params for request
$params = [
    'currency' => 'USD', // only support currency same PayPal
    'description' => 'Buy some item',
    'total_price' => 470,
    'email' => 'nguyentruongthanh.dn@gmail.com',
    'items' => [
        [
            'name' => 'Vinamilk',
            'quantity' => 2,
            'price' => 100
        ],
        [
            'name' => 'Pepsi',
            'quantity' => 3,
            'price' => 90
        ]
    ]
];

$response = Yii::$app->payPalRest->getLinkCheckOut($params);
```

> CLASSIC API

- Get Information Account

```
Attribute matchCriteria you can specify either NAME or NONE. Default: None
Attribute firstName and lastName (Required) if matchCriteria is name.

$params = [
    'email' => 'nguyentruongthanh.dn@gmail.com',
    'matchCriteria' => 'name',
    'firstName' => 'Thanh',
    'lastName'  => 'Nguyen'
];

$response = Yii::$app->payPalClassic->getAccountInfo($params);
```

- Send money (Mass Pay)

```
$params = [
    'email' => 'nguyentruongthanh.dn@gmail.com',
    'balance' => 200,
];

$response = Yii::$app->payPalClassic->sendMoney($params);
``
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 68.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~79 days

Total

2

Last Release

3764d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/805db4ad39f621188a2cf98353878feac6eff89e022ca33853a879600b33fe8a?d=identicon)[kun391](/maintainers/kun391)

---

Top Contributors

[![thanh391](https://avatars.githubusercontent.com/u/9245397?v=4)](https://github.com/thanh391 "thanh391 (30 commits)")[![kun391](https://avatars.githubusercontent.com/u/5398707?v=4)](https://github.com/kun391 "kun391 (13 commits)")[![deepsourcebot](https://avatars.githubusercontent.com/u/60907429?v=4)](https://github.com/deepsourcebot "deepsourcebot (1 commits)")

---

Tags

paypalphprestapiyiiyii2apiyii2paypal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kun391-yii2-paypal/health.svg)

```
[![Health](https://phpackages.com/badges/kun391-yii2-paypal/health.svg)](https://phpackages.com/packages/kun391-yii2-paypal)
```

###  Alternatives

[openbuildings/paypal

PayPal SDK for ExpressCheckout and AdaptivePayments. Supports recurring payments, simple payments, parallel payments and chained payments.

31176.0k](/packages/openbuildings-paypal)[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
