Blesta Source Documentation

Payments extends AppModel

Processes payments through remote gateways and records the transactions.

Supports non-merchant gateways by returning markup used to render those payment buttons.

Table of Contents

Methods

__construct() Initialize Payments
authorizePayment() Authorizes a payment for the given client of the given type using the supplied details.
capturePayment() Captures a payment for the given client and transaction in the supplied amount.
errors() Returns errors set in this object's Input object
getBuildAchForm() Returns HTML markup used to render a custom ach form for a merchant gateway
getBuildAchVerificationForm() Returns HTML markup used to render a custom verification ach form for a merchant gateway
getBuildAuthorize() Returns an array of HTML markup used to render authorization requests for non-merchant gateways
getBuildCcForm() Returns HTML markup used to render a custom credit card form for a merchant gateway
getBuildPaymentConfirmation() Gets an Html form from the merchant gateway to use as an addition to the regular payment confirmation pages in Blesta
getBuildProcess() Returns an array of HTML markup used to render capture and pay requests for non-merchant gateways
processPayment() Processes a payment for the given client of the given type using the supplied details.
refundPayment() Refunds a payment for the given client and transaction in the supplied amount.
voidPayment() Voids a payment for the given client and transaction.
Methods

__construct()

Initialize Payments

public __construct() : mixed

authorizePayment()

Authorizes a payment for the given client of the given type using the supplied details.

public authorizePayment(int $client_id, string $type, float $amount, string $currency[, array<string|int, mixed> $account_info = null ][, int $account_id = null ][, array<string|int, mixed> $options = null ]) : object

This method submits payment to the gateway and records the transaction

Parameters
$client_id : int

The ID of the client to authorize the payment for

$type : string

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

The amount to authorize

$currency : string

The ISO 4217 currency code this payment is to be processed under

$account_info : array<string|int, mixed> = null

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 : int = null

The account ID to be used to process the payment if no $account_info given

$options : array<string|int, mixed> = null

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
  • passphrase The value used to encrypt the private key that is used to decrypt account details
Return values
object

An object representing the transaction if attempted, void otherwise. Check Payments::errors(), as some transactions may be attempted and yet still produce errors

capturePayment()

Captures a payment for the given client and transaction in the supplied amount.

public capturePayment(int $client_id, int $transaction_id[, float $amount = null ][, array<string|int, mixed> $options = null ]) : object

This method submits payment to the gateway, updates the transaction, and sends out any necessary emails

Parameters
$client_id : int

The ID of the client to capture the payment for

$transaction_id : int

The ID of the transactiosn to capture

$amount : float = null

The amount to capture

$options : array<string|int, mixed> = null

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
Return values
object

An object representing the transaction if attempted, void otherwise. Check Payments::errors(), as some transactions may be attempted and yet still produce errors

errors()

Returns errors set in this object's Input object

public errors() : mixed

getBuildAchForm()

Returns HTML markup used to render a custom ach form for a merchant gateway

public getBuildAchForm(string $currency[, array<string|int, mixed> $account_info = null ][, int $client_id = null ][, int $client_group_id = null ][, bool $staff_id = null ][, int $gateway_id = null ]) : string
Parameters
$currency : string

The currency the payment is in

$account_info : array<string|int, mixed> = null

An array of bank account info

$client_id : int = null

The ID of the client to fetch only the gateway available for this client

$client_group_id : int = null

The ID of the client group to fetch only the gateway available for this client group

$staff_id : bool = null

The ID of the staff member for which to fetch this form

$gateway_id : int = null

The gateway ID to verify is installed and active for the given currency

Return values
string

Custom ACH form HTML from the merchant

getBuildAchVerificationForm()

Returns HTML markup used to render a custom verification ach form for a merchant gateway

public getBuildAchVerificationForm(string $currency[, array<string|int, mixed> $vars = null ][, int $client_id = null ][, int $client_group_id = null ][, int $gateway_id = null ]) : string
Parameters
$currency : string

The currency the payment is in

$vars : array<string|int, mixed> = null

An array of bank account info used for verification purposes

$client_id : int = null

The ID of the client to fetch only the gateway available for this client

$client_group_id : int = null

The ID of the client group to fetch only the gateway available for this client group

$gateway_id : int = null

The gateway ID to verify is installed and active for the given currency

Return values
string

Custom ACH form HTML from the merchant

getBuildAuthorize()

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

public getBuildAuthorize(array<string|int, mixed> $contact_info, float $amount, string $currency[, array<string|int, mixed> $invoice_amounts = null ][, array<string|int, mixed> $options = null ][, int $gateway_id = null ]) : array<string|int, mixed>
Parameters
$contact_info : array<string|int, mixed>

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

