PHPackages                             payment-gateways/paypal-sdk - 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. [Payment Processing](/categories/payments)
4. /
5. payment-gateways/paypal-sdk

ActiveLibrary[Payment Processing](/categories/payments)

payment-gateways/paypal-sdk
===========================

PayPal SDK

v1.2.0(5y ago)01.4k21MITPHPPHP ^7.4|^8.0

Since Dec 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/payment-gateways/paypal-sdk)[ Packagist](https://packagist.org/packages/payment-gateways/paypal-sdk)[ RSS](/packages/payment-gateways-paypal-sdk/feed)WikiDiscussions 2.x Synced today

READMEChangelogDependencies (4)Versions (14)Used By (1)

[![](https://private-user-images.githubusercontent.com/5879790/261381215-1e87082a-5629-44fb-abdc-b1c82b6902cb.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Nzg0Mzk3NDQsIm5iZiI6MTc3ODQzOTQ0NCwicGF0aCI6Ii81ODc5NzkwLzI2MTM4MTIxNS0xZTg3MDgyYS01NjI5LTQ0ZmItYWJkYy1iMWM4MmI2OTAyY2IucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDUxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA1MTBUMTg1NzI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2FkYjQ5YmFkMjk4NTljZjc0ZTk0NGZhYWVhNWI1MWMzZjkwYzBmYmZmY2FmZjA2MDMwYTNmY2MyN2JkNjIxYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.6WdS87OxwWROpyj1PxUTjYy7oLstSQTTQV36VZrx-F0)](https://private-user-images.githubusercontent.com/5879790/261381215-1e87082a-5629-44fb-abdc-b1c82b6902cb.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Nzg0Mzk3NDQsIm5iZiI6MTc3ODQzOTQ0NCwicGF0aCI6Ii81ODc5NzkwLzI2MTM4MTIxNS0xZTg3MDgyYS01NjI5LTQ0ZmItYWJkYy1iMWM4MmI2OTAyY2IucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDUxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA1MTBUMTg1NzI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2FkYjQ5YmFkMjk4NTljZjc0ZTk0NGZhYWVhNWI1MWMzZjkwYzBmYmZmY2FmZjA2MDMwYTNmY2MyN2JkNjIxYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.6WdS87OxwWROpyj1PxUTjYy7oLstSQTTQV36VZrx-F0)

[![Build Status](https://camo.githubusercontent.com/bea59eb5361f85e1ab3ace76b1cfb5e90af0d5233b8a7e08807f3c8a90bbbb0b/68747470733a2f2f7472617669732d63692e636f6d2f7061796d656e742d67617465776179732f70617970616c2d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/payment-gateways/paypal-sdk)[![Code Quality](https://camo.githubusercontent.com/12da1b63153a529284f3a9319ce1ee86f56e4206f70ce84647967a8d68a9275a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7061796d656e742d67617465776179732f70617970616c2d73646b2e737667)](https://scrutinizer-ci.com/g/payment-gateways/paypal-sdk)[![Code Coverage](https://camo.githubusercontent.com/bc1f0f4c03734b12a053566e550c7cb5be4ff3955becb3c263726b3534598e4c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7061796d656e742d67617465776179732f70617970616c2d73646b2f6261646765732f636f7665726167652e706e673f623d322e78)](https://scrutinizer-ci.com/g/payment-gateways/paypal-sdk/?branch=2.x)

PayPal SDK
==========

[](#paypal-sdk)

This is an SDK for [PayPal REST APIS](https://developer.paypal.com/docs/api/overview/). The following APIs are currently supported.

- [Catalog Products API v1](https://developer.paypal.com/docs/api/catalog-products/v1)
- [Subscriptions API v1](https://developer.paypal.com/docs/api/subscriptions/v1)

[![Bugs](https://camo.githubusercontent.com/632f0919262414d2cf18d5bbce53fc86c71b33b273aa7e24523ea6772aebc8c8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7061796d656e742d67617465776179735f70617970616c2d73646b266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=payment-gateways_paypal-sdk)[![Bugs](https://camo.githubusercontent.com/c3a5a87f9cb06eb2b1760e888495cfc172908ecd972d9f91d8e958a90de64ed1/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7061796d656e742d67617465776179735f70617970616c2d73646b266d65747269633d62756773)](https://sonarcloud.io/dashboard?id=payment-gateways_paypal-sdk)[![Bugs](https://camo.githubusercontent.com/5881b8090ad2cc7f64cc6289ef87fb51cc99df6e3b988b045020d3bf835f2b9a/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7061796d656e742d67617465776179735f70617970616c2d73646b266d65747269633d636f64655f736d656c6c73)](https://sonarcloud.io/dashboard?id=payment-gateways_paypal-sdk)

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

[](#installation)

Use following command to install this library:

```
composer require payment-gateways/paypal-sdk
```

Usage
=====

[](#usage)

Authentication
--------------

[](#authentication)

Go to [PayPal Developer site](https://developer.paypal.com/developer/applications) and get the **Client ID** and **Secret** for your app. These credentials can be used in the service authentication as follows:

```
use PaymentGateway\PayPalSdk\Api\SubscriptionsApi;

$service = new SubscriptionsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
```

Catalog Products API
--------------------

[](#catalog-products-api)

Merchants can use the Catalog Products API to create products, which are goods and services.

### List products

[](#list-products)

To get all products use the `getProducts` method.

```
use PaymentGateway\PayPalSdk\Api\CatalogProductsApi;

$service = new CatalogProductsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
$response = $service->getProducts()->toArray();
```

### Get a product

[](#get-a-product)

To get a single products use the `getProduct` method.

```
use PaymentGateway\PayPalSdk\Api\CatalogProductsApi;

$service = new CatalogProductsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
$response = $service->getProduct('PROD-8R6565867F172242R')->toArray();
```

### Create a product

[](#create-a-product)

To create a product use the `createProduct` method.

```
use PaymentGateway\PayPalSdk\Api\CatalogProductsApi;
use PaymentGateway\PayPalSdk\Products\Constants\ProductType;
use PaymentGateway\PayPalSdk\Products\Constants\ProductCategory;
use PaymentGateway\PayPalSdk\Products\Requests\StoreProductRequest;

$service = new CatalogProductsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');

$productRequest = new StoreProductRequest('My new product', ProductType::SERVICE);
$productRequest->setProductDescription('product description')
    ->setProductCategory(ProductCategory::SOFTWARE)
    ->setImageUrl('https://example.com/productimage.jpg')
    ->setHomeUrl('https://example.com');

// ['id' => 'PROD-XY...', 'name' => 'My new product', ...]
$response = $service->createProduct($productRequest)->toArray();
```

### Update a product

[](#update-a-product)

To update a product use the `updateProduct` method.

```
use PaymentGateway\PayPalSdk\Api\CatalogProductsApi;
use PaymentGateway\PayPalSdk\Products\Constants\ProductCategory;
use PaymentGateway\PayPalSdk\Products\Requests\UpdateProductRequest;

$service = new CatalogProductsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');

$productRequest = new UpdateProductRequest('PROD-XY458712546854478');
$productRequest->setProductDescription('product description')
    ->setProductCategory(ProductCategory::ACADEMIC_SOFTWARE)
    ->setImageUrl('https://example.com/productimage.jpg')
    ->setHomeUrl('https://example.com');

$service->updateProduct($productRequest);
```

Billing Plans API
-----------------

[](#billing-plans-api)

You can use billing plans and billing agreements to create an agreement for a recurring PayPal or debit card payment for goods or services.

### List plans

[](#list-plans)

To get all plans use the `getPlans` method.

```
use PaymentGateway\PayPalSdk\Api\BillingPlansApi;

$service = new BillingPlansApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
$response = $service->getPlans()->toArray();
```

### Get a plan

[](#get-a-plan)

To get a single plan use the `getPlan` method.

```
use PaymentGateway\PayPalSdk\Api\BillingPlansApi;

$service = new BillingPlansApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
$response = $service->getPlan('P-18T532823A424032WL7NIVUA')->toArray();
```

### Create a plan

[](#create-a-plan)

To create a product use the `createPlan` method.

```
use PaymentGateway\PayPalSdk\Api\BillingPlansApi;
use PaymentGateway\PayPalSdk\Subscriptions\Frequency;
use PaymentGateway\PayPalSdk\Subscriptions\BillingCycles\BillingCycleSet;
use PaymentGateway\PayPalSdk\Subscriptions\BillingCycles\RegularBillingCycle;
use PaymentGateway\PayPalSdk\Subscriptions\Constants\CurrencyCode;
use PaymentGateway\PayPalSdk\Subscriptions\Money;
use PaymentGateway\PayPalSdk\Subscriptions\PricingSchema;
use PaymentGateway\PayPalSdk\Plans\Requests\StorePlanRequest;
use PaymentGateway\PayPalSdk\Subscriptions\Constants\IntervalUnit;

$service = new BillingPlansApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');

$frequency = new Frequency(IntervalUnit::MONTH, 1);
$pricingSchema = new PricingSchema(new Money(CurrencyCode::UNITED_STATES_DOLLAR, '350'));
$billingCycle = new RegularBillingCycle($frequency, $pricingSchema);
$billingCycleSet = new BillingCycleSet();
$billingCycleSet->addBillingCycle($billingCycle);
$planRequest = new StorePlanRequest('PROD-8R6565867F172242R', 'New Plan', $billingCycleSet);

// ['id' => 'P-XY...', 'product_id' => 'PROD-8R6565867F172242R', 'name' => 'My Plan', ...]
$response = $service->createPlan($planRequest)->toArray();
```

### Update a plan

[](#update-a-plan)

To update a product use the `updatePlan` method.

```
use PaymentGateway\PayPalSdk\Api\BillingPlansApi;
use PaymentGateway\PayPalSdk\Subscriptions\Constants\CurrencyCode;
use PaymentGateway\PayPalSdk\Subscriptions\Money;
use PaymentGateway\PayPalSdk\Plans\Requests\UpdatePlanRequest;
use PaymentGateway\PayPalSdk\Subscriptions\PaymentPreferences;

$service = new BillingPlansApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');

$paymentPreferences = new PaymentPreferences();
$paymentPreferences->setSetupFee(new Money(CurrencyCode::UNITED_STATES_DOLLAR, '250'));
$planRequest = new UpdatePlanRequest('P-18T532823A424032WL7NIVUA');
$planRequest->setPaymentPreferences($paymentPreferences);

$service->updatePlan($planRequest);
```

Subscriptions API
-----------------

[](#subscriptions-api)

You can use this API to create subscriptions that process recurring PayPal payments for physical or digital goods, or services.

### Get a subscription

[](#get-a-subscription)

To get a single subscription use the `getSubscription` method.

```
use PaymentGateway\PayPalSdk\Api\SubscriptionsApi;

$service = new SubscriptionsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');
$response = $service->getSubscription('I-18T532823A424032WL7NIVUA')->toArray();
```

### Create a subscription

[](#create-a-subscription)

To create a subscription use the `createSubscription` method.

```
use PaymentGateway\PayPalSdk\Api\SubscriptionsApi;
use PaymentGateway\PayPalSdk\Subscriptions\Requests\StoreSubscriptionRequest;

$service = new SubscriptionsApi('https://api.sandbox.paypal.com');
$service->setCredentials('AeA1QIZXiflr1', 'ECYYrrSHdKfk');

$subscriptionRequest = new StoreSubscriptionRequest('P-18T532823A424032WL7NIVUA');

// ["status": "APPROVAL_PENDING", "id": "I-GFCGPH9100S7", ...]
$response = $service->createSubscription($subscriptionRequest);
```

Error Handling
--------------

[](#error-handling)

In general, You can use the `toArray` method in all responses to get the service response data (except for patch operations), otherwise you'll get an array with errors if something fails. You can check for a successful response using the `isSuccessful` method. .

```
$response = $service->getProducts();

if (!$response->isSuccessful()) {
    var_dump($response->toArray());     // check the errors
} else {
    // array with data
    $response->toArray();
}
```

Mocking
-------

[](#mocking)

You can create your own PayPal API Mock for use with `PayPalService` like this

```
use PaymentGateway\PayPalSdk\Api\SubscriptionsApi;

$service = new SubscriptionsApi('https://api.sandbox.paypal.com');
$service->withHandler($handler);
```

The handler must be a `callable` type. If you prefer, you can use the [PayPal API Mock](https://github.com/payment-gateways/paypal-api-mock)adding the following to your project

```
composer require --dev payment-gateways/paypal-api-mock
```

After, you could use the class `PayPalApiMock` as a handler

```
use PaymentGateway\PayPalSdk\Api\SubscriptionsApi;
use PaymentGateway\PayPalApiMock\PayPalApiMock;

$service = new SubscriptionsApi('https://api.sandbox.paypal.com');
$service->withHandler(new PayPalApiMock());
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~81 days

Recently: every ~238 days

Total

13

Last Release

997d ago

Major Versions

v0.2.0 → v1.0.02020-12-22

1.x-dev → 2.x-dev2023-08-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/da87983fc787b1876917187cf3f37a66659e1e3f81ff5fec88cd43b6140a1bda?d=identicon)[fermius](/maintainers/fermius)

---

Top Contributors

[![darioriverat](https://avatars.githubusercontent.com/u/5879790?v=4)](https://github.com/darioriverat "darioriverat (158 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/payment-gateways-paypal-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/payment-gateways-paypal-sdk/health.svg)](https://phpackages.com/packages/payment-gateways-paypal-sdk)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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