PHPackages                             brown-paper-tickets/bpt-api - 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. brown-paper-tickets/bpt-api

ActiveLibrary

brown-paper-tickets/bpt-api
===========================

A library for interacting with the Brown Paper Tickets API

1193PHP

Since Jul 31Pushed 8y ago1 watchersCompare

[ Source](https://github.com/chantron/bpt-api)[ Packagist](https://packagist.org/packages/brown-paper-tickets/bpt-api)[ RSS](/packages/brown-paper-tickets-bpt-api/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Brown Paper Tickets PHP API
===========================

[](#brown-paper-tickets-php-api)

[![Build Status](https://camo.githubusercontent.com/b306f184c492bc52d683e2a312a5f45e96e0c3289d89513e5b3f38e65d1dffae/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62726f776e70617065727469636b6574732f4270744150492e7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/brownpapertickets/BptAPI.php) [![Packagist](https://camo.githubusercontent.com/071f2ac39142d905bea460085bb7d8dac1027d549184f56e734556d460467b7f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62726f776e2d70617065722d7469636b6574732f6270742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brown-paper-tickets/bpt-api) [![License MIT](https://camo.githubusercontent.com/5eecf396a62aa09bbd78445f729e9e5377a75a1e3cade2c8164d61c0a4cee90c/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

The BptAPI library consists of a set of classes that enable you to easily interact with the [Brown Paper Tickets API](http://www.brownpapertickets.com/apidocs/index.html).

Since this library is still in early development, method names will possibly change. See [CHANGELOG](CHANGELOG.md) for more information on any breaking changes.

Install
-------

[](#install)

Via Composer: `$ composer require brown-paper-tickets/bpt-api`.

(This will also install Monolog\\Monolog as a dev dependency, if you don't need Monolog, add the `--no-dev` flag to composer.)

Usage
-----

[](#usage)

See [Usage.md](Usage.md) for a brief intro. You can also checkout the [api-example](https://www.github.com/brownpapertickets/api-example) app for a more complete example.

Options
-------

[](#options)

Currently there are three options that you can set: `debug`, `logErrors` and `logger`.

You can set them either by passing in an `$options` array as the second argument when you instantiate the classes or by using the `setOption()` method.`

optiontypedescriptionloggerPSR-3 Logger InterfaceIf you want to make use of a logger (like Monolog), you can pass it in with this option.debugbooleanIf debug is set to true, all errors will be logged as well as all the raw API call url's and responses.logErrorsbooleanIf set to true, all API errors will be logged to the object's `errors` array. If you have set a logger, they will also be logged there as well.For example:

```
$logger = new \Monolog\Logger('logger');

$logger->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__ . '/app.log', $logger::DEBUG));

$options = array(
    'logger' => $logger,
    'debug' => true,
    'logErrors' => true,
);
$info = new EventInfo(DEV_ID, $options);
```

`$info->setOption('logger', $logger);`

The Classes and Methods
-----------------------

[](#the-classes-and-methods)

The library contains the following classes:

- [AccountInfo](#accountinfo)
- [CartInfo](#cartinfo)
- [EventInfo](#eventinfo)
- [ManageCart](#managecart)
- [ManageEvent](#manageevent)
- [SalesInfo](#salesinfo)

### AccountInfo

[](#accountinfo)

The AccountInfo class has a single method that will return info about the specified user.

#### getAccount($username)

[](#getaccountusername)

Authorization Required: **Yes**

ArgumentsDescriptionRequired`$username`The user name of the account that you wish to get info on.Yes**Returns**This will return an array with the following fields:

FieldTypeDescription`id`IntegerThe producer ID`username`StringThe producer's username.`firstName`StringFirst name`lastName`StringLast name`address`StringThe address`city`StringCity`zip`StringZip Code`phone`IntegerPhone`email`StringEmail`nameForCheck`StringThe name that checks will be made out to.### CartInfo

[](#cartinfo)

Documentation Coming (View Source!)

### EventInfo

[](#eventinfo)

Authorization Required: **No**The EventInfo class provides methods that allow you to obtain event data.

\#####getEvents

ArgumentsDescriptionRequiredDefault`$username`The user name of the account that you wish to get info on. If not given, will return a ALL active BPT events and will probably break.No`null``$eventID`If passed, will only return the information for that eventNo`null``$getDates`Whether or not to also get a list of dates.No`false``getPrices`Whether or not to also get a list of prices.No`false`**Returns**

This method returns an array of event arrays that contain the following fields:

FieldTypeDescription`id`IntegerThe event ID.`title`stringTitle of the Event.`live`booleanWhether or not the event is live.`address1`stringEvent's address 1.`address2`stringEvent's address 2.`city`stringEvent's abbreviated state.`zip`stringEvent's zip/postal code.`shortDescriptionstringEvent's short description.`fullDescriptionstringEvent's full description.`phone`stringEvent's phone number.`web`stringEvent's website.`contactName`stringContact's name.`contactPhone`stringContact's phone.`contactAddress1`stringContact's address 1.`contactAddress2`stringContact's address 2.`contactCity`stringContact's city.`contactState`stringContact's state.`contactCountry`stringContact's country.`contactZip`stringContact's zip/postal code.`contactEmail`stringContact's email### ManageCart

[](#managecart)

Some methods will return a results array with two fields. The first is `success` which is a bolean indicating whether or not it failed and a `message` field explaining why.

#### initCart($cartID = null, $createdAt = null)

[](#initcartcartid--null-createdat--null)

Starts a new cart session with Brown Paper Tickets. You can also pass in an existing `cartID` and the time it was `createdAt`. If the cart has expired it will return a results array with `success` set to `false`.

If successful, it will return a results array with `success` set to `true` as well as a `cartID` and `cartCreatedAt` field.

**Returns**The newly created `cartID`. This cart will expire after 15 minutes.

#### isExpired()

[](#isexpired)

Determines whether or not the `cartID` has expired.

#### getCartId()

[](#getcartid)

**Returns**The `cartID`.

#### setAffiliateID($affiliateID)

[](#setaffiliateidaffiliateid)

Pass your affiliate ID if you want to earn a commission on the sale.

#### setPrices($prices)

[](#setpricesprices)

Set the prices to send to the cart. Will return the set prices. This does not update the actual cart (use `sendPrices()` for that).

This will throw out any prices with an invalid shipping method and will determine whether or not will call names need to be required when adding shipping info.

Pass in an array of prices IDs. Each Price ID value should be set to an array with the following fields:

parametertypedescription`shippingMethod`integerAn integer representing shipping method\*`quantity`integerthe number of tickets you wish to add.`affiliateID`integerOptional. If you wish to earn a commision, add the affiliate ID.- Shipping Methods 1 for Physical, 2 for Will Call, 3 for Print at Home.

```
$prices = array(
    '12345' => array(
        'shippingMethod' => 1,
        'quantity' => 2,
    ),
    '12346' => array(
        'shippingMethod' => 3,
        'quantity' => 3
    )
);
```

Returns an array of the set prices.

#### removePrices($prices)

[](#removepricesprices)

Pass in an array of price IDs and it will remove the price IDs passed from the set prices. This does not update the actual cart (use `sendPrices()` for that).

**Returns**An array of the set prices.

#### sendPrices()

[](#sendprices)

Send the prices to the cart via the API.

Returns the results array.

#### getPrices()

[](#getprices)

Returns the prices set.

#### getValue()

[](#getvalue)

Returns the current value of the cart as it was set when adding prices. Note: When the class sets the value, it will determine whether or not certain fields are required for the billing info. See `setShipping()` for more info.

#### setShipping($shipping)

[](#setshippingshipping)

Pass in an array of shipping information.

fieldnotesfirstNamelastNameaddressaddress2citystatezipcountryValues include "United States" and "Canada".If you have selected tickets that require Will Call names, you can pass in a different name using the `willCallFirstName` and `willCallLastName` fields. Otherwise it will default to using the first and last name fields for will call names.

#### setBilling($billing)

[](#setbillingbilling)

Pass in an array of billing information.

Always pass these fields:

fieldnotesfirstNamelastNameWhen the cart's value is greater than 0, you must also include the following fields. If you do not, then the cart will return the results array with the message ""

fieldnotesaddressaddress2citystatezipemailphonecountryValues include "United States" and "Canada".Returns a results array.

#### sendBilling(Array $ccInfo)

[](#sendbillingarray-ccinfo)

Sends the billing information to the cart.

When the cart's value is greater than 0, you must include the cc info array:

fieldnotestypeCredit card type. Must be "Visa", "Mastercard", "Discover" or "Amex"numberCredit card number. Must be a stringexpMonthExpiration month.expYearExpriration year.cvv2Credit card verification codeOnce this has been called and is successful, you will no longer be able to `sendPrices()`, `sendShipping()` or `sendBilling()`.

Returns a results array with the following fields:

fieldnotessuccessbooleanmessageA description of the resultsticketUrlIf successful and this shipping method was chosen, a link to the print-at-home ticketscartIDthe ID of the cart IDreceiptURLIf successful, a URL to the order's receipt on BPT.#### getReceipt()

[](#getreceipt)

Returns the results received by the `sendBilling()` method.

### SalesInfo

[](#salesinfo)

Documentation Coming (View Source!)

Latest Changes
--------------

[](#latest-changes)

(See [CHANGELOG](CHANGELOG.md) for full set of changes)

v0.15.2
-------

[](#v0152)

- Added .gitattributes to prevent tests and other crap from being downloaded with packagist.
- **Breaking Changes**

    - The ManageCart class no longer saves the credit card info to the object. You must now pass in the credit card info array to `MangeCart::sendBilling` method rather than `ManageCart::setBilling` as was done before.

v0.15.1
-------

[](#v0151)

- Fixed `__construct` logger option

### v0.15.0

[](#v0150)

- Added ability to capture all requests sent to the API and the raw response. Add `'debug' => true` to the `options` arrays upon instantiation or use `setOption('debug', true)`.
- Added `setLogger()` method that accepts a PSR-3 compatible logger (i.e. [Monolog](https://github.com/Seldaek/monolog)). You can also pass it in in the `options` array when instantiating.

### v0.14.2

[](#v0142)

- Fixed issue with the order field in getPrices.

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2015 Brown Paper Tickets

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

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

---

Top Contributors

[![chantron](https://avatars.githubusercontent.com/u/2153342?v=4)](https://github.com/chantron "chantron (28 commits)")

### Embed Badge

![Health badge](/badges/brown-paper-tickets-bpt-api/health.svg)

```
[![Health](https://phpackages.com/badges/brown-paper-tickets-bpt-api/health.svg)](https://phpackages.com/packages/brown-paper-tickets-bpt-api)
```

PHPackages © 2026

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