Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • GatewayPayments

Class GatewayPayments

Processes payments through gateways, records their transactions and sends out email notices when payments are successfully processed all according to the client and company settings for the client and company in question

Package: blesta\components\gateway\payments
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at components/gateway_payments/gateway_payments.php

Methods summary

public
# __construct( )

Initializes the object, loading the dependent components and models

Initializes the object, loading the dependent components and models

public
# setPassphrase( mixed $passphrase )

Sets the passphrase to be used when processing payments on existing accounts. This is the value used to encrypt the private key that is used to decrypt account details.

Sets the passphrase to be used when processing payments on existing accounts. This is the value used to encrypt the private key that is used to decrypt account details.

public array
# getBuildProcess( array $contact_info, float $amount, string $currency, array $invoice_amounts = null, array $options = null, integer $gateway_id = null )

Returns an array of HTML markup used to render capture and pay requests for non-merchant gateways

Returns an array of HTML markup used to render capture and pay requests for non-merchant gateways

Parameters

$contact_info
array
$contact_info An array of contact info including: - id The contact ID - client_id The ID of the client this contact belongs to - user_id The user ID this contact belongs to (if any) - contact_type The type of contact - contact_type_id The ID of the contact type - first_name The first name on the contact - last_name The last name on the contact - title The title of the contact - company The company name of the contact - address1 The address 1 line of the contact - address2 The address 2 line of the contact - city The city of the contact - state An array of state info including: - code The 2 or 3-character state code - name The local name of the country - country An array of country info including: - alpha2 The 2-character country code - alpha3 The 3-cahracter country code - name The english name of the country - alt_name The local name of the country - zip The zip/postal code of the contact
$amount
float
$amount The amount to charge this contact
$currency
string
$currency The current to charge
$invoice_amounts
array
$invoice_amounts An array of invoices, each containing: - id The ID of the invoice being processed - amount The amount being processed for this invoice (which is included in $amount)
$options
array
$options An array of options including: - description The Description of the charge - return_url The URL to redirect users to after a successful payment - recur An array of recurring info including: - start_date The date/time in UTC that the recurring payment begins - amount The amount to recur - term The term to recur - period The recurring period (day, week, month, year, onetime) used in conjunction with term in order to determine the next recurring payment
$gateway_id
integer
$gateway_id The ID of the nonmerchant gateway to fetch, if null will return all nonmerchant gateways for the currency

Returns

array
An array of HTML, indexed by the gateway name
public array
# getBuildAuthorize( array $contact_info, float $amount, string $currency, array $invoice_amounts = null, array $options = null, integer $gateway_id = null )

Returns an array of HTML markup used to render authorization requests for non-merchant gateways

Returns an array of HTML markup used to render authorization requests for non-merchant gateways

Parameters

$contact_info
array
$contact_info An array of contact info including: - id The contact ID - client_id The ID of the client this contact belongs to - user_id The user ID this contact belongs to (if any) - contact_type The type of contact - contact_type_id The ID of the contact type - first_name The first name on the contact - last_name The last name on the contact - title The title of the contact - company The company name of the contact - address1 The address 1 line of the contact - address2 The address 2 line of the contact - city The city of the contact - state An array of state info including: - code The 2 or 3-character state code - name The local name of the country - country An array of country info including: - alpha2 The 2-character country code - alpha3 The 3-cahracter country code - name The english name of the country - alt_name The local name of the country - zip The zip/postal code of the contact
$amount
float
$amount The amount to charge this contact
$currency
string
$currency The current to charge
$invoice_amounts
array
$invoice_amounts An array of invoices, each containing: - id The ID of the invoice being processed - amount The amount being processed for this invoice (which is included in $amount)
$options
array
$options An array of options including: - description The Description of the charge - return_url The URL to redirect users to after a successful payment - recur An array of recurring info including: - start_date The date/time in UTC that the recurring payment begins - amount The amount to recur - term The term to recur - period The recurring period (day, week, month, year, onetime) used in conjunction with term in order to determine the next recurring payment
$gateway_id
integer
$gateway_id The ID of the nonmerchant gateway to fetch, if null will return all nonmerchant gateways for the currency

Returns

array
An array of HTML, indexed by the gateway name
public array
# processReceived( string $gateway_name, array $get, array $post )

Process the payment received request, user redirected back after successful payment.

Process the payment received request, user redirected back after successful payment.

Parameters

$gateway_name
string
$gateway_name The file name of the gateway excluding any extension
$get
array
An array of GET parameters passed into the callback request
$post
array
An array of POST parameters passed into the callback request

Returns

array
An array of transaction data, may set errors using Input if the data appears invalid - client_id The ID of the client that attempted the payment - amount The amount of the payment - currency The currency of the payment - invoices An array of invoices and the amount the payment should be applied to (if any) including: - id The ID of the invoice to apply to - amount The amount to apply to the invoice - status The status of the transaction (approved, declined, void, pending, reconciled, refunded, returned) - transaction_id The ID returned by the gateway to identify this transaction - parent_transaction_id The ID returned by the gateway to identify this transaction's original transaction

