PHP Class Omnipay\Common\CreditCard

This class defines and abstracts all of the credit card types used throughout the Omnipay system.
Exibir arquivo Open project: omnipay/common Class Usage Examples

Protected Properties

Property Type Description
$parameters Symfony\Component\HttpFoundation\ParameterBag Internal storage of all of the card parameters.
$supported_cards

Public Methods

Method Description
__construct ( array $parameters = null ) Create a new CreditCard object using the specified parameters
addSupportedBrand ( string $name, string $expression ) : boolean Set a custom supported card brand with a regular expression to match it.
getAddress1 ( ) : string Get the billing address, line 1.
getAddress2 ( ) : string Get the billing address, line 2.
getBillingAddress1 ( ) : string Get the billing address, line 1.
getBillingAddress2 ( ) : string Get the billing address, line 2.
getBillingCity ( ) : string Get the billing city.
getBillingCompany ( ) : string Get the billing company name.
getBillingCountry ( ) : string Get the billing country name.
getBillingFax ( ) : string Get the billing fax number.
getBillingFirstName ( ) : string Get the first part of the card billing name.
getBillingLastName ( ) : string Get the last part of the card billing name.
getBillingName ( ) : string Get the card billing name.
getBillingPhone ( ) : string Get the billing phone number.
getBillingPhoneExtension ( ) : string Get the billing phone number extension.
getBillingPostcode ( ) : string Get the billing postcode.
getBillingState ( ) : string Get the billing state.
getBillingTitle ( ) : string Get the card billing title.
getBirthday ( $format = 'Y-m-d' ) : string Get the cardholder's birthday.
getBrand ( ) : string Credit Card Brand
getCity ( ) : string Get the billing city.
getCompany ( ) : string Get the card billing company name.
getCountry ( ) : string Get the billing country.
getCvv ( ) : string Get the card CVV.
getEmail ( ) : string Get the cardholder's email address.
getExpiryDate ( string $format ) : string Get the card expiry date, using the specified date format string.
getExpiryMonth ( ) : integer Get the card expiry month.
getExpiryYear ( ) : integer Get the card expiry year.
getFax ( ) : string Get the billing fax number.
getFirstName ( ) : string Get Card First Name.
getGender ( ) : string Get the cardholder's gender.
getIssueNumber ( ) : string Get the card issue number.
getLastName ( ) : string Get Card Last Name.
getName ( ) : string Get Card Name.
getNumber ( ) : string Get Card Number.
getNumberLastFour ( ) : string Get the last 4 digits of the card number.
getNumberMasked ( string $mask = 'X' ) : string Returns a masked credit card number with only the last 4 chars visible
getParameters ( ) : array Get all parameters.
getPhone ( ) : string Get the billing phone number.
getPhoneExtension ( ) : string Get the billing phone number extension.
getPostcode ( ) : string Get the billing postcode.
getShippingAddress1 ( ) : string Get the shipping address, line 1.
getShippingAddress2 ( ) : string Get the shipping address, line 2.
getShippingCity ( ) : string Get the shipping city.
getShippingCompany ( ) : string Get the shipping company name.
getShippingCountry ( ) : string Get the shipping country.
getShippingFax ( ) : string Get the shipping fax number.
getShippingFirstName ( ) : string Get the first part of the card shipping name.
getShippingLastName ( ) : string Get the last part of the card shipping name.
getShippingName ( ) : string Get the card shipping name.
getShippingPhone ( ) : string Get the shipping phone number.
getShippingPhoneExtension ( ) : string Get the shipping phone number extension.
getShippingPostcode ( ) : string Get the shipping postcode.
getShippingState ( ) : string Get the shipping state.
getShippingTitle ( ) : string Get the title of the card shipping name.
getStartDate ( string $format ) : string Get the card start date, using the specified date format string
getStartMonth ( ) : string Get the card start month.
getStartYear ( ) : integer Get the card start year.
getState ( ) : string Get the billing state.
getSupportedBrands ( ) : array All known/supported card brands, and a regular expression to match them.
getTitle ( ) : string Get Card Title.
getTrack1 ( ) : string Get raw data for track 1 on the credit card magnetic strip.
getTrack2 ( ) : string Get raw data for track 2 on the credit card magnetic strip.
getTracks ( ) : string Get raw data for all tracks on the credit card magnetic strip.
initialize ( array $parameters = null ) : CreditCard Initialize the object with parameters.
setAddress1 ( string $value ) : CreditCard Sets the billing and shipping address, line 1.
setAddress2 ( string $value ) : CreditCard Sets the billing and shipping address, line 2.
setBillingAddress1 ( string $value ) : CreditCard Sets the billing address, line 1.
setBillingAddress2 ( string $value ) : CreditCard Sets the billing address, line 2.
setBillingCity ( string $value ) : CreditCard Sets billing city.
setBillingCompany ( string $value ) : CreditCard Sets the billing company name.
setBillingCountry ( string $value ) : CreditCard Sets the billing country name.
setBillingFax ( string $value ) : CreditCard Sets the billing fax number.
setBillingFirstName ( string $value ) : CreditCard Sets the first part of the card billing name.
setBillingLastName ( string $value ) : CreditCard Sets the last part of the card billing name.
setBillingName ( string $value ) : CreditCard Sets the card billing name.
setBillingPhone ( string $value ) : CreditCard Sets the billing phone number.
setBillingPhoneExtension ( string $value ) : CreditCard Sets the billing phone number extension.
setBillingPostcode ( string $value ) : CreditCard Sets the billing postcode.
setBillingState ( string $value ) : CreditCard Sets the billing state.
setBillingTitle ( string $value ) : CreditCard Sets the card billing title.
setBirthday ( string $value ) : CreditCard Sets the cardholder's birthday.
setCity ( string $value ) : CreditCard Sets the billing and shipping city.
setCompany ( string $value ) : CreditCard Sets the billing and shipping company name.
setCountry ( string $value ) : CreditCard Sets the billing and shipping country.
setCvv ( string $value ) : CreditCard Sets the card CVV.
setEmail ( string $value ) : CreditCard Sets the cardholder's email address.
setExpiryMonth ( string $value ) : CreditCard Sets the card expiry month.
setExpiryYear ( string $value ) : CreditCard Sets the card expiry year.
setFax ( string $value ) : CreditCard Sets the billing and shipping fax number.
setFirstName ( string $value ) : CreditCard Set Card First Name (Billing and Shipping).
setGender ( string $value ) : CreditCard Sets the cardholder's gender.
setIssueNumber ( string $value ) : CreditCard Sets the card issue number.
setLastName ( string $value ) : CreditCard Set Card Last Name (Billing and Shipping).
setName ( string $value ) : CreditCard Set Card Name (Billing and Shipping).
setNumber ( string $value ) : CreditCard Set Card Number
setPhone ( string $value ) : CreditCard Sets the billing and shipping phone number.
setPhoneExtension ( string $value ) : CreditCard Sets the billing and shipping phone number extension.
setPostcode ( string $value ) : CreditCard Sets the billing and shipping postcode.
setShippingAddress1 ( string $value ) : CreditCard Sets the shipping address, line 1.
setShippingAddress2 ( string $value ) : CreditCard Sets the shipping address, line 2.
setShippingCity ( string $value ) : CreditCard Sets the shipping city.
setShippingCompany ( string $value ) : CreditCard Sets the shipping company name.
setShippingCountry ( string $value ) : CreditCard Sets the shipping country.
setShippingFax ( string $value ) : CreditCard Sets the shipping fax number.
setShippingFirstName ( string $value ) : CreditCard Sets the first part of the card shipping name.
setShippingLastName ( string $value ) : CreditCard Sets the last part of the card shipping name.
setShippingName ( string $value ) : CreditCard Sets the card shipping name.
setShippingPhone ( string $value ) : CreditCard Sets the shipping phone number.
setShippingPhoneExtension ( string $value ) : CreditCard Sets the shipping phone number extension.
setShippingPostcode ( string $value ) : CreditCard Sets the shipping postcode.
setShippingState ( string $value ) : CreditCard Sets the shipping state.
setShippingTitle ( string $value ) : CreditCard Sets the title of the card shipping name.
setStartMonth ( string $value ) : CreditCard Sets the card start month.
setStartYear ( string $value ) : CreditCard Sets the card start year.
setState ( string $value ) : CreditCard Sets the billing and shipping state.
setTitle ( string $value ) : CreditCard Set Card Title.
setTracks ( $value ) : CreditCard Sets raw data from all tracks on the credit card magnetic strip. Used by gateways that support card-present transactions.
validate ( ) : void Validate this credit card. If the card is invalid, InvalidCreditCardException is thrown.

