├── .github └── workflows │ └── run-tests.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml.dist └── tests └── OmnipayTest.php /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - "*" 10 | schedule: 11 | - cron: '0 0 * * *' 12 | 13 | jobs: 14 | php-tests: 15 | runs-on: ubuntu-latest 16 | timeout-minutes: 15 17 | env: 18 | COMPOSER_NO_INTERACTION: 1 19 | 20 | strategy: 21 | matrix: 22 | php: [7.4, 7.3, 7.2] 23 | dependency-version: [prefer-lowest, prefer-stable] 24 | 25 | name: P${{ matrix.php }} - ${{ matrix.dependency-version }} 26 | 27 | steps: 28 | - name: Checkout code 29 | uses: actions/checkout@v2 30 | 31 | - name: Setup PHP 32 | uses: shivammathur/setup-php@v2 33 | with: 34 | php-version: ${{ matrix.php }} 35 | coverage: none 36 | tools: composer 37 | 38 | - name: Install dependencies 39 | run: | 40 | composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress 41 | 42 | - name: Execute Unit Tests 43 | run: composer test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.lock 3 | composer.phar 4 | phpunit.xml 5 | .idea/* 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | * Fork the project. 4 | * Make your feature addition or bug fix. 5 | * Add tests for it. This is important so I don't break it in a future version unintentionally. 6 | * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. 7 | * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) 8 | style and that all tests pass. 9 | * Don't forget to check all versionnumbers and tag it correctly in GIT ;) 10 | * Send the pull request. 11 | * Check that the Travis CI build passed. If not, rinse and repeat. 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2018 Adrian Macneil 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Omnipay 2 | 3 | **An easy to use, consistent payment processing library for PHP** 4 | 5 | [![Build Status](https://travis-ci.org/thephpleague/omnipay-common.svg?branch=master)](https://travis-ci.org/thephpleague/omnipay-common) 6 | [![Latest Stable Version](https://poser.pugx.org/omnipay/common/version)](https://packagist.org/packages/omnipay/common) 7 | [![Total Downloads](https://poser.pugx.org/omnipay/common/d/total)](https://packagist.org/packages/omnipay/common) 8 | 9 | Omnipay is a payment processing library for PHP. It has been designed based on 10 | ideas from [Active Merchant](http://activemerchant.org/), plus experience implementing 11 | dozens of gateways for [CI Merchant]. It has a clear and consistent API, 12 | is fully unit tested, and even comes with an example application to get you started. 13 | 14 | **Why use Omnipay instead of a gateway's official PHP package/example code?** 15 | 16 | * Because you can learn one API and use it in multiple projects using different payment gateways 17 | * Because if you need to change payment gateways you won't need to rewrite your code 18 | * Because most official PHP payment gateway libraries are a mess 19 | * Because most payment gateways have exceptionally poor documentation 20 | * Because you are writing a shopping cart and need to support multiple gateways 21 | 22 | ## TL;DR 23 | 24 | Just want to see some code? 25 | 26 | ```php 27 | use Omnipay\Omnipay; 28 | 29 | $gateway = Omnipay::create('Stripe'); 30 | $gateway->setApiKey('abc123'); 31 | 32 | $formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '123'); 33 | $response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send(); 34 | 35 | if ($response->isRedirect()) { 36 | // redirect to offsite payment gateway 37 | $response->redirect(); 38 | } elseif ($response->isSuccessful()) { 39 | // payment was successful: update database 40 | print_r($response); 41 | } else { 42 | // payment failed: display message to customer 43 | echo $response->getMessage(); 44 | } 45 | ``` 46 | 47 | As you can see, Omnipay has a consistent, well thought out API. We try to abstract as much 48 | as possible the differences between the various payments gateways. 49 | 50 | ## Package Layout 51 | 52 | Omnipay is a collection of packages which all depend on the 53 | [omnipay/common](https://github.com/thephpleague/omnipay-common) package to provide 54 | a consistent interface. There are no dependencies on official payment gateway PHP packages - 55 | we prefer to work with the HTTP API directly. Under the hood, we use the popular and powerful 56 | [PHP-HTTP](http://docs.php-http.org/en/latest/index.html) library to make HTTP requests. 57 | A [Guzzle](http://guzzlephp.org/) adapter is required by default, when using `league/omnipay`. 58 | 59 | New gateways can be created by cloning the layout of an existing package. When choosing a 60 | name for your package, please don't use the `omnipay` vendor prefix, as this implies that 61 | it is officially supported. You should use your own username as the vendor prefix, and prepend 62 | `omnipay-` to the package name to make it clear that your package works with Omnipay. 63 | For example, if your GitHub username was `santa`, and you were implementing the `giftpay` 64 | payment library, a good name for your composer package would be `santa/omnipay-giftpay`. 65 | 66 | ## Installation 67 | 68 | Omnipay is installed via [Composer](https://getcomposer.org/). 69 | For most uses, you will need to require `league/omnipay` and an individual gateway: 70 | 71 | ``` 72 | composer require league/omnipay:^3 omnipay/paypal 73 | ``` 74 | 75 | If you want to use your own HTTP Client instead of Guzzle (which is the default for `league/omnipay`), 76 | you can require `league/common` and any `php-http/client-implementation` (see [PHP Http](http://docs.php-http.org/en/latest/clients.html)) 77 | 78 | ``` 79 | composer require league/common:^3 omnipay/paypal php-http/buzz-adapter 80 | ``` 81 | 82 | ## Upgrade from v2 to v3 83 | 84 | If your gateway is supported for v3, you can require that version. Make sure you require `league/omnipay` or a separate Http Adapter. 85 | 86 | If there is no version for v3 yet, please raise an issue or upgrade the gateways yourself and create a PR. 87 | See the [Upgrade guide for omnipay/common](https://github.com/thephpleague/omnipay-common/blob/master/UPGRADE.md) 88 | 89 | > Note: The package name has been changed from `omnipay/omnipay` to `league/omnipay` for v3 90 | 91 | ## Payment Gateways 92 | 93 | All payment gateways must implement [GatewayInterface](https://github.com/thephpleague/omnipay-common/blob/master/src/Common/GatewayInterface.php), and will usually 94 | extend [AbstractGateway](https://github.com/thephpleague/omnipay-common/blob/master/src/Common/AbstractGateway.php) for basic functionality. 95 | 96 | The following gateways are available: 97 | 98 | Gateway | 2.x | 3.x | Composer Package | Maintainer 99 | --- | --- | --- | --- | --- 100 | [2c2p](https://github.com/dilab/omnipay-2c2p) | ✓ | ✓ | dilab/omnipay-2c2p | [Xu Ding](https://github.com/dilab) 101 | [2Checkout](https://github.com/thephpleague/omnipay-2checkout) | ✓ | - | omnipay/2checkout | [Omnipay](https://github.com/thephpleague/omnipay) 102 | [2Checkout Improved](https://github.com/collizo4sky/omnipay-2checkout) | ✓ | - | collizo4sky/omnipay-2checkout | [Agbonghama Collins](https://github.com/collizo4sky) 103 | [Acapture (PayVision)](https://github.com/queueup-dev/omnipay-acapture) | ✓ | - | qup/omnipay-acapture | [Niels de Vries](https://github.com/niels-qup) 104 | [Adyen](https://github.com/academe/omnipay-adyen) | - | ✓ | academe/omnipay-adyen | [Jason Judge](https://github.com/judgej) 105 | [Agms](https://github.com/agmscode/omnipay-agms) | ✓ | - | agmscode/omnipay-agms | [Maanas Royy](https://github.com/maanas) 106 | [Alipay(Global)](https://github.com/lokielse/omnipay-global-alipay) | ✓ | ✓ | lokielse/omnipay-global-alipay | [Loki Else](https://github.com/lokielse) 107 | [Alipay](https://github.com/lokielse/omnipay-alipay) | ✓ | ✓ | lokielse/omnipay-alipay | [Loki Else](https://github.com/lokielse) 108 | [99Bill](https://github.com/laraveler/omnipay-99bill) | - | ✓ | x-class/omnipay-99bill | [Laraveler](https://github.com/laraveler) 109 | [Allied Wallet](https://github.com/delatbabel/omnipay-alliedwallet) | ✓ | - | delatbabel/omnipay-alliedwallet | [Del](https://github.com/delatbabel) 110 | [Authorize.Net](https://github.com/thephpleague/omnipay-authorizenet) | ✓ | ✓ | omnipay/authorizenet | [Jason Judge](https://github.com/judgej) 111 | [Authorize.Net API](https://github.com/academe/omnipay-authorizenetapi) | - | ✓ | academe/omnipay-authorizenetapi | [Jason Judge](https://github.com/judgej) 112 | [Authorize.Net Recurring Billing](https://github.com/cimpleo/omnipay-authorizenetrecurring) | - | ✓ | cimpleo/omnipay-authorizenetrecurring | [CimpleO](https://github.com/cimpleo) 113 | [Bankart](https://github.com/ampeco/omnipay-bankart) | ✓ | ✓ | ampeco/omnipay-bankart | [Ampeco](https://github.com/ampeco) 114 | [Barclays ePDQ](https://github.com/digitickets/omnipay-barclays-epdq) | ✓ | - | digitickets/omnipay-barclays-epdq | [DigiTickets](https://github.com/digitickets) 115 | [Beanstream](https://github.com/lemonstand/omnipay-beanstream) | ✓ | - | lemonstand/omnipay-beanstream | [LemonStand](https://github.com/lemonstand) 116 | [BitPay](https://github.com/hiqdev/omnipay-bitpay) | ✓ | - | hiqdev/omnipay-bitpay | [HiQDev](https://github.com/hiqdev) 117 | [BKM Express](https://github.com/yasinkuyu/omnipay-bkm) | ✓ | - | yasinkuyu/omnipay-bkm | [Yasin Kuyu](https://github.com/yasinkuyu) 118 | [BlueSnap](https://github.com/vimeo/omnipay-bluesnap) | ✓ | - | vimeo/omnipay-bluesnap | [Vimeo](https://github.com/vimeo) 119 | [Braintree](https://github.com/thephpleague/omnipay-braintree) | ✓ | ✓ | omnipay/braintree | [Omnipay](https://github.com/thephpleague/omnipay) 120 | [Buckaroo](https://github.com/thephpleague/omnipay-buckaroo) | ✓ | - | omnipay/buckaroo | [Omnipay](https://github.com/thephpleague/omnipay) 121 | [CardGate](https://github.com/cardgate/omnipay-cardgate) | ✓ | - | cardgate/omnipay-cardgate | [CardGate](https://github.com/cardgate) 122 | [CardSave](https://github.com/thephpleague/omnipay-cardsave) | ✓ | - | omnipay/cardsave | [Omnipay](https://github.com/thephpleague/omnipay) 123 | [CashBaBa](https://github.com/tapos007/omnipay-cashbaba) | ✓ | ✓ | omnipay/cashbaba | [Recursion Technologies Ltd](https://github.com/tapos007) 124 | [Checkout.com](https://github.com/fotografde/omnipay-checkoutcom) | ✓ | - | fotografde/checkoutcom | [fotograf.de](https://github.com/fotografde) 125 | [CloudBanking](https://github.com/spsingh/omnipay-cloudbanking) | ✓ | - | cloudbanking/omnipay-cloudbanking | [Cloudbanking](http://cloudbanking.com.au/) 126 | [Coinbase](https://github.com/thephpleague/omnipay-coinbase) | ✓ | - | omnipay/coinbase | [Omnipay](https://github.com/thephpleague/omnipay) 127 | [CoinGate](https://github.com/coingate/omnipay-coingate) | ✓ | - | coingate/omnipay-coingate | [CoinGate](https://github.com/coingate) 128 | [CoinPayments](https://github.com/InkedCurtis/omnipay-coinpayments) | ✓ | ✓ | InkedCurtis/omnipay-coinpayments | [InkedCurtis](https://github.com/InkedCurtis) 129 | [Creditcall](https://github.com/meebio/omnipay-creditcall) | ✓ | - | meebio/omnipay-creditcall | [John Jablonski](https://github.com/jan-j) 130 | [CSOB](https://github.com/bileto/omnipay-csob) (GP WebPay) | ✓ | - | bileto/omnipay-csob | 131 | [Cybersource](https://github.com/dioscouri/omnipay-cybersource) | ✓ | ✓ | dioscouri/omnipay-cybersource | [Dioscouri Design](https://github.com/dioscouri) 132 | [Cybersource SOAP](https://github.com/Klinche/omnipay-cybersource-soap) | ✓ | - | dabsquared/omnipay-cybersource-soap | [DABSquared](https://github.com/DABSquared) 133 | [DataCash](https://github.com/digitickets/omnipay-datacash) | ✓ | - | digitickets/omnipay-datacash | [DigiTickets](https://github.com/digitickets) 134 | [Datatrans](https://github.com/w-vision/omnipay-datatrans) | ✓ | - | w-vision/datatrans | [Dominik Pfaffenbauer](https://github.com/dpfaffenbauer) 135 | [Datatrans](https://github.com/academe/omnipay-datatrans) | ✓ | ✓ | academe/omnipay-datatrans | [Jason Judge](https://github.com/judgej) 136 | [Docdata Payments](https://github.com/Uskur/omnipay-docdata-payments) | ✓ | ✓ | uskur/omnipay-docdata-payments | [Uskur](https://github.com/Uskur) 137 | [Dummy](https://github.com/thephpleague/omnipay-dummy) | ✓ | ✓ | omnipay/dummy | [Del](https://github.com/delatbabel) 138 | [Ebanx](https://github.com/descubraomundo/omnipay-ebanx) | - | ✓ | descubraomundo/omnipay-ebanx | [Descubra o Mundo](https://github.com/descubraomundo/) 139 | [eGHL](https://bitbucket.org/eghl/eghl-omnipay/src/master/) | - | ✓ | e-ghl/omnipay | [Jawad Humayun](https://bitbucket.org/jawad242/) 140 | [eGHL](https://github.com/dilab/omnipay-eghl) | ✓ | ✓ | dilab/omnipay-eghl | [Xu Ding](https://github.com/dilab) 141 | [eCoin](https://github.com/hiqdev/omnipay-ecoin) | ✓ | - | hiqdev/omnipay-ecoin | [HiQDev](https://github.com/hiqdev) 142 | [ecoPayz](https://github.com/dercoder/omnipay-ecopayz) | ✓ | - | dercoder/omnipay-ecopayz | [Alexander Fedra](https://github.com/dercoder) 143 | [eSewa](https://github.com/sudiptpa/esewa) | - | ✓ | sudiptpa/omnipay-esewa | [Sujip Thapa](https://github.com/sudiptpa) 144 | [EgopayRu](https://github.com/pinguinjkeke/omnipay-egopaymentru) | ✓ | - | pinguinjkeke/omnipay-egopaymentru | [Alexander Avakov](https://github.com/pinguinjkeke) 145 | [Elavon](https://github.com/lxrco/omnipay-elavon) | ✓ | ✓ | lxrco/omnipay-elavon | [Korri](https://github.com/Korri) 146 | [ePayments](https://github.com/hiqdev/omnipay-epayments) | ✓ | - | hiqdev/omnipay-epayments | [HiQDev](https://github.com/hiqdev) 147 | [ePayService](https://github.com/hiqdev/omnipay-epayservice) | ✓ | - | hiqdev/omnipay-epayservice | [HiQDev](https://github.com/hiqdev) 148 | [eWAY](https://github.com/thephpleague/omnipay-eway) | ✓ | ✓ | omnipay/eway | [Del](https://github.com/delatbabel) 149 | [Fasapay](https://github.com/andreas22/omnipay-fasapay) | ✓ | - | andreas22/omnipay-fasapay | [Andreas Christodoulou](https://github.com/andreas22) 150 | [Fat Zebra](https://github.com/delatbabel/omnipay-fatzebra) | ✓ | - | delatbabel/omnipay-fatzebra | [Del](https://github.com/delatbabel) 151 | [FreeKassa](https://github.com/hiqdev/omnipay-freekassa) | ✓ | - | hiqdev/omnipay-freekassa | [HiQDev](https://github.com/hiqdev) 152 | [Fibank](https://github.com/ampeco/omnipay-fibank) | - | ✓ | ampeco/omnipay-fibank | [Ampeco](https://github.com/ampeco) 153 | [First Data](https://github.com/thephpleague/omnipay-firstdata) | ✓ | - | omnipay/firstdata | [OmniPay](https://github.com/thephpleague/omnipay) 154 | [Flo2cash](https://github.com/guisea/omnipay-flo2cash) | ✓ | - | guisea/omnipay-flo2cash | [Aaron Guise](https://github.com/guisea) 155 | [Free / Zero Amount](https://github.com/colinodell/omnipay-zero) | ✓ | - | colinodell/omnipay-zero | [Colin O'Dell](https://github.com/colinodell) 156 | [GiroCheckout](https://github.com/academe/Omnipay-GiroCheckout) | ✓ | ✓ | academe/omnipay-girocheckout | [Jason Judge](https://github.com/judgej) 157 | [Globalcloudpay](https://github.com/dercoder/omnipay-globalcloudpay) | ✓ | - | dercoder/omnipay-globalcloudpay | [Alexander Fedra](https://github.com/dercoder) 158 | [GoCardless](https://github.com/thephpleague/omnipay-gocardless) | ✓ | - | omnipay/gocardless | [Del](https://github.com/delatbabel) 159 | [GoPay](https://github.com/bileto/omnipay-gopay) | ✓ | - | bileto/omnipay-gopay | 160 | [GovPayNet](https://github.com/flexcoders/omnipay-govpaynet) | ✓ | - | omnipay/omnipay-govpaynet | [FlexCoders](https://github.com/flexcoders) 161 | [GVP (Garanti)](https://github.com/yasinkuyu/omnipay-gvp) | ✓ | - | yasinkuyu/omnipay-gvp | [Yasin Kuyu](https://github.com/yasinkuyu) 162 | [GVP (Garanti)](https://github.com/emr/omnipay-gvp) | - | ✓ | emr/omnipay-gvp | [Emre Akinci](https://github.com/emr) 163 | [Helcim](https://github.com/academe/omnipay-helcim) | ✓ | - | academe/omnipay-helcim | [Jason Judge](https://github.com/judgej) 164 | [Icepay Payments](https://github.com/superbrave/omnipay-icepay-payments) | - | ✓ | superbrave/omnipay-icepay-payments | [SuperBrave](https://github.com/superbrave) 165 | [iDram](https://github.com/ptuchik/omnipay-idram) | - | ✓ | ptuchik/omnipay-idram | [Avik Aghajanyan](https://github.com/ptuchik) 166 | [iDeal](https://github.com/deniztezcan/omnipay-ideal) | - | ✓ | deniztezcan/omnipay-ideal | [Deniz Tezcan](https://github.com/deniztezcan) 167 | [Ingenico ePayments](https://github.com/deniztezcan/omnipay-ingenico-epayments) | - | ✓ | deniztezcan/omnipay-ingenico-epayments | [Deniz Tezcan](https://github.com/deniztezcan) 168 | [iPay88](https://github.com/dilab/omnipay-ipay88) | ✓ | ✓ | dilab/omnipay-ipay88 | [Xu Ding](https://github.com/dilab) 169 | [IfthenPay](https://github.com/ifthenpay/omnipay-ifthenpay) | ✓ | - | ifthenpay/omnipay-ifthenpay | [Rafael Almeida](https://github.com/rafaelcpalmeida) 170 | [InterKassa](https://github.com/hiqdev/omnipay-interkassa) | ✓ | ✓ | hiqdev/omnipay-interkassa | [HiQDev](https://github.com/hiqdev) 171 | [InovioPay](https://github.com/mvestil/omnipay-inoviopay) | ✓ | ✓ | mvestil/omnipay-inoviopay | [Mark Vestil](https://github.com/mvestil) 172 | [Iyzico](https://github.com/yasinkuyu/omnipay-iyzico) | ✓ | - | yasinkuyu/omnipay-iyzico | [Yasin Kuyu](https://github.com/yasinkuyu) 173 | [Judo Pay](https://github.com/Transportersio/omnipay-judopay) | ✓ | - | transportersio/omnipay-judopay | [Transporters.io](https://github.com/Transportersio) 174 | [Klarna Checkout](https://github.com/MyOnlineStore/omnipay-klarna-checkout) | ✓ | ✓ | myonlinestore/omnipay-klarna-checkout | [MyOnlineStore](https://github.com/MyOnlineStore) 175 | [Laybuy](https://github.com/mediabeastnz/omnipay-laybuy) | ✓ | - | mediabeastnz/omnipay-laybuy | [Myles Derham](https://github.com/mediabeastnz) 176 | [Komerci (Rede, former RedeCard)](https://github.com/byjg/omnipay-komerci) | ✓ | - | byjg/omnipay-komerci | [João Gilberto Magalhães](https://github.com/byjg) 177 | [Komoju](https://github.com/dannyvink/omnipay-komoju) | ✓ | - | vink/omnipay-komoju | [Danny Vink](https://github.com/dannyvink) 178 | [Midtrans](https://github.com/dilab/omnipay-midtrans) | ✓ | ✓ | dilab/omnipay-midtrans | [Xu Ding](https://github.com/dilab) 179 | [MercadoPago](https://github.com/lucassmacedo/omnipay-mercadopago) | - | ✓ | lucassmacedo/omnipay-mercadopago | [Lucas Macedo](https://github.com/lucassmacedo) 180 | [Magnius](https://github.com/fruitcake/omnipay-magnius) | - | ✓ | fruitcake/omnipay-magnius | [Fruitcake](https://github.com/fruitcake) 181 | [Manual](https://github.com/thephpleague/omnipay-manual) | ✓ | - | omnipay/manual | [Del](https://github.com/delatbabel) 182 | [Migs](https://github.com/thephpleague/omnipay-migs) | ✓ | - | omnipay/migs | [Omnipay](https://github.com/thephpleague/omnipay) 183 | [Mpesa](https://github.com/wasksofts/omnipay-mpesa) | ✓ | - | wasksofts/omnipay-mpesa | [wasksofts](https://github.com/wasksofts/omnipay-mpesa) 184 | [MTNCAM Mobile Money](https://github.com/larrytech7/omnipay-momocm) | ✓ | ✓ | larrytech7/omnipay-momocm | [Akah Harvey](https://github.com/larrytech7) 185 | [Mollie](https://github.com/thephpleague/omnipay-mollie) | ✓ | ✓ | omnipay/mollie | [Barry vd. Heuvel](https://github.com/barryvdh) 186 | [MOLPay](https://github.com/leesiongchan/omnipay-molpay) | ✓ | - | leesiongchan/molpay | [Lee Siong Chan](https://github.com/leesiongchan) 187 | [MoMo](https://github.com/phpviet/omnipay-momo) | - | ✓ | phpviet/omnipay-momo | [PHPViet](https://github.com/phpviet) 188 | [MultiCards](https://github.com/incube8/omnipay-multicards) | ✓ | - | incube8/omnipay-multicards | [Del](https://github.com/delatbabel) 189 | [MultiSafepay](https://github.com/thephpleague/omnipay-multisafepay) | ✓ | - | omnipay/multisafepay | [Alexander Deruwe](https://github.com/aderuwe) 190 | [MyCard](https://github.com/xxtime/omnipay-mycard) | ✓ | - | xxtime/omnipay-mycard | [Joe Chu](https://github.com/xxtime) 191 | [National Australia Bank (NAB) Transact](https://github.com/sudiptpa/omnipay-nabtransact) | ✓ | ✓ | sudiptpa/omnipay-nabtransact | [Sujip Thapa](https://github.com/sudiptpa) 192 | [NestPay (EST)](https://github.com/yasinkuyu/omnipay-nestpay) | ✓ | - | yasinkuyu/omnipay-nestpay | [Yasin Kuyu](https://github.com/yasinkuyu) 193 | [NestPay (EST)](https://github.com/uskur/omnipay-nestpay) | - | ✓ | uskur/omnipay-nestpay | [Uskur](https://github.com/uskur) 194 | [Netaxept (BBS)](https://github.com/thephpleague/omnipay-netaxept) | ✓ | - | omnipay/netaxept | [Omnipay](https://github.com/thephpleague/omnipay) 195 | [Netbanx](https://github.com/thephpleague/omnipay-netbanx) | ✓ | - | omnipay/netbanx | [Maks Rafalko](https://github.com/borNfreee) 196 | [Neteller](https://github.com/dercoder/omnipay-neteller) | ✓ | - | dercoder/omnipay-neteller | [Alexander Fedra](https://github.com/dercoder) 197 | [NetPay](https://github.com/netpay/omnipay-netpay) | ✓ | - | netpay/omnipay-netpay | [NetPay](https://github.com/netpay) 198 | [Network Merchants Inc. (NMI)](https://github.com/mfauveau/omnipay-nmi) | ✓ | - | mfauveau/omnipay-nmi | [Matthieu Fauveau](https://github.com/mfauveau) 199 | [Nocks](https://github.com/nocksapp/checkout-omnipay) | ✓ | ✓ | nocksapp/omnipay-nocks | [Nocks](https://github.com/nocksapp) 200 | [OkPay](https://github.com/hiqdev/omnipay-okpay) | ✓ | - | hiqdev/omnipay-okpay | [HiQDev](https://github.com/hiqdev) 201 | [OnePay](https://github.com/dilab/omnipay-onepay) | ✓ | ✓ | dilab/omnipay-onepay | [Xu Ding](https://github.com/dilab) 202 | [Openpay Australia](https://github.com/sudiptpa/openpay) | ✓ | ✓ | sudiptpa/omnipay-openpay | [Sujip Thapa](https://github.com/sudiptpa) 203 | [Oppwa](https://github.com/vdbelt/omnipay-oppwa) | ✓ | ✓ | vdbelt/omnipay-oppwa | [Martin van de Belt](https://github.com/vdbelt) 204 | [PAY. (Pay.nl & Pay.be)](https://github.com/paynl/omnipay-paynl) | ✓ | ✓ | paynl/omnipay-paynl | [Andy Pieters](https://github.com/andypieters) 205 | [PayMongo](https://github.com/omarusman/omnipay-paymongo) | - | ✓ | omarusman/omnipay-paymongo | [Omar Usman](https://github.com/omarusman) 206 | [Payoo](https://github.com/dilab/omnipay-payoo) | ✓ | ✓ | dilab/omnipay-payoo | [Xu Ding](https://github.com/dilab) 207 | [Pacnet](https://github.com/mfauveau/omnipay-pacnet) | ✓ | - | mfauveau/omnipay-pacnet | [Matthieu Fauveau](https://github.com/mfauveau) 208 | [Pagar.me](https://github.com/descubraomundo/omnipay-pagarme) | ✓ | - | descubraomundo/omnipay-pagarme | [Descubra o Mundo](https://github.com/descubraomundo) 209 | [Paratika (Asseco)](https://github.com/yasinkuyu/omnipay-paratika) | ✓ | - | yasinkuyu/omnipay-paratika | [Yasin Kuyu](https://github.com/yasinkuyu) 210 | [PayFast](https://github.com/thephpleague/omnipay-payfast) | ✓ | - | omnipay/payfast | [Omnipay](https://github.com/thephpleague/omnipay) 211 | [Payflow](https://github.com/thephpleague/omnipay-payflow) | ✓ | - | omnipay/payflow | [Del](https://github.com/delatbabel) 212 | [PaymentExpress (DPS)](https://github.com/thephpleague/omnipay-paymentexpress) | ✓ | ✓ | omnipay/paymentexpress | [Del](https://github.com/delatbabel) 213 | [PaymentExpress / DPS (A2A)](https://github.com/onlinesid/omnipay-paymentexpress-a2a) | ✓ | - | onlinesid/omnipay-paymentexpress-a2a | [Sid](https://github.com/onlinesid) 214 | [PaymentgateRu](https://github.com/pinguinjkeke/omnipay-paymentgateru) | ✓ | ✓ | pinguinjkeke/omnipay-paymentgateru | [Alexander Avakov](https://github.com/pinguinjkeke) 215 | [PaymentSense](https://github.com/digitickets/omnipay-paymentsense) | ✓ | - | digitickets/omnipay-paymentsense | [DigiTickets](https://github.com/digitickets) 216 | [PaymentWall](https://github.com/incube8/omnipay-paymentwall) | ✓ | - | incube8/omnipay-paymentwall | [Del](https://github.com/delatbabel) 217 | [PayPal](https://github.com/thephpleague/omnipay-paypal) | ✓ | ✓ | omnipay/paypal | [Del](https://github.com/delatbabel) 218 | [PayPro](https://github.com/payproNL/omnipay-paypro) | ✓ | - | paypronl/omnipay-paypro | [Fruitcake](https://github.com/fruitcake) 219 | [PAYONE](https://github.com/academe/omnipay-payone) | ✓ | ✓ | academe/omnipay-payone | [Jason Judge](https://github.com/judgej) 220 | [Paysafecard](https://github.com/dercoder/omnipay-paysafecard) | ✓ | - | dercoder/omnipay-paysafecard | [Alexander Fedra](https://github.com/dercoder) 221 | [Paysafecard](https://github.com/worldstream-labs/omnipay-paysafecard) | - | ✓ | worldstream-labs/omnipay-paysafecard | [Worldstream](https://github.com/worldstream-labs) 222 | [Paysafe Payment Hub (Neteller)](https://github.com/worldstream-labs/omnipay-paysafe-payment-hub) | - | ✓ | worldstream-labs/omnipay-paysafe-payment-hub | [Worldstream](https://github.com/worldstream-labs) 223 | [Paysera](https://github.com/povils/omnipay-paysera) | ✓ | - | povils/omnipay-paysera | [Povils](https://github.com/povils) 224 | [Paysera](https://github.com/semyonchetvertnyh/omnipay-paysera) | - | ✓ | semyonchetvertnyh/omnipay-paysera | [Semyon Chetvertnyh](https://github.com/semyonchetvertnyh) 225 | [PaySimple](https://github.com/dranes/omnipay-paysimple) | ✓ | - | dranes/omnipay-paysimple | [Dranes](https://github.com/dranes) 226 | [PaySsion](https://github.com/InkedCurtis/omnipay-payssion) | ✓ | - | inkedcurtis/omnipay-payssion | [Curtis](https://github.com/inkedcurtis) 227 | [PayTrace](https://github.com/iddqdidkfa/omnipay-paytrace) | ✓ | - | softcommerce/omnipay-paytrace | [Oleg Ilyushyn](https://github.com/iddqdidkfa) 228 | [PayU](https://github.com/efesaid/omnipay-payu) | ✓ | - | omnipay/payu | [efesaid](https://github.com/efesaid) 229 | [PayU](https://github.com/bileto/omnipay-payu) | ✓ | - | bileto/omnipay-payu | 230 | [PayZen](https://github.com/ubitransports/omnipay-payzen) | ✓ | - | ubitransports/omnipay-payzen | [Ubitransport](https://github.com/ubitransports) 231 | [Paxum](https://github.com/hiqdev/omnipay-paxum) | ✓ | - | hiqdev/omnipay-paxum | [HiQDev](https://github.com/hiqdev) 232 | [Pelecard](https://github.com/Uskur/omnipay-pelecard) | ✓ | ✓ | uskur/omnipay-pelecard | [Uskur](https://github.com/Uskur) 233 | [Pin Payments](https://github.com/thephpleague/omnipay-pin) | ✓ | - | omnipay/pin | [Del](https://github.com/delatbabel) 234 | [Ping++](https://github.com/phoenixg/omnipay-pingpp) | ✓ | - | phoenixg/omnipay-pingpp | [Huang Feng](https://github.com/phoenixg) 235 | [POLi](https://github.com/burnbright/omnipay-poli) | ✓ | - | burnbright/omnipay-poli | [Sid](https://github.com/onlinesid) 236 | [Portmanat](https://github.com/dercoder/omnipay-portmanat) | ✓ | - | dercoder/omnipay-portmanat | [Alexander Fedra](https://github.com/dercoder) 237 | [Posnet](https://github.com/yasinkuyu/omnipay-posnet) | ✓ | - | yasinkuyu/omnipay-posnet | [Yasin Kuyu](https://github.com/yasinkuyu) 238 | [Postfinance](https://github.com/bummzack/omnipay-postfinance) | ✓ | - | bummzack/omnipay-postfinance | [Roman Schmid](https://github.com/bummzack) 239 | [Qiwi](https://github.com/hiqdev/omnipay-qiwi) | ✓ | - | hiqdev/omnipay-qiwi | [HiQDev](https://github.com/hiqdev) 240 | [QQ Wallet(QPay)](https://github.com/kuangjy2/omnipay-qpay) | - | ✓ | kuangjy/omnipay-qpay | [Kuang Jiaye](https://github.com/kuangjy2) 241 | [Quickpay](https://github.com/NobrainerWeb/omnipay-quickpay) | ✓ | - | nobrainerweb/omnipay-quickpay | [Nobrainer Web](https://github.com/NobrainerWeb) 242 | [Rabobank](https://github.com/thephpleague/omnipay-rabobank) | ✓ | - | omnipay/rabobank | [Barry vd. Heuvel](https://github.com/barryvdh) 243 | [Realex](https://github.com/digitickets/omnipay-realex) | ✓ | - | digitickets/omnipay-realex | [DigiTickets](https://github.com/digitickets) 244 | [RedSys](https://github.com/jsampedro77/sermepa-omnipay) | ✓ | - | nazka/sermepa-omnipay | [Javier Sampedro](https://github.com/jsampedro77) 245 | [RentMoola](https://github.com/rentmoola/omnipay-rentmoola) | ✓ | - | rentmoola/omnipay-rentmoola | [Geoff Shaw](https://github.com/Shawg) 246 | [RoboKassa](https://github.com/hiqdev/omnipay-robokassa) | ✓ | ✓ | hiqdev/omnipay-robokassa | [HiQDev](https://github.com/hiqdev) 247 | [RocketGate](https://github.com/mvestil/omnipay-rocketgate) | ✓ | ✓ | mvestil/omnipay-rocketgate | [Mark Vestil](https://github.com/mvestil) 248 | [Sage Pay](https://github.com/thephpleague/omnipay-sagepay) | ✓ | ✓ | omnipay/sagepay | [Jason Judge](https://github.com/judgej) 249 | [Sberbank](https://github.com/AndrewNovikof/omnipay-sberbank) | - | ✓ | andrewnovikof/omnipay-sberbank | [Andrew Novikov](https://github.com/AndrewNovikof) 250 | [SecPay](https://github.com/justinbusschau/omnipay-secpay) | ✓ | - | justinbusschau/omnipay-secpay | [Justin Busschau](https://github.com/justinbusschau) 251 | [SecurePay](https://github.com/thephpleague/omnipay-securepay) | ✓ | ✓ | omnipay/securepay | [Omnipay](https://github.com/thephpleague/omnipay) 252 | [Secure Trading](https://github.com/meebio/omnipay-secure-trading) | ✓ | - | meebio/omnipay-secure-trading | [John Jablonski](https://github.com/jan-j) 253 | [Sisow](https://github.com/fruitcake/omnipay-sisow) | ✓ | ✓ | fruitcakestudio/omnipay-sisow | [Fruitcake](https://github.com/fruitcake) 254 | [Skrill](https://github.com/alfaproject/omnipay-skrill) | ✓ | - | alfaproject/omnipay-skrill | [João Dias](https://github.com/alfaproject) 255 | [Sofort](https://github.com/aimeoscom/omnipay-sofort) | ✓ | - | aimeoscom/omnipay-sofort | [Aimeos GmbH](https://github.com/aimeoscom) 256 | [Spreedly](https://github.com/gregoriohc/omnipay-spreedly) | ✓ | - | gregoriohc/omnipay-spreedly | [Gregorio Hernández Caso](https://github.com/gregoriohc) 257 | [Square](https://github.com/Transportersio/omnipay-square) | ✓ | - | transportersio/omnipay-square | [Transporters.io](https://github.com/Transportersio) 258 | [Stripe](https://github.com/thephpleague/omnipay-stripe) | ✓ | ✓ | omnipay/stripe | [Del](https://github.com/delatbabel) 259 | [TargetPay](https://github.com/thephpleague/omnipay-targetpay) | ✓ | - | omnipay/targetpay | [Alexander Deruwe](https://github.com/aderuwe) 260 | [TatraBank](https://github.com/bileto/omnipay-tatrabank) | ✓ | - | omnipay-tatrabank | 261 | [UnionPay](https://github.com/lokielse/omnipay-unionpay) | ✓ | ✓ | lokielse/omnipay-unionpay | [Loki Else](https://github.com/lokielse) 262 | [Vantiv](https://github.com/lemonstand/omnipay-vantiv) | ✓ | - | lemonstand/omnipay-vantiv | [LemonStand](https://github.com/lemonstand) 263 | [Veritrans](https://github.com/andylibrian/omnipay-veritrans) | ✓ | - | andylibrian/omnipay-veritrans | [Andy Librian](https://github.com/andylibrian) 264 | [Vindicia](https://github.com/vimeo/omnipay-vindicia) | ✓ | - | vimeo/omnipay-vindicia | [Vimeo](https://github.com/vimeo) 265 | [VivaPayments](https://github.com/delatbabel/omnipay-vivapayments) | ✓ | - | delatbabel/omnipay-vivapayments | [Del](https://github.com/delatbabel) 266 | [VR Payment](https://github.com/antibodies-online/omnipay-vr-payment) | - | ✓ | antibodies-online/omnipay-vr-payment | [antibodies-online](https://github.com/antibodies-online) 267 | [WebMoney](https://github.com/dercoder/omnipay-webmoney) | ✓ | - | dercoder/omnipay-webmoney | [Alexander Fedra](https://github.com/dercoder) 268 | [WeChat](https://github.com/labs7in0/omnipay-wechat) | ✓ | - | labs7in0/omnipay-wechat | [7IN0's Labs](https://github.com/labs7in0) 269 | [WechatPay](https://github.com/lokielse/omnipay-wechatpay) | ✓ | ✓ | lokielse/omnipay-wechatpay | [Loki Else](https://github.com/lokielse) 270 | [WePay](https://github.com/collizo4sky/omnipay-wepay) | ✓ | - | collizo4sky/omnipay-wepay | [Agbonghama Collins](https://github.com/collizo4sky) 271 | [Wirecard](https://github.com/igaponov/omnipay-wirecard) | ✓ | ✓ | igaponov/omnipay-wirecard | [Igor Gaponov](https://github.com/igaponov) 272 | [Wirecard](https://github.com/academe/omnipay-wirecard) | ✓ | - | academe/omnipay-wirecard | [Jason Judge](https://github.com/judgej) 273 | [Worldpay XML Direct Corporate Gateway](https://github.com/teaandcode/omnipay-worldpay-xml) | ✓ | - | teaandcode/omnipay-worldpay-xml | [Dave Nash](https://github.com/teaandcode) 274 | [Worldpay XML Hosted Corporate Gateway](https://github.com/catharsisjelly/omnipay-worldpay-cg-hosted) | ✓ | ✓ | catharsisjelly/omnipay-worldpay-cg-hosted | [Chris Lock](https://github.com/catharsisjelly) 275 | [Worldpay Business Gateway](https://github.com/thephpleague/omnipay-worldpay) | ✓ | ✓ | omnipay/worldpay | [Omnipay](https://github.com/thephpleague/omnipay) 276 | [Yandex.Kassa](https://github.com/hiqdev/omnipay-yandex-kassa) | ✓ | ✓ | hiqdev/omnipay-yandex-kassa | [HiQDev](https://github.com/hiqdev) 277 | [Yandex.Money](https://github.com/yandex-money/yandex-money-cms-omnipay) | ✓ | - | yandexmoney/omnipay | [Roman Ananyev](https://github.com/aTastyCookie/) 278 | [Yandex.Money for P2P payments](https://github.com/hiqdev/omnipay-yandexmoney) | ✓ | - | hiqdev/omnipay-yandexmoney | [HiQDev](https://github.com/hiqdev) 279 | [Tpay](https://github.com/tpay-com/omnipay-tpay) | ✓ | - | omnipay/tpay | [Tpay.com](https://github.com/tpay-com) 280 | [Faspay](https://github.com/David-Kurniawan/omnipay-faspay) | ✓ | ✓ | David-Kurniawan/omnipay-faspay | [David](https://github.com/David-Kurniawan) 281 | [Yekpay](https://github.com/nekofar/omnipay-yekpay) | - | ✓ | nekofar/omnipay-yekpay | [Milad Nekofar](https://github.com/nekofar) 282 | [ZarinPal](https://github.com/nekofar/omnipay-zarinpal) | - | ✓ | nekofar/omnipay-zarinpal | [Milad Nekofar](https://github.com/nekofar) 283 | [Moneris](https://github.com/unoapp-dev/omnipay-moneris) | - | ✓ | unoapp-dev/omnipay-moneris | [UNOapp Dev](https://github.com/unoapp-dev) 284 | 285 | Gateways are created and initialized like so: 286 | 287 | ```php 288 | use Omnipay\Omnipay; 289 | 290 | $gateway = Omnipay::create('PayPal_Express'); 291 | $gateway->setUsername('adrian'); 292 | $gateway->setPassword('12345'); 293 | ``` 294 | 295 | Most settings are gateway specific. If you need to query a gateway to get a list 296 | of available settings, you can call `getDefaultParameters()`: 297 | 298 | ```php 299 | $settings = $gateway->getDefaultParameters(); 300 | // default settings array format: 301 | array( 302 | 'username' => '', // string variable 303 | 'testMode' => false, // boolean variable 304 | 'landingPage' => array('billing', 'login'), // enum variable, first item should be treated as default 305 | ); 306 | ``` 307 | 308 | Generally most payment gateways can be classified as one of two types: 309 | 310 | * Off-site gateways such as PayPal Express, where the customer is redirected to a third party site to enter payment details 311 | * On-site (merchant-hosted) gateways such as PayPal Pro, where the customer enters their credit card details on your site 312 | 313 | However, there are some gateways such as Sage Pay Direct, where you take credit card details on site, then optionally redirect 314 | if the customer's card supports 3D Secure authentication. Therefore, there is no point differentiating between the two types of 315 | gateway (other than by the methods they support). 316 | 317 | ## Credit Card / Payment Form Input 318 | 319 | User form input is directed to an [CreditCard](https://github.com/thephpleague/omnipay-common/blob/master/src/Common/CreditCard.php) 320 | object. This provides a safe way to accept user input. 321 | 322 | The `CreditCard` object has the following fields: 323 | 324 | * firstName 325 | * lastName 326 | * number 327 | * expiryMonth 328 | * expiryYear 329 | * startMonth 330 | * startYear 331 | * cvv 332 | * issueNumber 333 | * type 334 | * billingAddress1 335 | * billingAddress2 336 | * billingCity 337 | * billingPostcode 338 | * billingState 339 | * billingCountry 340 | * billingPhone 341 | * shippingAddress1 342 | * shippingAddress2 343 | * shippingCity 344 | * shippingPostcode 345 | * shippingState 346 | * shippingCountry 347 | * shippingPhone 348 | * company 349 | * email 350 | 351 | Even off-site gateways make use of the `CreditCard` object, because often you need to pass 352 | customer billing or shipping details through to the gateway. 353 | 354 | The `CreditCard` object can be initialized with untrusted user input via the constructor. 355 | Any fields passed to the constructor which are not recognized will be ignored. 356 | 357 | ```php 358 | $formInputData = array( 359 | 'firstName' => 'Bobby', 360 | 'lastName' => 'Tables', 361 | 'number' => '4111111111111111', 362 | ); 363 | $card = new CreditCard($formInputData); 364 | ``` 365 | 366 | You can also just pass the form data array directly to the gateway, and a `CreditCard` object 367 | will be created for you. 368 | 369 | CreditCard fields can be accessed using getters and setters: 370 | 371 | ```php 372 | $number = $card->getNumber(); 373 | $card->setFirstName('Adrian'); 374 | ``` 375 | 376 | If you submit credit card details which are obviously invalid (missing required fields, or a number 377 | which fails the Luhn check), [InvalidCreditCardException](https://github.com/thephpleague/omnipay-common/blob/master/src/Omnipay/Common/Exception/InvalidCreditCardException.php) 378 | will be thrown. You should validate the card details using your framework's validation library 379 | before submitting the details to your gateway, to avoid unnecessary API calls. 380 | 381 | For on-site payment gateways, the following card fields are generally required: 382 | 383 | * firstName 384 | * lastName 385 | * number 386 | * expiryMonth 387 | * expiryYear 388 | * cvv 389 | 390 | You can also verify the card number using the Luhn algorithm by calling `Helper::validateLuhn($number)`. 391 | 392 | ## Gateway Methods 393 | 394 | The main methods implemented by gateways are: 395 | 396 | * `authorize($options)` - authorize an amount on the customer's card 397 | * `completeAuthorize($options)` - handle return from off-site gateways after authorization 398 | * `capture($options)` - capture an amount you have previously authorized 399 | * `purchase($options)` - authorize and immediately capture an amount on the customer's card 400 | * `completePurchase($options)` - handle return from off-site gateways after purchase 401 | * `refund($options)` - refund an already processed transaction 402 | * `void($options)` - generally can only be called up to 24 hours after submitting a transaction 403 | * `acceptNotification()` - convert an incoming request from an off-site gateway to a generic notification object 404 | for further processing 405 | 406 | On-site gateways do not need to implement the `completeAuthorize` and `completePurchase` methods. Gateways that don't 407 | receive payment notifications don't need to implement `acceptNotification`. If any gateway does not support certain 408 | features (such as refunds), it will throw `BadMethodCallException`. 409 | 410 | All gateway methods except `acceptNotification` take an `$options` array as an argument. The `acceptNotification` method 411 | does not take any parameters and will access the HTTP URL variables or POST data implicitly. Each gateway differs in 412 | which parameters are required, and the gateway will throw `InvalidRequestException` if you omit any required parameters. 413 | All gateways will accept a subset of these options: 414 | 415 | * card 416 | * token 417 | * amount 418 | * currency 419 | * description 420 | * transactionId 421 | * clientIp 422 | * returnUrl 423 | * cancelUrl 424 | 425 | Pass the options through to the method like so: 426 | 427 | ```php 428 | $card = new CreditCard($formData); 429 | $request = $gateway->authorize(array( 430 | 'amount' => '10.00', // this represents $10.00 431 | 'card' => $card, 432 | 'returnUrl' => 'https://www.example.com/return', 433 | )); 434 | ``` 435 | 436 | When calling the `completeAuthorize` or `completePurchase` methods, the exact same arguments should be provided as 437 | when you made the initial `authorize` or `purchase` call (some gateways will need to verify for example the actual 438 | amount paid equals the amount requested). The only parameter you can omit is `card`. 439 | 440 | To summarize the various parameters you have available to you: 441 | 442 | * Gateway settings (e.g. username and password) are set directly on the gateway. These settings apply to all payments, and generally you will store these in a configuration file or in the database. 443 | * Method options are used for any payment-specific options, which are not set by the customer. For example, the payment `amount`, `currency`, `transactionId` and `returnUrl`. 444 | * CreditCard parameters are data which the user supplies. For example, you want the user to specify their `firstName` and `billingCountry`, but you don't want a user to specify the payment `currency` or `returnUrl`. 445 | 446 | ## The Payment Response 447 | 448 | The payment response must implement [ResponseInterface](https://github.com/thephpleague/omnipay-common/blob/master/src/Omnipay/Common/Message/ResponseInterface.php). There are two main types of response: 449 | 450 | * Payment was successful (standard response) 451 | * Website requires redirect to off-site payment form (redirect response) 452 | 453 | ### Successful Response 454 | 455 | For a successful responses, a reference will normally be generated, which can be used to capture or refund the transaction 456 | at a later date. The following methods are always available: 457 | 458 | ```php 459 | $response = $gateway->purchase(array('amount' => '10.00', 'card' => $card))->send(); 460 | 461 | $response->isSuccessful(); // is the response successful? 462 | $response->isRedirect(); // is the response a redirect? 463 | $response->getTransactionReference(); // a reference generated by the payment gateway 464 | $response->getTransactionId(); // the reference set by the originating website if available. 465 | $response->getMessage(); // a message generated by the payment gateway 466 | ``` 467 | 468 | In addition, most gateways will override the response object, and provide access to any extra fields returned by the gateway. 469 | 470 | ### Redirect Response 471 | 472 | The redirect response is further broken down by whether the customer's browser must redirect using GET (RedirectResponse object), or 473 | POST (FormRedirectResponse). These could potentially be combined into a single response class, with a `getRedirectMethod()`. 474 | 475 | After processing a payment, the cart should check whether the response requires a redirect, and if so, redirect accordingly: 476 | 477 | ```php 478 | $response = $gateway->purchase(array('amount' => '10.00', 'card' => $card))->send(); 479 | if ($response->isSuccessful()) { 480 | // payment is complete 481 | } elseif ($response->isRedirect()) { 482 | $response->redirect(); // this will automatically forward the customer 483 | } else { 484 | // not successful 485 | } 486 | ``` 487 | 488 | The customer isn't automatically forwarded on, because often the cart or developer will want to customize the redirect method 489 | (or if payment processing is happening inside an AJAX call they will want to return JS to the browser instead). 490 | 491 | To display your own redirect page, simply call `getRedirectUrl()` on the response, then display it accordingly: 492 | 493 | ```php 494 | $url = $response->getRedirectUrl(); 495 | // for a form redirect, you can also call the following method: 496 | $data = $response->getRedirectData(); // associative array of fields which must be posted to the redirectUrl 497 | ``` 498 | 499 | ## Error Handling 500 | 501 | You can test for a successful response by calling `isSuccessful()` on the response object. If there 502 | was an error communicating with the gateway, or your request was obviously invalid, an exception 503 | will be thrown. In general, if the gateway does not throw an exception, but returns an unsuccessful 504 | response, it is a message you should display to the customer. If an exception is thrown, it is 505 | either a bug in your code (missing required fields), or a communication error with the gateway. 506 | 507 | You can handle both scenarios by wrapping the entire request in a try-catch block: 508 | 509 | ```php 510 | try { 511 | $response = $gateway->purchase(array('amount' => '10.00', 'card' => $card))->send(); 512 | if ($response->isSuccessful()) { 513 | // mark order as complete 514 | } elseif ($response->isRedirect()) { 515 | $response->redirect(); 516 | } else { 517 | // display error to customer 518 | exit($response->getMessage()); 519 | } 520 | } catch (\Exception $e) { 521 | // internal error, log exception and display a generic message to the customer 522 | exit('Sorry, there was an error processing your payment. Please try again later.'); 523 | } 524 | ``` 525 | 526 | ## Test mode and developer mode 527 | Most gateways allow you to set up a sandbox or developer account which uses a different url 528 | and credentials. Some also allow you to do test transactions against the live site, which does 529 | not result in a live transaction. 530 | 531 | Gateways that implement only the developer account (most of them) call it testMode. Authorize.net, 532 | however, implements both and refers to this mode as developerMode. 533 | 534 | When implementing with multiple gateways you should use a construct along the lines of the following: 535 | ```php 536 | if ($is_developer_mode) { 537 | if (method_exists($gateway, 'setDeveloperMode')) { 538 | $gateway->setDeveloperMode(TRUE); 539 | } else { 540 | $gateway->setTestMode(TRUE); 541 | } 542 | } 543 | ``` 544 | 545 | ## Token Billing 546 | 547 | Token billing allows you to store a credit card with your gateway, and charge it at a later date. 548 | Token billing is not supported by all gateways. For supported gateways, the following methods 549 | are available: 550 | 551 | * `createCard($options)` - returns a response object which includes a `cardReference`, which can be used for future transactions 552 | * `updateCard($options)` - update a stored card, not all gateways support this method 553 | * `deleteCard($options)` - remove a stored card, not all gateways support this method 554 | 555 | Once you have a `cardReference`, you can use it instead of the `card` parameter when creating a charge: 556 | 557 | $gateway->purchase(array('amount' => '10.00', 'cardReference' => 'abc')); 558 | 559 | ## Recurring Billing 560 | 561 | At this stage, automatic recurring payments functionality is out of scope for this library. 562 | This is because there is likely far too many differences between how each gateway handles 563 | recurring billing profiles. Also in most cases token billing will cover your needs, as you can 564 | store a credit card then charge it on whatever schedule you like. Feel free to get in touch if 565 | you really think this should be a core feature and worth the effort. 566 | 567 | ## Incoming Notifications 568 | 569 | Some gateways (e.g. Cybersource, GoPay) offer HTTP notifications to inform the merchant about the completion (or, in 570 | general, status) of the payment. To assist with handling such notifications, the `acceptNotification()` method will 571 | extract the transaction reference and payment status from the HTTP request and return a generic `NotificationInterface`. 572 | 573 | ```php 574 | $notification = $gateway->acceptNotification(); 575 | 576 | $notification->getTransactionReference(); // A reference provided by the gateway to represent this transaction 577 | $notification->getTransactionStatus(); // Current status of the transaction, one of NotificationInterface::STATUS_* 578 | $notification->getMessage(); // Additional message, if any, provided by the gateway 579 | 580 | // update the status of the corresponding transaction in your database 581 | ``` 582 | 583 | **Note:** some earlier gateways used the `completeAuthorize` and `completePurchase` messages to handle the incoming 584 | notifications. These are being converted and the `complete*` messages deprecated. 585 | They won't be removed in OmniPay 2.x, but it is advisable to switch to the `acceptNotification` message when convenient. 586 | An example is Sage Pay Server [completeAuthorize](https://github.com/thephpleague/omnipay-sagepay/blob/master/src/ServerGateway.php#L81) 587 | which is now handled by [acceptNotification](https://github.com/thephpleague/omnipay-sagepay/blob/master/src/ServerGateway.php#L40). 588 | 589 | ## Example Application 590 | 591 | An example application is provided in the [omnipay/example](https://github.com/thephpleague/omnipay-example) repo. 592 | You can run it using PHP's built in web server (PHP 5.4+): 593 | 594 | $ php composer.phar update --dev 595 | $ php -S localhost:8000 596 | 597 | For more information, see the [Omnipay example application](https://github.com/thephpleague/omnipay-example). 598 | 599 | ## Support 600 | 601 | If you are having general issues with Omnipay, we suggest posting on 602 | [Stack Overflow](http://stackoverflow.com/). Be sure to add the 603 | [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. 604 | 605 | If you want to keep up to date with release anouncements, discuss ideas for the project, 606 | or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which 607 | you can subscribe to. 608 | 609 | If you believe you have found a bug, please report it using the GitHub issue tracker 610 | for the appropriate package, or better yet, fork the library and submit a pull request. 611 | 612 | ## Security 613 | If you discover any security related issues, please email barryvdh@gmail.com instead of using the issue tracker. 614 | 615 | 616 | ## Feedback 617 | 618 | **Please provide feedback!** We want to make this library useful in as many projects as possible. 619 | Please head on over to the [mailing list](https://groups.google.com/forum/#!forum/omnipay) 620 | and point out what you do and don't like, or fork the project and make suggestions. **No issue is too small.** 621 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "league/omnipay", 3 | "type": "metapackage", 4 | "description": "Omnipay payment processing library", 5 | "keywords": [ 6 | "omnipay", 7 | "checkout", 8 | "creditcard", 9 | "payment" 10 | ], 11 | "homepage": "https://omnipay.thephpleague.com/", 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "name": "Adrian Macneil", 16 | "email": "adrian@adrianmacneil.com" 17 | }, 18 | { 19 | "name": "Barry vd. Heuvel", 20 | "email": "barryvdh@gmail.com" 21 | } 22 | ], 23 | "require": { 24 | "php": "^7.2", 25 | "omnipay/common": "^3", 26 | "php-http/discovery": "^1.12", 27 | "php-http/guzzle7-adapter": "^0.1" 28 | }, 29 | "require-dev": { 30 | "omnipay/tests": "^3" 31 | }, 32 | "autoload-dev": { 33 | "psr-4": { "Omnipay\\Tests\\" : "tests" } 34 | }, 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "3.1.x-dev" 38 | } 39 | }, 40 | "scripts": { 41 | "test": "phpunit" 42 | }, 43 | "minimum-stability": "dev", 44 | "prefer-stable": true 45 | } 46 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | 19 | ./src 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/OmnipayTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf('Omnipay\Common\GatewayFactory', $factory); 23 | } 24 | 25 | 26 | /** 27 | * Verify a new Client instance can be instantiated 28 | */ 29 | public function testNewClient() 30 | { 31 | $client = new Client(); 32 | 33 | $this->assertInstanceOf('Omnipay\Common\Http\Client', $client); 34 | } 35 | } --------------------------------------------------------------------------------