PaymentAPI::StartPayment (open)

Start a payment

Syntax

LOADLIB "mod::wrd/lib/payments.whlib";

RECORD FUNCTION StartPayment(INTEGER entityid, MONEY amount, RECORD paymentdata)

Parameters

INTEGER entityid

Entity in which to record payment. This entity must be of the paymenttype. If 0, this is a precheck, not an actual payment attempt

MONEY amount

Amount to request

RECORD paymentdata

Payment metadata

BOOLEAN forceapproved

Force the transaction to be approved immediately, to allow us to 'shortcircuit' transaction flows

BOOLEAN isexternal

Request the external provider (for safety reasons setting paymentprovider=0 is not sufficient)

STRING language

Customer language code

STRING paymentmethodtag

Method tag (combines provider + optional tag). Specify either this tag or both provider + optiontag

STRING paymentoptiontag

Optional tag for payment provider (to select payment option)

INTEGER paymentprovider

Id of a payment provider

OBJECT wrdpersonentity

WRD_PERSON entity describing the customer

Return value

RECORD

Payment instruction

BOOLEAN complete

If true, the payment has already reached a final status

RECORD ARRAY errors

If set, errors returned by the PSP which aborted this payment.

STRING errors.description

Internal description of the error

STRING errors.error

Message to show to user, translated into the current language, if any

STRING errors.field

Affected field, if known. Eg WRD_LASTNAME

RECORD submitinstruction

If set, submitinstruction to send to the client to complete payment

Description

Initiates the payment with the remote PSP. The payment must already be committed to the database and be in the 'pending' status. The PSP may do some final checks and stil return 'errors' - if so, the payment itself remains in pending status and no payment(reference) is recorded (but the next payment WILL have a different paymentreference)