Protected Methods

Method Description
getParameter ( $key ) : mixed Get one parameter.
setParameter ( string $key, mixed $value ) : CreditCard Set one parameter.
setYearParameter ( string $key, mixed $value ) : CreditCard Set the credit card year.

Method Details

__construct() public method

Create a new CreditCard object using the specified parameters
public __construct ( array $parameters = null )
$parameters array An array of parameters to set on the new object

addSupportedBrand() public method

Note: The fact that a particular card is known does not imply that your gateway supports it. Set $add_to_front to true if the key should be added to the front of the array
public addSupportedBrand ( string $name, string $expression ) : boolean
$name string The name of the new supported brand.
$expression string The regular expression to check if a card is supported.
return boolean success

getAddress1() public method

Get the billing address, line 1.
public getAddress1 ( ) : string
return string

getAddress2() public method

Get the billing address, line 2.
public getAddress2 ( ) : string
return string

getBillingAddress1() public method

Get the billing address, line 1.
public getBillingAddress1 ( ) : string
return string

getBillingAddress2() public method

Get the billing address, line 2.
public getBillingAddress2 ( ) : string
return string

getBillingCity() public method

Get the billing city.
public getBillingCity ( ) : string
return string

getBillingCompany() public method

Get the billing company name.
public getBillingCompany ( ) : string
return string

