PaymentProcessing
in package
Payment Service Provider manager
These are the requirements of the current specification for any external payment service provider class:
- Any payment method MUST be implemented in its own class, with its constructor and/or methods being called from PaymentProcessing.class.php using only the two methods checkIn() and checkOut().
- Any data needed by the payment service class MUST be provided as arguments to the constructor and/or methods from within the PaymentProcessing class.
- Any code in checkOut() MUST return either a valid payment form OR redirect to a payment page of that provider, supplying all necessary data for a successful payment.
- Any code in checkIn() MUST return the original order ID of the order being processed on success, false otherwise (both in the case of failure and upon cancelling the payment).
- A payment provider class MUST NOT access the database itself, in particular it is strictly forbidden to read or change the order status of any order.
- A payment provider class MUST NOT store any data in the global session array. Instead, it is to rely on the protocol of the payment service provider to transmit and retrieve all necessary data.
- Any payment method providing different return values for different
outcomes of the payment in the consecutive HTTP requests SHOULD use
the follwing arguments and values:
Successful payments: result=1
Successful payments, silent *: result=-1
Failed payments: result=0
Aborted payments: result=2
Aborted payments, silent *: result=-2
- Some payment services do not only redirect the customer after a successful payment has completed, but already after the payment has been authorized. Yellowpay, as an example, expects an empty page as a reply to such a request. Other PSP send the notification even for failed or cancelled transactions, e.g. Datatrans. Consult your local PSP for further information.
Tags
Table of Contents
Properties
- $arrPaymentProcessor : array<string|int, mixed>
- Array of all available payment processors
- $processorId : int
- The selected processor ID
Methods
- _getPictureCode() : string
- Returns HTML code for showing the logo associated with this payment processor, if any, or an empty string otherwise.
- _PayrexxProcessor() : string
- Returns the HTML code for the Payrexx payment method.
- _SaferpayJsonProcessor() : string
- Returns the HTML code for the Saferpay payment form.
- _SaferpayProcessor() : string
- Returns the HTML code for the Saferpay payment form.
- _YellowpayProcessor() : string
- Returns the HTML code for the Yellowpay payment method.
- checkIn() : mixed
- Check in the payment processor after the payment is complete.
- checkOut() : string
- Check out the payment processor associated with the payment processor selected by {@link initProcessor()}.
- errorHandler() : bool
- Handles all kinds of database errors
- getCurrentPaymentProcessorType() : string
- Returns the processor type associated with a payment processor ID.
- getDatatransForm() : string
- Returns the complete HTML code for the Datatrans payment form
- getMenuoptions() : mixed
- getOrderId() : mixed
- getPaymentProcessorName() : string
- Returns the name associated with a payment processor ID.
- getPaymentProcessorNameArray() : array<string|int, mixed>
- Returns an array with all the payment processor names indexed by their ID.
- getPaymentProcessorPicture() : string
- Returns the picture file name associated with a payment processor ID.
- init() : mixed
- Initialize known payment service providers
- initProcessor() : void
- Set the active processor ID
Properties
$arrPaymentProcessor
Array of all available payment processors
protected
static array<string|int, mixed>
$arrPaymentProcessor
= array()
Tags
$processorId
The selected processor ID
private
static int
$processorId
= false
Tags
Methods
_getPictureCode()
Returns HTML code for showing the logo associated with this payment processor, if any, or an empty string otherwise.
public
static _getPictureCode() : string
Tags
Return values
string —HTML code, or the empty string
_PayrexxProcessor()
Returns the HTML code for the Payrexx payment method.
public
static _PayrexxProcessor() : string
Return values
string —HTML code
_SaferpayJsonProcessor()
Returns the HTML code for the Saferpay payment form.
public
static _SaferpayJsonProcessor() : string
Tags
Return values
string —The HTML code
_SaferpayProcessor()
Returns the HTML code for the Saferpay payment form.
public
static _SaferpayProcessor() : string
Tags
Return values
string —The HTML code
_YellowpayProcessor()
Returns the HTML code for the Yellowpay payment method.
public
static _YellowpayProcessor() : string
Return values
string —HTML code
checkIn()
Check in the payment processor after the payment is complete.
public
static checkIn() : mixed
Return values
mixed —For external payment methods: The integer order ID, if known, upon success For internal payment methods: Boolean true, in order to make these skip the order status update, as this has already been done. If the order ID is unknown or upon failure: Boolean false
checkOut()
Check out the payment processor associated with the payment processor selected by {@link initProcessor()}.
public
static checkOut() : string
If the page is redirected, or has already been handled, returns the empty string. In the other cases, returns HTML code for the payment form and to insert a picture representing the payment method.
Tags
Return values
string —Empty string, or HTML code
errorHandler()
Handles all kinds of database errors
public
static errorHandler() : bool
Creates the processors' table, and creates default entries if necessary
Tags
Return values
bool —False. Always.
getCurrentPaymentProcessorType()
Returns the processor type associated with a payment processor ID.
public
static getCurrentPaymentProcessorType([int $processorId = 0 ]) : string
If the optional argument is not set and greater than zero, the value processorId stored in this object is used. If this is invalid as well, returns the empty string. Note: Currently supported types are 'internal' and 'external'.
Parameters
- $processorId : int = 0
-
The payment processor ID
Tags
Return values
string —The payment processor type, or the empty string on failure.
getDatatransForm()
Returns the complete HTML code for the Datatrans payment form
public
static getDatatransForm() : string
Includes form, input and submit button tags
Tags
Return values
string —The HTML form code
getMenuoptions()
public
static getMenuoptions([mixed $selected_id = 0 ]) : mixed
Parameters
- $selected_id : mixed = 0
getOrderId()
public
static getOrderId() : mixed
getPaymentProcessorName()
Returns the name associated with a payment processor ID.
public
static getPaymentProcessorName([int $processorId = 0 ]) : string
If the optional argument is not set and greater than zero, the value processorId stored in this object is used. If this is invalid as well, returns the empty string.
Parameters
- $processorId : int = 0
-
The payment processor ID
Tags
Return values
string —The payment processors' name, or the empty string on failure.
getPaymentProcessorNameArray()
Returns an array with all the payment processor names indexed by their ID.
public
static getPaymentProcessorNameArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The payment processor name array on success, the empty array on failure.
getPaymentProcessorPicture()
Returns the picture file name associated with a payment processor ID.
public
static getPaymentProcessorPicture([int $processorId = 0 ]) : string
If the optional argument is not set and greater than zero, the value processorId stored in this object is used. If this is invalid as well, returns the empty string.
Parameters
- $processorId : int = 0
-
The payment processor ID
Tags
Return values
string —The payment processors' picture file name, or the empty string on failure.
init()
Initialize known payment service providers
public
static init() : mixed
initProcessor()
Set the active processor ID
public
static initProcessor(int $processorId) : void
Parameters
- $processorId : int
-
The PSP ID to use