The amount to charge this contact

$currency : string

The current to charge

$invoice_amounts : array<string|int, mixed> = null

An array of key/value pairs where each key represents an invoice ID and each value is the amount to apply to that invoice

$options : array<string|int, mixed> = null

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 : int = null

The ID of the nonmerchant gateway to fetch, if null will return all nonmerchant gateways for the currency

Return values
array<string|int, mixed>

An array of HTML, indexed by the gateway name

getBuildCcForm()

Returns HTML markup used to render a custom credit card form for a merchant gateway

public getBuildCcForm(string $currency[, int $client_id = null ][, int $client_group_id = null ][, bool $staff_id = null ][, int $gateway_id = null ]) : string
Parameters
$currency : string

The currency the payment is in

$client_id : int = null

The ID of the client to fetch only the gateway available for this client

$client_group_id : int = null

The ID of the client group to fetch only the gateway available for this client group

$staff_id : bool = null

The ID of the staff member for which to fetch this form

$gateway_id : int = null

The gateway ID to verify is installed and active for the given currency

Return values
string

Custom CC form HTML from the merchant

getBuildPaymentConfirmation()

Gets an Html form from the merchant gateway to use as an addition to the regular payment confirmation pages in Blesta

public getBuildPaymentConfirmation(int $client_id, int $transaction_id) : string
Parameters
$client_id : int

The ID of the client that payment confirmation is being viewed for

$transaction_id : int

The ID of the transaction being confirmed

Return values
string

The Html, if any, provided by the merchant gateway for confirming payments

getBuildProcess()

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

public getBuildProcess(array<string|int, mixed> $contact_info, float $amount, string $currency[, array<string|int, mixed> $invoice_amounts = null ][, array<string|int, mixed> $options = null ][, int $gateway_id = null ]) : array<string|int, mixed>
Parameters
$contact_info : array<string|int, mixed>

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

The amount to charge this contact

$currency : string

The current to charge

$invoice_amounts : array<string|int, mixed> = null

An array of key/value pairs where each key represents an invoice ID and each value is the amount to apply to that invoice

$options : array<string|int, mixed> = null

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 : int = null

The ID of the nonmerchant gateway to fetch, if null will return all nonmerchant gateways for the currency

Return values
array<string|int, mixed>

An array of HTML, indexed by the gateway name

processPayment()

Processes a payment for the given client of the given type using the supplied details.

public processPayment(int $client_id, string $type, float $amount, string $currency[, array<string|int, mixed> $account_info = null ][, int $account_id = null ][, array<string|int, mixed> $options = null ]) : object

This method submits payment to the gateway, records the transaction, and sends out any necessary emails

Parameters
$client_id : int

The ID of the client to submit the payment for

$type : string

The type of payment to submit "cc" or "ach"

$amount : float

The amount to process

$currency : string

The ISO 4217 currency code this payment is to be processed under

$account_info : array<string|int, mixed> = null

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 : int = null

The account ID to be used to process the payment if no $account_info given

$options : array<string|int, mixed> = null

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
  • passphrase The value used to encrypt the private key that is used to decrypt account details
Return values
object

An object representing the transaction if attempted, void otherwise. Check Payments::errors(), as some transactions may be attempted and yet still produce errors

refundPayment()

Refunds a payment for the given client and transaction in the supplied amount.

public refundPayment(int $client_id, int $transaction_id[, float $amount = null ][, array<string|int, mixed> $options = null ]) : mixed

This method submits payment to the gateway and updates the transaction

Parameters
$client_id : int

The ID of the client to refund the payment for

$transaction_id : int

The ID of the transactiosn to refund

$amount : float = null

The amount to refund, defaults to the original transaction amount if not given

$options : array<string|int, mixed> = null

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
Return values
mixed

An object representing the transaction if attempted, void otherwise. Check Payments::errors(), as some transactions may be attempted and yet still produce errors

voidPayment()

Voids a payment for the given client and transaction.

public voidPayment(int $client_id, int $transaction_id[, array<string|int, mixed> $options = null ]) : mixed

This method submits payment to the gateway and updates the transaction

Parameters
$client_id : int

The ID of the client to refund the payment for

$transaction_id : int

The ID of the transactiosn to refund

$options : array<string|int, mixed> = null

An array of options including (optional):

  • staff_id The ID of the staff member that processed this payment
Return values
mixed

An object representing the transaction if attempted, void otherwise. Check Payments::errors(), as some transactions may be attempted and yet still produce errors

Tags
subpackage

app.models

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results