getBillingCountry() public method

Get the billing country name.
public getBillingCountry ( ) : string
return string

getBillingFax() public method

Get the billing fax number.
public getBillingFax ( ) : string
return string

getBillingFirstName() public method

Get the first part of the card billing name.
public getBillingFirstName ( ) : string
return string

getBillingLastName() public method

Get the last part of the card billing name.
public getBillingLastName ( ) : string
return string

getBillingName() public method

Get the card billing name.
public getBillingName ( ) : string
return string

getBillingPhone() public method

Get the billing phone number.
public getBillingPhone ( ) : string
return string

getBillingPhoneExtension() public method

Get the billing phone number extension.
public getBillingPhoneExtension ( ) : string
return string

getBillingPostcode() public method

Get the billing postcode.
public getBillingPostcode ( ) : string
return string

getBillingState() public method

Get the billing state.
public getBillingState ( ) : string
return string

getBillingTitle() public method

Get the card billing title.
public getBillingTitle ( ) : string
return string

getBirthday() public method

Get the cardholder's birthday.
public getBirthday ( $format = 'Y-m-d' ) : string
return string

getBrand() public method

Iterates through known/supported card brands to determine the brand of this card
public getBrand ( ) : string
return string

getCity() public method

Get the billing city.
public getCity ( ) : string
return string

getCompany() public method

Get the card billing company name.
public getCompany ( ) : string
return string

getCountry() public method

Get the billing country.
public getCountry ( ) : string
return string

getCvv() public method

Get the card CVV.
public getCvv ( ) : string
return string

getEmail() public method

Get the cardholder's email address.
public getEmail ( ) : string
return string

getExpiryDate() public method

Get the card expiry date, using the specified date format string.
public getExpiryDate ( string $format ) : string
$format string
return string

getExpiryMonth() public method

Get the card expiry month.
public getExpiryMonth ( ) : integer
return integer

getExpiryYear() public method

Get the card expiry year.
public getExpiryYear ( ) : integer
return integer

getFax() public method

.
public getFax ( ) : string
return string

getFirstName() public method

Get Card First Name.
public getFirstName ( ) : string
return string

getGender() public method

Get the cardholder's gender.
public getGender ( ) : string
return string

getIssueNumber() public method

Get the card issue number.
public getIssueNumber ( ) : string
return string

getLastName() public method

Get Card Last Name.
public getLastName ( ) : string
return string

getName() public method

Get Card Name.
public getName ( ) : string
return string

getNumber() public method

Get Card Number.
public getNumber ( ) : string
return string

getNumberLastFour() public method

Get the last 4 digits of the card number.
public getNumberLastFour ( ) : string
return string

getNumberMasked() public method

Returns a masked credit card number with only the last 4 chars visible
public getNumberMasked ( string $mask = 'X' ) : string
$mask string Character to use in place of numbers
return string

getParameter() protected method

Get one parameter.
protected getParameter ( $key ) : mixed
return mixed A single parameter value.

getParameters() public method