See

GatewayPayments::processReceived()
public object
# processNotification( string $gateway_name, array $get, array $post )

Process the notification request from a remote gateway. Records the transaction (if valid), and sends out the necessary emails.

Process the notification request from a remote gateway. Records the transaction (if valid), and sends out the necessary emails.

Parameters

$gateway_name
string
$gateway_name The file name of the gateway excluding any extension
$get
array
An array of GET parameters passed into the callback request
$post
array
An array of POST parameters passed into the callback request

Returns

object
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public object
# processPayment( integer $client_id, string $type, float $amount, string $currency, array $account_info = null, integer $account_id = null, array $options = null )

Processes a payment for the given client of the given type using the supplied details. This method submits payment to the gateway, records the transaction, and sends out any necessary emails

Processes a payment for the given client of the given type using the supplied details. This method submits payment to the gateway, records the transaction, and sends out any necessary emails

Parameters

$client_id
integer
$client_id The ID of the client to submit the payment for
$type
string
$type The type of payment to submit "cc" or "ach"
$amount
float
$amount The amount to process
$currency
string
$currency The ISO 4217 currency code this payment is to be processed under
$account_info
array
$account_info An array of account info if no $account_id used, including: - first_name The first name on the account - last_name The last name on the account - account_number The bank account number (if ach) - routing_number The bank account routing number (if ach) - type The bank account type (checking, savings, business_checking) (if ach) - card_number The credit card number (if cc) - card_exp The card expiration date in yyyymm format (if cc) - card_security_code The card security code (if cc) - address1 The address 1 line of the account holder - address2 The address 2 line of the account holder - city The city of the account holder - state The 2 or 3 character state code - country The 2 or 3 character country code - zip The zip/postal code of the account holder
$account_id
integer
$account_id The account ID to be used to process the payment if no $account_info given
$options
array
$options An array of options including (optional): - invoices An array of key/value pairs where each key represents an invoice ID and each value is the amount to apply to that invoice (optional, may not exceed $amount) - staff_id The ID of the staff member that processed this payment - email_receipt If true (default true), will send an email receipt to the client and BCC appropriate staff members

Returns

object
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public object
# authorizePayment( integer $client_id, string $type, float $amount, string $currency, array $account_info = null, integer $account_id = null, array $options = null )

Authorizes a payment for the given client of the given type using the supplied details. This method submits payment to the gateway and records the transaction

Authorizes a payment for the given client of the given type using the supplied details. This method submits payment to the gateway and records the transaction

Parameters

$client_id
integer
$client_id The ID of the client to authorize the payment for
$type
string
$type The type of payment to submit "cc" or "ach", NOTE: Only "cc" is supported, but this varaible remains for consistency (and possible future support)
$amount
float
$amount The amount to authorize
$currency
string
$currency The ISO 4217 currency code this payment is to be processed under
$account_info
array
$account_info An array of account info if no $account_id used, including: - first_name The first name on the account - last_name The last name on the account - account_number The bank account number (if ach) - routing_number The bank account routing number (if ach) - type The bank account type (checking, savings, business_checking) (if ach) - card_number The credit card number (if cc) - card_exp The card expiration date in yyyymm format (if cc) - card_security_code The card security code (if cc) - address1 The address 1 line of the account holder - address2 The address 2 line of the account holder - city The city of the account holder - state The 2 or 3 character state code - country The 2 or 3 character country code - zip The zip/postal code of the account holder
$account_id
integer
$account_id The account ID to be used to process the payment if no $account_info given
$options
array
$options An array of options including (optional): - invoices An array of key/value pairs where each key represents an invoice ID and each value is the amount to apply to that invoice (optional, may not exceed $amount) - staff_id The ID of the staff member that processed this payment - email_receipt If true (default true), will send an email receipt to the client and BCC appropriate staff members

Returns

object
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public object
# capturePayment( integer $client_id, integer $transaction_id, float $amount = null, array $options = null )

Captures a payment for the given client and transaction in the supplied amount. This method submits payment to the gateway, updates the transaction, and sends out any necessary emails

Captures a payment for the given client and transaction in the supplied amount. This method submits payment to the gateway, updates the transaction, and sends out any necessary emails

Parameters

$client_id
integer
$client_id The ID of the client to capture the payment for
$transaction_id
integer
$transaction_id The ID of the transactiosn to capture
$amount
float
$amount The amount to capture
$options
array
$options An array of options including (optional): - invoices An array of key/value pairs where each key represents an invoice ID and each value is the amount to apply to that invoice (optional, may not exceed $amount) - staff_id The ID of the staff member that processed this payment - email_receipt If true (default true), will send an email receipt to the client and BCC appropriate staff members

Returns

object
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public mixed
# refundPayment( integer $client_id, integer $transaction_id, float $amount = null, array $options = null )

Refunds a payment for the given client and transaction in the supplied amount. This method submits payment to the gateway and updates the transaction

Refunds a payment for the given client and transaction in the supplied amount. This method submits payment to the gateway and updates the transaction

