PHPackages                             apvanlaan/usaepay - 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. apvanlaan/usaepay

ActiveLibrary[Payment Processing](/categories/payments)

apvanlaan/usaepay
=================

Allows easy connection with and use of USAePay's REST API with Laravel

v1.1(3y ago)12924[19 PRs](https://github.com/apvanlaan/laravel-usaepay/pulls)MITPHP

Since Jul 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/apvanlaan/laravel-usaepay)[ Packagist](https://packagist.org/packages/apvanlaan/usaepay)[ Docs](https://github.com/apvanlaan/usaepay)[ RSS](/packages/apvanlaan-usaepay/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (32)Used By (0)

USAePay Rest API Package for Laravel
====================================

[](#usaepay-rest-api-package-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/93aaf0401458a8ab8f727eb55ad174a484cd78475a0b0a277fb5ae2a63547cb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617076616e6c61616e2f757361657061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/apvanlaan/usaepay)[![Build Status](https://camo.githubusercontent.com/b56547b203c3e25b3728f911e0f8789ff354d18419d20bbeeed8d7e6cd500d37/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f617076616e6c61616e2f757361657061792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/github/apvanlaan/laravel-usaepay)

Project was created by, and is maintained by [Aaron VanLaan](https://github.com/apvanlaan).

Usage
-----

[](#usage)

Table Of Content
----------------

[](#table-of-content)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [EpayCustomer Class](#epaycustomer-class)
    - [Parameters](#epaycustomer-class-parameters)
    - [Methods](#epaycustomer-class-example)
4. [EpayTransaction Class](#epaytransaction-class)
    - [Parameters](#epaytransaction-class-parameters)
    - [Methods](#epaytransaction-class-example)
    - [EpayTransaction Child Classes](#epaytransaction-class-children)
        - [EpayAmountDetail Class](#epayamountdetail-class)
        - [EpayCreditCard Class](#epaycreditcard-class)
        - [EpayCustomerAddress Class](#epaycustomeraddress-class)
        - [EpayCustomField Class (COMING SOON)](#epaycustomfield-class)
        - [EpayLineItem Class](#epaylineitem-class)
        - [EpayTrait Class](#epaytrait-class)
5. [EpayBatch Class](#epaybatch-class)
    - [Parameters](#epaybatch-class-parameters)
    - [Methods](#epaybatch-class-example)
6. [EpayProduct Class](#epayproduct-class)
    - [Parameters](#epayproduct-class-parameters)
    - [Methods](#epayproduct-class-example)
7. [EpayCategory Class](#epaycategory-class)
    - [Parameters](#epaycategory-class-parameters)
    - [Methods](#epaycategory-class-example)
8. [EpayInventory Class (COMING SOON)](#epayinventory-class)
    - [Parameters](#epayinventory-class-parameters)
    - [Methods](#epayinventory-class-example)
9. [Examples](#examples)
    - [Example View](#example-view)
    - [Example Vue Component](#example-vue)

Requirements
------------

[](#requirements)

This library uses PHP 7.4+ and Laravel 6+

You can find the USAePay Rest API docs here :

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

[](#installation)

Require via Composer

```
$ composer require apvanlaan/usaepay
```

Publish Assets

```
$ php artisan vendor:publish --provider="Apvanlaan\UsaEpay\UsaEpayServiceProvider"
```

Add required ENV variables to .env

```
EPAYAPI=
#EPAYPIN= (optional, only include if pin is utilized)
EPAYPUBLIC=
EPAY_SUB=sandbox (change to secure for production)
#EPAY_ENDPOINT= (optional, use if using a custom endpoint, otherwise defaults to v2)

```

Note: In the following sections, the included routes relate to the controllers I have included in the package. If you end up rolling your own then obviously you can ignore those. The required fields, however, are required via the USAePay API, so those must remain.

EpayCustomer Class
------------------

[](#epaycustomer-class)

The EpayCustomer Class handles the creation of the Customer object and the associated api calls.

### Parameters

[](#parameters)

EpayCustomer parameters are: (note: all listed required are the minimum required by the USAePay API)

- `company` String
- `first_name` String
- `last_name` String
- `customerid` String
- `street` String
- `street2`
- `city` String
- `state` String
- `postalcode` String
- `country` String
- `phone` String
- `fax` String
- `email` String
- `url` String
- `notes` String
- `description` String
- `custkey` String

### EpayCustomer Methods w/ default required params and Examples

[](#epaycustomer-methods-w-default-required-params-and-examples)

#### (note: there are two ways to instantiate the epay classes, you can pass an array/object with the paramters or you can instantiate an empty class and manually set the parameters as needed.)

[](#note-there-are-two-ways-to-instantiate-the-epay-classes-you-can-pass-an-arrayobject-with-the-paramters-or-you-can-instantiate-an-empty-class-and-manually-set-the-parameters-as-needed)

#### getCustomer()

[](#getcustomer)

- Route : ` GET epay/customer/get/{custkey}`
- Required : `custkey`

```
$customer = new EpayCustomer();
$customer->custkey = $custkey;

return $customer->getCustomer();
```

#### listCustomers()

[](#listcustomers)

- Route : `GET epay/customer/list`
- Required : `none`

```
$customer = new EpayCustomer();

return $customer->listCustomers();
```

#### addCustomer()

[](#addcustomer)

- Route : `POST epay/customer/create`
- Required : `company (if no first_name && last_name), first_name (if no company), last_name (if no company)`

```
$customer = new EpayCustomer();
$params = ['first_name' =>"John",'last_name' =>"Doe",'street' =>"123 House Rd",'city' =>"Beverly Hills",'state' =>"CA",'postalcode' =>"90210",'country' =>"USA",'phone' =>"5558675309",'email' =>"john.doe@email.com",'description' =>"Fake customer information for testing."];
return $customer->addCustomer($params);
```

#### updateCustomer()

[](#updatecustomer)

- Route : `POST epay/customer/update`
- Required : `custkey`

```
$customerUpdate = new \StdClass();
$customerUpdate->custkey = "asdf";
$customerUpdate->description = 'Still a fake customer used for testing';

$customer = new EpayCustomer($params);

return $customer->updateCustomer();
```

#### deleteCustomer()

[](#deletecustomer)

- Route : `POST epay/customer/delete`
- Required : `custkey`

```
$params = ['custkey'=>$request->custkey];
$customer = new EpayCustomer($params);

return $customer->deleteCustomer();
```

EpayTransaction Class
---------------------

[](#epaytransaction-class)

The EpayTransaction Class handles the creation of the Transaction object and the associated api calls.

### Parameters

[](#parameters-1)

EpayTransaction parameters are:

- `trankey` String
- `refnum` String
- `invoice` String
- `ponum` String
- `orderid` String
- `description` String
- `comments` String
- `email` String
- `merchemailaddr` String
- `amount` Float
- `amount_detail` Transactions\\EpayAmountDetail
- `creditcard` Transactions\\EpayCreditCard
- `save_card` Bool
- `traits` Transactions\\EpayTrait
- `custkey` String
- `save_customer` Bool
- `save_customer_paymethod` Bool
- `billing_address` Transactions\\EpayCustomerAddress
- `shipping_address` Transactions\\EpayCustomerAddress
- `lineitmes` Transactions\\EpayLineItem
- `custom_fields` Transactions\\EpayCustomField
- `currency` String
- `terminal` String
- `clerk` String
- `clientip` String
- `software` String

### EpayTransaction Methods w/ default required params

[](#epaytransaction-methods-w-default-required-params)

#### listAuthorized()

[](#listauthorized)

- Route : `GET epay/transaction/list`
- Required : `none`

#### listAuthorized()

[](#listauthorized-1)

- Route : `GET epay/transaction/list`
- Required : `trankey`

#### createSale()

[](#createsale)

- Route : `POST epay/transaction/sale`
- Required : `amount, payment_key (if no creditcard), creditcard (if no payment_key)`

#### createRefund()

[](#createrefund)

- Required : `amount, creditcard`

#### createVoid()

[](#createvoid)

- Route : `POST epay/transaction/void`
- Required : `trankey (if no refnum), refnum (if no trankey)`

#### authorizeTransaction()

[](#authorizetransaction)

- Route : `POST epay/transaction/auth`
- Required : `amount, payment_key (if no creditcard), creditcard (if no payment_key)`

#### captureTransaction()

[](#capturetransaction)

- Route : `POST epay/transaction/capture`
- Required : `trankey (if no refnum), refnum (if no trankey)`

### EpayTransaction Child Classes

[](#epaytransaction-child-classes)

### EpayAmountDetail Class &amp; Parameters

[](#epayamountdetail-class--parameters)

- `subtotal` Double
- `tax` Double
- `nontaxable` Bool
- `tip` Double
- `discount` Double
- `shipping` Double
- `duty` Double
- `enable_partialauth` Bool

### EpayCreditCard Class &amp; Parameters

[](#epaycreditcard-class--parameters)

- `cardholder` String
- `number` String
- `expiration` String
- `cvc` Int
- `avs_street` String
- `avs_postalcode` String

### EpayCustomerAddress Class &amp; Parameters

[](#epaycustomeraddress-class--parameters)

- `company` String
- `firstname` String
- `lastname` String
- `street` String
- `street2` String
- `city` String
- `state` String
- `postalcode` String
- `country` String
- `phone` String
- `fax; ` String

### EpayLineItem Class &amp; Parameters

[](#epaylineitem-class--parameters)

- `product_key` String
- `name` String
- `cost` Double
- `qty` Int
- `description` String
- `sku` String
- `taxable` Bool
- `tax_amount` Double
- `tax_rate` String
- `discount_rate` String
- `discount_amount` Double
- `location_key` String
- `commodity_code` String

### EpayTrait Class &amp; Parameters

[](#epaytrait-class--parameters)

- `is_debt` Bool
- `is_bill_pay` Bool
- `is_recurring` Bool
- `is_healthcare` Bool
- `is_cash_advance` Bool
- `secure_collection` Int

EpayBatch Class
---------------

[](#epaybatch-class)

The EpayBatch Class handles the creation of the Batch object and the associated api calls.

### Parameters

[](#parameters-2)

EpayBatch parameters are:

- `limit` Int
- `offset` Int
- `openedlt` String
- `openedgt` String
- `closedlt` String
- `closedgt` String
- `openedle` String
- `openedge` String
- `closedle` String
- `closedge` String
- `batch_key` String

### EpayBatch Methods w/ default required params

[](#epaybatch-methods-w-default-required-params)

#### listBatches()

[](#listbatches)

- Route : `GET epay/batch/list`
- Required : `none`

#### currentBatch()

[](#currentbatch)

- Route : `GET epay/batch/current`
- Required : `none`

#### retrieveBatch()

[](#retrievebatch)

- Route : `POST epay/batch/retrieve`
- Required : `batch_key`

#### getCurrentBatchTransactions()

[](#getcurrentbatchtransactions)

- Route : `GET epay/batch/currentTransactions`
- Required : `none`

#### getTransactionsByBatch()

[](#gettransactionsbybatch)

- Route : `GET epay/batch/transactionsByBatch`
- Required : `trankey (if no refnum), refnum (if no trankey)`

#### closeBatch()

[](#closebatch)

- Route : `POST epay/batch/close`
- Required : `batch_key`

EpayProduct Class
-----------------

[](#epayproduct-class)

The EpayProduct Class handles the creation of the Product object and the associated api calls.

### Parameters

[](#parameters-3)

- `name` String
- `price` Float
- `enabled` Bool
- `taxable` Bool
- `available_all` Bool
- `available_all_date` String
- `categoryid` Int
- `commodity_code` String
- `date_available` String
- `description` String
- `list_price` Float
- `wholesale_price` Float
- `manufacturer` String
- `merch_productid` String
- `min_quantity` Int
- `model` String
- `physicalgood` Bool
- `weight` Int
- `ship_weight` Int
- `sku` String
- `taxclass` String
- `um` String
- `upc` String
- `url` String
- `allow_override` Bool
- `product_key` String
- `limit` Int
- `offset` Int
- `inventory` Array
- `modifiers` Array

### EpayProduct Methods w/ default required params

[](#epayproduct-methods-w-default-required-params)

#### listProducts()

[](#listproducts)

- Route : `GET epay/product/list`
- Required : `none`

#### createProduct()

[](#createproduct)

- Route : `POST epay/product/create`
- Required : `name`

#### getProduct()

[](#getproduct)

- Route : `GET epay/product/get`
- Required : `product_key`

#### updateProduct()

[](#updateproduct)

- Route : `POST epay/product/update`
- Required : `product_key`

#### deleteProduct()

[](#deleteproduct)

- Route : `POST epay/product/delete`
- Required : `product_key`

EpayCategory Class
------------------

[](#epaycategory-class)

The EpayCategory Class handles the creation of the Category object and the associated api calls.

### Parameters

[](#parameters-4)

- `name` String
- `categorykey` String
- `limit` Int
- `offset` Int
- `modifiers` Array

### EpayCategory Methods w/ default required params

[](#epaycategory-methods-w-default-required-params)

#### listCategories()

[](#listcategories)

- Route : `GET epay/category/list`
- Required : `none`

#### createCategory()

[](#createcategory)

- Route : `POST epay/category/create`
- Required : `name`

#### getCategory()

[](#getcategory)

- Route : `GET epay/category/get`
- Required : `category_key`

#### updateCategory()

[](#updatecategory)

- Route : `POST epay/category/update`
- Required : `category_key`

#### deleteCategory()

[](#deletecategory)

- Route : `POST epay/category/delete`
- Required : `category_key`

EpayInventory Class
-------------------

[](#epayinventory-class)

(COMING SOON)

### Parameters (COMING SOON)

[](#parameters-coming-soon)

EpayInventory Methods w/ default required params (COMING SOON)
--------------------------------------------------------------

[](#epayinventory-methods-w-default-required-params-coming-soon)

Examples
--------

[](#examples)

The following is an example of creating a View in Laravel that utilizes a Vue Component

### Example View

[](#example-view)

```

            Payment/Auth Form

            Transaction List

```

### Example Vue Component

[](#example-vue-component)

```

            Save Customer?

            Transaction Type

            Authorization

            Sale

            Amount : ${{transaction.amount}}

            Email

                    Company

                    First Name

                    Last Name

                    Address

                    Apt / Building

                    City

                    State

                    Zip

                    Country

                        Select Country
                        US
                        Canada

                    Phone#

            Different Billing Address?

                Company

                First Name

                Last Name

                Address

                Apt / Building

                City

                State

                Zip

                Country

                    Select Country
                    US
                    Canada

                Phone#

            Submit

    Results : {{results}}

    export default {
        props: ['publickey'],
        data() {
            return {
                transaction:{
                    billing_address:{
                        company:'',
                        firstname:'',
                        lastname:'',
                        street:'',
                        street2:'',
                        city:'',
                        state:'',
                        postalcode:'',
                        country:'',
                        phone:'',
                    },
                    shipping_address:{
                        company:'',
                        firstname:'',
                        lastname:'',
                        street:'',
                        street2:'',
                        city:'',
                        state:'',
                        postalcode:'',
                        country:'',
                        phone:'',
                    },
                    lineitems:[
                        {
                            name: "Test1",
                            cost: 3.50,
                            qty: 2,
                            description: "This is the first test item."
                        },
                        {
                            name: "Test2",
                            cost: 3.75,
                            qty: 1,
                            description: "This is the second test item."
                        }
                    ],
                    email:'',
                    type:'auth',
                    amount:3.5,
                },
                diffBilling:false,
                results:'',
                results_output:'',
                payment_key:'',
                saveCust:false,
            }
        },
        methods: {
            submitForm(){
                var self = this;
                self.$refs.cc.errormsg = '';
                var client = this.$refs.cc.client;
                var paymentCard = this.$refs.cc.paymentCard;
                if(!self.diffBilling){
                    self.transaction.billing_address = self.transaction.shipping_address;
                }
                client.getPaymentKey(paymentCard).then(result => {
                    if (result.error) {
                        self.$refs.cc.errormsg = result.error.message;
                    } else {
                        // do something with your payment key
                        self.payment_key = result;
                    }
                    self.transaction.payment_key = self.payment_key;
                    if(self.saveCust == true){
                        self.transaction.save_customer = 1;
                    }
                    axios.post('api/epay/transaction/' + self.transaction.type,self.transaction).then(function(response){
                        self.results = response.data;
                        if(self.saveCust == true){
                            axios.get('api/epay/customer/get/' + response.data.customer.custkey).then(function(customer){
                                self.results.customer = customer.data;
                            })
                        }
                         self.results_output = JSON.stringify(response.data,null,2);
                    })
                    .catch(function(error){
                        console.log(error.response.data.message);
                        self.$refs.cc.errormsg = "An error has occurred.  Please check the form and try again.\r\n Error Message: " + error.response.data.message;
                    });
                });
            },
        },
        watch:{
        },
        computed: {
        },
        mounted: function(){
        }
    }

.paymentForm{width:300px;}

```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Credits
-------

[](#credits)

- [Aaron VanLaan](https://github.com/apvanlaan)

License
-------

[](#license)

The USAePay REST API Package for Laravel is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% 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 ~66 days

Recently: every ~177 days

Total

12

Last Release

1398d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/235ff2030760c858905581b94282fa735e8dd5f231f2747aaf87b17e03ee8bf8?d=identicon)[apvanlaan](/maintainers/apvanlaan)

---

Top Contributors

[![apvanlaan](https://avatars.githubusercontent.com/u/1636588?v=4)](https://github.com/apvanlaan "apvanlaan (51 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

laravelusaepay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/apvanlaan-usaepay/health.svg)

```
[![Health](https://phpackages.com/badges/apvanlaan-usaepay/health.svg)](https://phpackages.com/packages/apvanlaan-usaepay)
```

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[henryejemuta/laravel-monnify

A laravel package to seamlessly integrate monnify api within your laravel application

132.1k](/packages/henryejemuta-laravel-monnify)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)

PHPackages © 2026

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