Get all parameters.
public getParameters ( ) : array
return array An associative array of parameters.

getPhone() public method

Get the billing phone number.
public getPhone ( ) : string
return string

getPhoneExtension() public method

Get the billing phone number extension.
public getPhoneExtension ( ) : string
return string

getPostcode() public method

Get the billing postcode.
public getPostcode ( ) : string
return string

getShippingAddress1() public method

Get the shipping address, line 1.
public getShippingAddress1 ( ) : string
return string

getShippingAddress2() public method

Get the shipping address, line 2.
public getShippingAddress2 ( ) : string
return string

getShippingCity() public method

Get the shipping city.
public getShippingCity ( ) : string
return string

getShippingCompany() public method

Get the shipping company name.
public getShippingCompany ( ) : string
return string

getShippingCountry() public method

Get the shipping country.
public getShippingCountry ( ) : string
return string

getShippingFax() public method

Get the shipping fax number.
public getShippingFax ( ) : string
return string

getShippingFirstName() public method

Get the first part of the card shipping name.
public getShippingFirstName ( ) : string
return string

getShippingLastName() public method

Get the last part of the card shipping name.
public getShippingLastName ( ) : string
return string

getShippingName() public method

Get the card shipping name.
public getShippingName ( ) : string
return string

getShippingPhone() public method

Get the shipping phone number.
public getShippingPhone ( ) : string
return string

getShippingPhoneExtension() public method

Get the shipping phone number extension.

getShippingPostcode() public method

Get the shipping postcode.
public getShippingPostcode ( ) : string
return string

getShippingState() public method

Get the shipping state.
public getShippingState ( ) : string
return string

getShippingTitle() public method

Get the title of the card shipping name.
public getShippingTitle ( ) : string
return string

getStartDate() public method

Get the card start date, using the specified date format string
public getStartDate ( string $format ) : string
$format string
return string

getStartMonth() public method

Get the card start month.
public getStartMonth ( ) : string
return string

getStartYear() public method

Get the card start year.
public getStartYear ( ) : integer
return integer

getState() public method

Get the billing state.
public getState ( ) : string
return string

getSupportedBrands() public method

Note: The fact that this class knows about a particular card brand does not imply that your gateway supports it.
See also: self::$supported_cards
public getSupportedBrands ( ) : array
return array

getTitle() public method

Get Card Title.
public getTitle ( ) : string
return string

getTrack1() public method

Get raw data for track 1 on the credit card magnetic strip.
public getTrack1 ( ) : string
return string

getTrack2() public method

Get raw data for track 2 on the credit card magnetic strip.
public getTrack2 ( ) : string
return string

getTracks() public method

Get raw data for all tracks on the credit card magnetic strip.
public getTracks ( ) : string
return string

initialize() public method

If any unknown parameters passed, they will be ignored.
public initialize ( array $parameters = null ) : CreditCard
$parameters array An associative array of parameters
return CreditCard provides a fluent interface.

setAddress1() public method

Sets the billing and shipping address, line 1.
public setAddress1 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setAddress2() public method

Sets the billing and shipping address, line 2.
public setAddress2 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingAddress1() public method

Sets the billing address, line 1.
public setBillingAddress1 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingAddress2() public method

Sets the billing address, line 2.
public setBillingAddress2 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingCity() public method

Sets billing city.
public setBillingCity ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingCompany() public method

Sets the billing company name.
public setBillingCompany ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingCountry() public method

Sets the billing country name.
public setBillingCountry ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingFax() public method

Sets the billing fax number.
public setBillingFax ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingFirstName() public method

Sets the first part of the card billing name.
public setBillingFirstName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingLastName() public method

Sets the last part of the card billing name.
public setBillingLastName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingName() public method

Sets the card billing name.
public setBillingName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingPhone() public method

Sets the billing phone number.
public setBillingPhone ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingPhoneExtension() public method

Sets the billing phone number extension.
public setBillingPhoneExtension ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingPostcode() public method

Sets the billing postcode.
public setBillingPostcode ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingState() public method

Sets the billing state.
public setBillingState ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBillingTitle() public method

Sets the card billing title.
public setBillingTitle ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setBirthday() public method

Sets the cardholder's birthday.
public setBirthday ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setCity() public method

Sets the billing and shipping city.
public setCity ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setCompany() public method

