PHPackages                             ttruong15/omnipay-square - 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. ttruong15/omnipay-square

ActiveLibrary[Payment Processing](/categories/payments)

ttruong15/omnipay-square
========================

Square driver for the Omnipay payment processing library

2.0.1(6y ago)0401MITPHP

Since Jun 22Pushed 6y agoCompare

[ Source](https://github.com/ttruong15/omnipay-square)[ Packagist](https://packagist.org/packages/ttruong15/omnipay-square)[ Docs](https://github.com/transportersio/omnipay-square)[ RSS](/packages/ttruong15-omnipay-square/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (9)Used By (0)

Omnipay: Square
===============

[](#omnipay-square)

**Square driver for the Omnipay PHP payment processing library**

[![Build Status](https://camo.githubusercontent.com/4684cbf99a78056205d25b95209bd51c7fbb1267bfdc758c4011ae194458a081/68747470733a2f2f7472617669732d63692e6f72672f5472616e73706f7274657273696f2f6f6d6e697061792d7371756172652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Transportersio/omnipay-square)[![Latest Stable Version](https://camo.githubusercontent.com/cbd72654d83e35d039e83fa3272265056945b32a8174f37eb8d3f622f138dcd6/68747470733a2f2f706f7365722e707567782e6f72672f7472616e73706f7274657273696f2f6f6d6e697061792d7371756172652f76657273696f6e2e706e67)](https://packagist.org/packages/transportersio/omnipay-square)[![Total Downloads](https://camo.githubusercontent.com/1831cd7e96b491b0d497e5a7c1909f48f62eeefe872188b0e10e07fa55b6d3e0/68747470733a2f2f706f7365722e707567782e6f72672f7472616e73706f7274657273696f2f6f6d6e697061792d7371756172652f642f746f74616c2e706e67)](https://packagist.org/packages/transportersio/omnipay-square)[![License](https://camo.githubusercontent.com/d459a97bdf35c8212b2304ccda109a897c499379a6e343cfe19d6bb1902f066f/68747470733a2f2f706f7365722e707567782e6f72672f7472616e73706f7274657273696f2f6f6d6e697061792d7371756172652f6c6963656e7365)](https://packagist.org/packages/transportersio/omnipay-square)

[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Square support for Omnipay.

Installation
------------

[](#installation)

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
{
    "require": {
        "transportersio/omnipay-square": "~1.0.7"
    }
}
```

And run composer to update your dependencies:

```
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

```

Basic Usage
-----------

[](#basic-usage)

The following gateways are provided by this package:

- Square

For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)repository.

Example
-------

[](#example)

```
use Omnipay\Omnipay;

$gateway = Omnipay::create('Square');
$gateway->setAccessToken("YOUR-ACCESS-TOKEN-HERE");
$gateway->setParameter("testMode", true);  // enable sandbox testing

```

Take a payment example
----------------------

[](#take-a-payment-example)

```
$purchase = [
    'amount' => 10,
    'currency' => 'AUD',
    'nonce' => 'ccof:kIjiG3WZhEblEdYj3GB',    // either a secure token (cnon:***) or card on file token (ccof:**)
    'note' => 'my testing payment',
    'referenceId' => 'abc',
    'customerReference' => '9E9X4YNDYH53VFZ32JD5EBFFFF'
];

try {
    $resp = $gateway->purchase($purchase)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Refund example
--------------

[](#refund-example)

```
$refundPayment = [
    'idempotencyKey' => uniqid(),
    'amount' => 1,
    'currency' => 'AUD',
    'transactionId' => 'XbeDoYcBcukcQNSgnX82go5LzwAZY',
    'reason' => 'test refund'
];

try {
    $resp = $gateway->refund($refundPayment)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Create a customer example
-------------------------

[](#create-a-customer-example)

```
$newCustomer = [
    'firstName' => 'test',
    'lastName' => 'test',
    'email' => 'test+01@testxample.com',
    'companyName' => 'test company pty ltd',
    'nickname' => 'test nick',
    'address' => [
	'address_line_1' => '22 test st',
	'locality' => 'brisbane',
	'administrative_district_level_1' => 'QLD',
	'postal_code' => '4000',
	'country' => 'AU'
    ],
    'phoneNumber' => '0733222222',
    'referenceId' => 'testref123',
    'note' => 'test note',
    'birthday' => '1970-01-30T00:00:00'
];

try {
    $resp = $gateway->createCustomer($newCustomer)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Update customer example
-----------------------

[](#update-customer-example)

```
$updateCustomer = [
    'customerReference' => 'DQ5ADHPB8GWKF6AEBP44Q8AZP4',
    'firstName' => 'test',
    'lastName' => 'test',
    'email' => 'test+01@testxample.com',
    'companyName' => 'test company pty ltd',
    'nickname' => 'test nick',
    'address' => [
	'address_line_1' => '22 test st',
	'locality' => 'brisbane',
	'administrative_district_level_1' => 'QLD',
	'postal_code' => '4000',
	'country' => 'AU'
    ],
    'phoneNumber' => '0733222222',
    'referenceId' => 'testref123',
    'note' => 'test note',
    'birthday' => '1970-01-30T00:00:00'
];

try {
    $resp = $gateway->updateCustomer($updateCustomer)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Create a card for customer example
----------------------------------

[](#create-a-card-for-customer-example)

```
$customerCard = [
    "customerReference" => "Y2QP0W93PWYWNBT3PTX5CAMKXC",
    "card" => "cnon:CBASEIP-9iU6Y9hLwvbKlU9mkcM",
    "cardholderName" => "Amelia Earhart"
];

try {
    $resp = $gateway->createCard($customerCard)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Delete customer example
-----------------------

[](#delete-customer-example)

```
$deleteCustomer = [
    'customerReference' => '9E9X4YNDYH53VFZ32JD5EB55PG',
];

try {
    $resp = $gateway->deleteCustomer($deleteCustomer)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Delete customer card example
----------------------------

[](#delete-customer-card-example)

```
$deleteCustomerCard = [
    'customerReference' => '9E9X4YNDYH53VFZ32JD5EB55PG',
    'cardReference' => 'ccof:yZmvTQ2YfslSRKHi4GB'
];

try {
    $resp = $gateway->deleteCard($deleteCustomerCard)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Retrieve customer example
-------------------------

[](#retrieve-customer-example)

```
$fetchCustomer = [
	'customerReference' => 'DQ5ADHPB8GWKF6AEBP44Q8AZP4',
];

try {
    $resp = $gateway->fetchCustomer($fetchCustomer)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Retrieve customer cards example
-------------------------------

[](#retrieve-customer-cards-example)

```
$fetchCustomerCard = [
	'customerReference' => 'DQ5ADHPB8GWKF6AEBP44Q8AZP4',
	'card' => 'ccof:eTAtmHpmpE8kfshh3GB'
];
try {
    $resp = $gateway->fetchCard($fetchCustomerCard)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Retrieve payment refunds example
--------------------------------

[](#retrieve-payment-refunds-example)

```
$listPaymentRefunds = [
    'beginTime' => '2020-01-12T01:06:23.798Z',
    'endTime' => '2020-03-12T01:06:23.798Z',
    'sortOrder' => 'ASC',
    'cursor' => null,
    'locationId' => null,
    'status' => 'PENDING',
    'sourceType' => 'CARD'
];

try {
    $resp = $gateway->listRefunds($listPaymentRefunds)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Retrieve payments example
-------------------------

[](#retrieve-payments-example)

```
$listPayments = [
    'beginTime' => '2020-01-12T01:06:23.798Z',
    'endTime' => '2020-03-12T01:06:23.798Z',
    'sortOrder' => 'ASC',
    'cursor' => null,
    'total' => '100',
    'last4' => '1111',
    'card_brand' => 'VISA'
];

try {
    $resp = $gateway->listRefunds($listPayments)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Refund payment example
----------------------

[](#refund-payment-example)

```
$refundPayment = [
	'idempotencyKey' => uniqid(),
	'amount' => 1,
	'currency' => 'AUD',
	'transactionId' => 'XbeDoYcBcukcQNSgnX82go5LzwAZY',
	'reason' => 'test refund'
];

try {
    $resp = $gateway->refund($refundPayment)->send();
    $responseData = $resp->getData();
} catch(\Exception $e) {
    echo $e->getMessage();
}

```

Support
-------

[](#support)

If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/Transportersio/omnipay-square/issues), or better yet, fork the library and submit a pull request.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~141 days

Recently: every ~248 days

Total

8

Last Release

2252d ago

Major Versions

1.0.5 → 2.0.02019-05-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7704535?v=4)[tinh](/maintainers/tinh)[@tinh](https://github.com/tinh)

---

Top Contributors

[![mikeybeck](https://avatars.githubusercontent.com/u/468643?v=4)](https://github.com/mikeybeck "mikeybeck (25 commits)")[![BasicmanBoonmee](https://avatars.githubusercontent.com/u/3637742?v=4)](https://github.com/BasicmanBoonmee "BasicmanBoonmee (16 commits)")[![skurvish](https://avatars.githubusercontent.com/u/8654397?v=4)](https://github.com/skurvish "skurvish (16 commits)")[![mnwalker](https://avatars.githubusercontent.com/u/9032080?v=4)](https://github.com/mnwalker "mnwalker (2 commits)")[![Tam](https://avatars.githubusercontent.com/u/977594?v=4)](https://github.com/Tam "Tam (1 commits)")

---

Tags

paymentgatewaypaymerchantomnipaysquare

### Embed Badge

![Health badge](/badges/ttruong15-omnipay-square/health.svg)

```
[![Health](https://phpackages.com/badges/ttruong15-omnipay-square/health.svg)](https://phpackages.com/packages/ttruong15-omnipay-square)
```

###  Alternatives

[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[sudiptpa/omnipay-nabtransact

National Australia Bank (NAB) Transact driver for the Omnipay payment processing library.

1017.2k](/packages/sudiptpa-omnipay-nabtransact)[lucassmacedo/omnipay-mercadopago

MercadoPago gateway for OmniPay

154.6k](/packages/lucassmacedo-omnipay-mercadopago)

PHPackages © 2026

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