Parameters

$client_id
integer
$client_id The ID of the client to refund the payment for
$transaction_id
integer
$transaction_id The ID of the transactiosn to refund
$amount
float
$amount The amount to refund, defaults to the original transaction amount if not given
$options
array
$options An array of options including (optional): - staff_id The ID of the staff member that processed this payment - notes Any additional notes to include with this transaction

Returns

mixed
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public mixed
# voidPayment( integer $client_id, integer $transaction_id, array $options = null )

Voids a payment for the given client and transaction. This method submits payment to the gateway and updates the transaction

Voids a payment for the given client and transaction. This method submits payment to the gateway and updates the transaction

Parameters

$client_id
integer
$client_id The ID of the client to refund the payment for
$transaction_id
integer
$transaction_id The ID of the transactiosn to refund
$options
float
$amount The amount to refund, defaults to the original transaction amount if not given

Returns

mixed
An object representing the transaction if attempted, void otherwise. Check GatewayPayments::errors(), as some transactions may be attempted and yet still produce errors
public mixed
# storeAccount( string $type, array $vars )

Communicates with the remote gateway to store the account. SHOULD NOT BE USED TO CREATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::addAch() or Accounts::addCc() instead.

Communicates with the remote gateway to store the account. SHOULD NOT BE USED TO CREATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::addAch() or Accounts::addCc() instead.

Parameters

$type
string
$type The type of account ("cc" or "ach")
$vars
array
$vars An array of ACH or CC account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional, defaults to 'US') - account The account number (if ach) - routing The routing number (if ach) - type The type of account, 'checking' or 'savings', (if ach, defaults to 'checking') - card_number The card number (if cc) - expiration The card expiration date in yyyymm format (if cc) - security_code The card security code (if cc)

Returns

mixed
False if the gateway does not support off-site payment accounts or is not enabled for off-site payment accounts, void for all other errors (errors set, use GatewayPayments::errors() to fetch errors), else sets an array containing: - gateway_id The ID of the gateway used to process the request - client_reference_id The reference ID for this client - reference_id The reference ID for this payment account

See

Accounts::addAch()
Accounts::addCc()
public mixed
# updateAccount( string $type, object $account, array $vars )

Communicates with the remote gateway to update the account. SHOULD NOT BE USED TO UPDATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::editAch() or Accounts::editCc() instead.

Communicates with the remote gateway to update the account. SHOULD NOT BE USED TO UPDATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::editAch() or Accounts::editCc() instead.

Parameters

$type
string
$type The type of account ("cc" or "ach")
$account
object
$account The existing account record that is to be updated
$vars
array
$vars An array of ACH or CC account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional, defaults to 'US') - account The account number (if ach) - routing The routing number (if ach) - type The type of account, 'checking' or 'savings', (if ach, defaults to 'checking') - card_number The card number (if cc) - expiration The card expiration date in yyyymm format (if cc) - security_code The card security code (if cc) - account_changed True if the account details (bank account or card number, etc.) have been updated, false otherwise

Returns

mixed
False if the gateway does not support off-site payment accounts or is not enabled for off-site payment accounts, void for all other errors (errors set, use GatewayPayments::errors() to fetch errors), else sets an array containing: - gateway_id The ID of the gateway used to process the request - client_reference_id The reference ID for this client - reference_id The reference ID for this payment account

See

Accounts::editAch()
Accounts::editCc()
public mixed
# removeAccount( string $type, object $account )

Communicates with the remote gateway to update the account. SHOULD NOT BE USED TO UPDATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::deleteAch() or Accounts::deleteCc() instead.

Communicates with the remote gateway to update the account. SHOULD NOT BE USED TO UPDATE PAYMENT ACCOUNTS IN THE SYSTEM. See Accounts::deleteAch() or Accounts::deleteCc() instead.

Parameters

$type
string
$type The type of account ("cc" or "ach")
$account
object
$account The existing account record that is to be updated

Returns

mixed
False if the gateway does not support off-site payment accounts or is not enabled for off-site payment accounts, void for all other errors (errors set, use GatewayPayments::errors() to fetch errors), else sets an array containing: - gateway_id The ID of the gateway used to process the request - client_reference_id The reference ID for this client - reference_id The reference ID for this payment account

See

Accounts::deleteAch()
Accounts::deleteCc()
public
# errors( )

Returns errors set in this object's Input object

Returns errors set in this object's Input object

public boolean
# implementsGateway( string $type, object $gateway_obj, boolean $off_site )

Returns whether or not the supplied gateway object implements the correct gateway interface based on its type and off site capabilities

Returns whether or not the supplied gateway object implements the correct gateway interface based on its type and off site capabilities

Parameters

$type
string
$type The type of merchant gateway (cc or ach)
$gateway_obj
object
The gateway object
$off_site
boolean
$off_site True if attempting to verify support for off site payments, false otherwise

Returns

boolean
True if the gateway object supports the appropriate interface, false otherwise

Magic methods summary

Blesta API documentation generated by ApiGen 2.8.0