PHP Class SEPASDD, sepa-direct-debit

显示文件 Open project: congressus/sepa-direct-debit Class Usage Examples

Public Methods

Method Description
__construct ( $config )
addCustomNode ( $parent_XPATH, $name, $value = "", $attr = [] ) Function to add a custom node to the document.
addPayment ( $payment ) Public function to add payments
getDirectDebitInfo ( )
isEmpty ( ) getBatch
save ( ) : The Function to finalize and save the document after all payments are added.
validate ( $xml ) Function to validate xml against the pain.008.001.02 schema definition.
validateAmount ( $amount ) : TRUE Function to validate an amount, to check that amount is in cents.
validateBIC ( $BIC ) : TRUE Validate a BIC number.Payment Information
validateBatch ( $batch ) : boolean Validate an batch config option.
validateDDType ( $type ) : True Function to validate the Direct Debit Transaction types
validateDate ( $date ) : True Function to validate a ISO date.
validateEndToEndId ( $EndToEndId ) : boolean Validate an EndToEndId.
validateIBAN ( $IBAN ) : boolean Validate an IBAN Number.
validateMandateDate ( $date ) : True Function to validate a ISO date.

Private Methods

Method Description
calcTotalAmount ( $array ) : The Function to calculate the sum of the amounts, given as decimals in an array.
createGroupHeader ( ) Function to create the GroupHeader (GrpHdr) in the CstmrDrctDbtInit Node
decimalToInt ( $decimal ) : The Function to convert an amount in decimal to cents (without point).
finalize ( ) Function to finalize the document, completes the header with metadata, and processes batches.
getBatch ( $type, $date ) Function to create a batch (PmtInf with BtchBookg set true) element.
getCstmrDrctDbtInitnNode ( ) : The Function to get the CstmrDrctDbtInitnNode from the current document.
intToDecimal ( $int ) : The Function to convert an amount in cents to a decimal (with point).
makeId ( ) : the Create a random id, combined with the name (truncated at 22 chars).
makeMsgId ( ) : the Create a random Message Id f$PmtInfNodeor the header, prefixed with a timestamp.
prepareDocument ( ) Build the main document node and set xml namespaces.
validateConfig ( $config ) : TRUE Check the config file for required fields and validity.
validatePayment ( $payment ) : TRUE Check a payment for validity

Method Details

__construct() public method

public __construct ( $config )

addCustomNode() public method

Function to add a custom node to the document.
public addCustomNode ( $parent_XPATH, $name, $value = "", $attr = [] )
$parent_XPATH A valid XPATH expression defining the parent of the new node
$name The name of the new node
$value The value of the new node (Optional, default "")
$attr Key => Value array defining the attributes (Optional, default none)

addPayment() public method

Public function to add payments
public addPayment ( $payment )

getDirectDebitInfo() public method

public getDirectDebitInfo ( )

isEmpty() public method

getBatch
public isEmpty ( )

save() public method

Function to finalize and save the document after all payments are added.
public save ( ) : The
return The XML to be echoed or saved to file.

validate() public method

Function to validate xml against the pain.008.001.02 schema definition.
public validate ( $xml )
$xml The xml, as a string, to validate agianst the schema.

validateAmount() public static method

Function to validate an amount, to check that amount is in cents.
public static validateAmount ( $amount ) : TRUE
$amount The amount to validate.
return TRUE if valid, FALSE if invalid.

validateBIC() public method

Validate a BIC number.Payment Information
public validateBIC ( $BIC ) : TRUE
$BIC the BIC number to check.
return TRUE if valid, FALSE if invalid.

validateBatch() public static method

Validate an batch config option.
public static validateBatch ( $batch ) : boolean
$batch the boolean to check.
return boolean TRUE if valid, FALSE if invalid.

validateDDType() public static method

Function to validate the Direct Debit Transaction types
public static validateDDType ( $type ) : True
return True if valid, error string if invalid.

validateDate() public static method

Function to validate a ISO date.
public static validateDate ( $date ) : True
$date The date to validate.
return True if valid, error string if invalid.

validateEndToEndId() public static method

Validate an EndToEndId.
public static validateEndToEndId ( $EndToEndId ) : boolean
$EndToEndId the EndToEndId to check.
return boolean TRUE if valid, error string if invalid.

validateIBAN() public method

Validate an IBAN Number.
public validateIBAN ( $IBAN ) : boolean
$IBAN the IBAN number to check.
return boolean TRUE if valid, FALSE if invalid.

validateMandateDate() public static method

Function to validate a ISO date.
public static validateMandateDate ( $date ) : True
$date The date to validate.
return True if valid, error string if invalid.