PHPackages                             utopia-php/pay - 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. [Framework](/categories/framework)
4. /
5. utopia-php/pay

ActiveLibrary[Framework](/categories/framework)

utopia-php/pay
==============

A simple library to manage payments using multiple payment provider adapters

0.13.0(2mo ago)10122.5k↓26.1%2[1 issues](https://github.com/utopia-php/pay/issues)[3 PRs](https://github.com/utopia-php/pay/pulls)MITPHPPHP &gt;=8.1

Since Apr 13Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/utopia-php/pay)[ Packagist](https://packagist.org/packages/utopia-php/pay)[ RSS](/packages/utopia-php-pay/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (7)Versions (31)Used By (0)

Utopia Pay
==========

[](#utopia-pay)

[![Build Status](https://camo.githubusercontent.com/8f851099821e5f3d1f99a23a56c1cc80eb778fa85816a7dadbbd7631d7b5843a/68747470733a2f2f7472617669732d63692e6f72672f75746f7069612d7068702f7061792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/utopia-php/pay)[![Total Downloads](https://camo.githubusercontent.com/4d262117a96b7416dc45b352d9dff3e87f73ed6d1f2e5eae810005462c330e29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75746f7069612d7068702f7061792e737667)](https://camo.githubusercontent.com/4d262117a96b7416dc45b352d9dff3e87f73ed6d1f2e5eae810005462c330e29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75746f7069612d7068702f7061792e737667)[![Discord](https://camo.githubusercontent.com/6e418910df1b6eb524c6cbd88dbaf5a5aa294316eeadcd963e11262a319f6321/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3536343136303733303834353135313234343f6c6162656c3d646973636f7264)](https://appwrite.io/discord)

Utopia Pay library is simple and lite library for accepting payments. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).

Although this library is part of the [Utopia Framework](https://github.com/utopia-php/framework), it is dependency free and can be used as standalone with any other PHP project or framework.

Getting Started
---------------

[](#getting-started)

Install using composer:

```
composer require utopia-php/pay
```

Get Secret Key and Publishable Key from your Stripe Account.

```
require_once '../vendor/autoload.php';
use Utopia\Pay\Pay;
use Utopia\Pay\Adapter\Stripe;

$pay = new Pay(new Stripe('PUBLISHABLE_KEY', 'SECRET_KEY'));

$customer = $pay->createCustomer('Customer One', 'customer@gmail.com');
\var_dump($customer);

$pay->setCurrency('INR');
$purchase = $pay->purchase(
    5000, // price
    $customer['id'], // customer ID
    null, // card ID
    [
        'description' => 'some countries require descriptions'
    ]
);

var_dump($purchase);
```

Features
--------

[](#features)

### Direct Purchase

[](#direct-purchase)

Immediately charge a customer's payment method:

```
$purchase = $pay->purchase(
    5000,
    $customerId,
    $paymentMethodId
);
```

### Authorization and Capture (Hold and Charge)

[](#authorization-and-capture-hold-and-charge)

For scenarios where you need to verify payment availability before providing a service (e.g., domain registration, ticket booking):

```
// Step 1: Authorize payment (hold funds)
$authorization = $pay->authorize(
    5000,
    $customerId,
    $paymentMethodId,
    [
        'metadata' => [
            'domain' => 'example.com',
            'order_id' => 'ORD-12345'
        ]
    ]
);

// Step 2: Acquire resource from vendor
try {
    $domain = purchaseDomainFromVendor('example.com');

    // Step 3a: Capture payment on success
    $captured = $pay->capture($authorization['id']);

} catch (Exception $e) {
    // Step 3b: Cancel authorization on failure (release hold)
    $cancelled = $pay->cancelAuthorization($authorization['id']);
}
```

See the [Payment Authorization and Capture Guide](docs/tutorials/payment-authorization-capture.md) for detailed examples.

### Customer Management

[](#customer-management)

```
// Create customer
$customer = $pay->createCustomer('John Doe', 'john@example.com');

// Get customer
$customer = $pay->getCustomer($customerId);

// Update customer
$updated = $pay->updateCustomer($customerId, 'Jane Doe', 'jane@example.com');

// Delete customer
$pay->deleteCustomer($customerId);
```

### Payment Methods

[](#payment-methods)

```
// Add payment method
$paymentMethod = $pay->createPaymentMethod($customerId, 'card', [
    'number' => '4242424242424242',
    'exp_month' => 12,
    'exp_year' => 2025,
    'cvc' => '123'
]);

// List payment methods
$methods = $pay->listPaymentMethods($customerId);

// Delete payment method
$pay->deletePaymentMethod($paymentMethodId);
```

### Refunds

[](#refunds)

```
$refund = $pay->refund($paymentId, 3000); // Refund $30.00
```

System Requirements
-------------------

[](#system-requirements)

Utopia Pay requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.

Contributing
------------

[](#contributing)

All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.

Fork the project, create a feature branch, and send us a pull request.

You can refer to the [Contributing Guide](CONTRIBUTING.md) for more info.

### Testing

[](#testing)

```
vendor/bin/phpunit --configuration phpunit.xml

```

Copyright and license
---------------------

[](#copyright-and-license)

The MIT License (MIT)

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~77 days

Recently: every ~68 days

Total

18

Last Release

60d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.0

0.13.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/023f08a9df59f81cc4a04b1cebd20f45ede5db53ef2f9e9ad3d75f4c69be66b8?d=identicon)[eldadfux](/maintainers/eldadfux)

---

Top Contributors

[![lohanidamodar](https://avatars.githubusercontent.com/u/6360216?v=4)](https://github.com/lohanidamodar "lohanidamodar (179 commits)")[![christyjacob4](https://avatars.githubusercontent.com/u/20852629?v=4)](https://github.com/christyjacob4 "christyjacob4 (6 commits)")[![eldadfux](https://avatars.githubusercontent.com/u/1297371?v=4)](https://github.com/eldadfux "eldadfux (4 commits)")[![vermakhushboo](https://avatars.githubusercontent.com/u/43381712?v=4)](https://github.com/vermakhushboo "vermakhushboo (3 commits)")[![ChiragAgg5k](https://avatars.githubusercontent.com/u/110609663?v=4)](https://github.com/ChiragAgg5k "ChiragAgg5k (2 commits)")[![byt3h3ad](https://avatars.githubusercontent.com/u/26319721?v=4)](https://github.com/byt3h3ad "byt3h3ad (2 commits)")[![rohitkori](https://avatars.githubusercontent.com/u/99089826?v=4)](https://github.com/rohitkori "rohitkori (2 commits)")[![Meldiron](https://avatars.githubusercontent.com/u/19310830?v=4)](https://github.com/Meldiron "Meldiron (1 commits)")[![abnegate](https://avatars.githubusercontent.com/u/5857008?v=4)](https://github.com/abnegate "abnegate (1 commits)")

---

Tags

hacktoberfestphputopiaphpframeworkpaymentutopia

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/utopia-php-pay/health.svg)

```
[![Health](https://phpackages.com/badges/utopia-php-pay/health.svg)](https://phpackages.com/packages/utopia-php-pay)
```

###  Alternatives

[utopia-php/vcs

A simple library to integrate version control systems like GitHub, GitLab etc. to receive webhook events

13221.0k3](/packages/utopia-php-vcs)[utopia-php/audit

A simple audit library to manage application users logs

23305.1k3](/packages/utopia-php-audit)[utopia-php/domains

Utopia Domains library is simple and lite library for parsing web domains. This library is aiming to be as simple and easy to learn and use.

57691.2k18](/packages/utopia-php-domains)[utopia-php/database

A simple library to manage application persistence using multiple database adapters

74410.0k15](/packages/utopia-php-database)[utopia-php/queue

A powerful task queue.

11243.0k6](/packages/utopia-php-queue)[utopia-php/cli

A simple CLI library to manage command line applications

42492.7k16](/packages/utopia-php-cli)

PHPackages © 2026

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