PHPackages                             betsuno/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. betsuno/yii2-paypal

AbandonedLibrary[API Development](/categories/api)

betsuno/yii2-paypal
===================

Process with Paypal

v0.2(7y ago)0579Apache-2.0PHP

Since Jul 31Pushed 6y ago2 watchersCompare

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

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

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

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

[![Build Status](https://camo.githubusercontent.com/2493df88f2c4cebb0b5fa2a2551dd4915f49dd38261212cca2a6c78108444ff6/68747470733a2f2f7472617669732d63692e6f72672f42657473754e6f2f796969322d70617970616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/BetsuNo/yii2-paypal)

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

[](#installation)

Add to the composer.json file following section:

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

```

or

```
"betsuno/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'        => 'betsuno\paypal\ClassicAPI',
    'pathFileConfig' => '',
],
'payPalRest'               => [
    'class'        => 'betsuno\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

```
$params = [
    'email' => 'nguyentruongthanh.dn@gmail.com',
    '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

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~999 days

Total

2

Last Release

2664d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8bb28e87428383d3adaf380f079a5971ccd28b3c9f9f2183870d2f4e219fc9d4?d=identicon)[BetsuNo](/maintainers/BetsuNo)

---

Top Contributors

[![thanh391](https://avatars.githubusercontent.com/u/9245397?v=4)](https://github.com/thanh391 "thanh391 (28 commits)")[![BetsuNo](https://avatars.githubusercontent.com/u/12868790?v=4)](https://github.com/BetsuNo "BetsuNo (6 commits)")[![kun391](https://avatars.githubusercontent.com/u/5398707?v=4)](https://github.com/kun391 "kun391 (5 commits)")[![sergeivl](https://avatars.githubusercontent.com/u/15172324?v=4)](https://github.com/sergeivl "sergeivl (1 commits)")

---

Tags

apiyii2paypal

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kun391/yii2-paypal

Process with Paypal

161.6k](/packages/kun391-yii2-paypal)[openbuildings/paypal

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

31176.4k](/packages/openbuildings-paypal)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

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

PHPackages © 2026

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