Sets the billing and shipping company name.
public setCompany ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setCountry() public method

Sets the billing and shipping country.
public setCountry ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setCvv() public method

Sets the card CVV.
public setCvv ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setEmail() public method

Sets the cardholder's email address.
public setEmail ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setExpiryMonth() public method

Sets the card expiry month.
public setExpiryMonth ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setExpiryYear() public method

Sets the card expiry year.
public setExpiryYear ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setFax() public method

Sets the billing and shipping fax number.
public setFax ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setFirstName() public method

Set Card First Name (Billing and Shipping).
public setFirstName ( string $value ) : CreditCard
$value string Parameter value
return CreditCard provides a fluent interface.

setGender() public method

Sets the cardholder's gender.
public setGender ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setIssueNumber() public method

Sets the card issue number.
public setIssueNumber ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setLastName() public method

Set Card Last Name (Billing and Shipping).
public setLastName ( string $value ) : CreditCard
$value string Parameter value
return CreditCard provides a fluent interface.

setName() public method

Set Card Name (Billing and Shipping).
public setName ( string $value ) : CreditCard
$value string Parameter value
return CreditCard provides a fluent interface.

setNumber() public method

Non-numeric characters are stripped out of the card number, so it's safe to pass in strings such as "4444-3333 2222 1111" etc.
public setNumber ( string $value ) : CreditCard
$value string Parameter value
return CreditCard provides a fluent interface.

setParameter() protected method

Set one parameter.
protected setParameter ( string $key, mixed $value ) : CreditCard
$key string Parameter key
$value mixed Parameter value
return CreditCard provides a fluent interface.

setPhone() public method

Sets the billing and shipping phone number.
public setPhone ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setPhoneExtension() public method

Sets the billing and shipping phone number extension.
public setPhoneExtension ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setPostcode() public method

Sets the billing and shipping postcode.
public setPostcode ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingAddress1() public method

Sets the shipping address, line 1.
public setShippingAddress1 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingAddress2() public method

Sets the shipping address, line 2.
public setShippingAddress2 ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingCity() public method

Sets the shipping city.
public setShippingCity ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingCompany() public method

Sets the shipping company name.
public setShippingCompany ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingCountry() public method

Sets the shipping country.
public setShippingCountry ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingFax() public method

Sets the shipping fax number.
public setShippingFax ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingFirstName() public method

Sets the first part of the card shipping name.
public setShippingFirstName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingLastName() public method

Sets the last part of the card shipping name.
public setShippingLastName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingName() public method

Sets the card shipping name.
public setShippingName ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingPhone() public method

Sets the shipping phone number.
public setShippingPhone ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingPhoneExtension() public method

Sets the shipping phone number extension.
public setShippingPhoneExtension ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingPostcode() public method

Sets the shipping postcode.
public setShippingPostcode ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingState() public method

Sets the shipping state.
public setShippingState ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setShippingTitle() public method

Sets the title of the card shipping name.
public setShippingTitle ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setStartMonth() public method

Sets the card start month.
public setStartMonth ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setStartYear() public method

Sets the card start year.
public setStartYear ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setState() public method

Sets the billing and shipping state.
public setState ( string $value ) : CreditCard
$value string
return CreditCard provides a fluent interface.

setTitle() public method

Set Card Title.
public setTitle ( string $value ) : CreditCard
$value string Parameter value
return CreditCard provides a fluent interface.

setTracks() public method

Sets raw data from all tracks on the credit card magnetic strip. Used by gateways that support card-present transactions.
public setTracks ( $value ) : CreditCard
$value
return CreditCard

setYearParameter() protected method

The input value is normalised to a 4 digit number.
protected setYearParameter ( string $key, mixed $value ) : CreditCard
$key string Parameter key, e.g. 'expiryYear'
$value mixed Parameter value
return CreditCard provides a fluent interface.

validate() public method

This method is called internally by gateways to avoid wasting time with an API call when the credit card is clearly invalid. Generally if you want to validate the credit card yourself with custom error messages, you should use your framework's validation library, not this method.
public validate ( ) : void
return void

Property Details

$parameters protected_oe property

Internal storage of all of the card parameters.
protected ParameterBag,Symfony\Component\HttpFoundation $parameters
return Symfony\Component\HttpFoundation\ParameterBag

$supported_cards protected_oe property

protected $supported_cards