* Card postal code incorrect Use 99999 as the postal code
* Card expiration date incorrect Use 01/40 as the expiration date
*
+ * Declined
+ * You can also trigger a "Card declined" error by using 403 as the amount_money in the Charge request.
*/
public function processPayment( $payment = false, $customer = false )
{
$transactionApi = new \SquareConnect\Api\TransactionsApi();
+ if ( !isset( $customer['email'] ) || trim( $customer['email'] ) == '' ) {
+ $errorMsg[] = 'Required Customer Email Address not provided';
+ }
if ( !isset( $customer['addr1'] ) || trim( $customer['addr1'] ) == '' ) {
$errorMsg[] = 'Required Customer Address Line 1 not provided';
}
if ( !isset( $customer['zip'] ) || trim( $customer['zip'] ) == '' ) {
$errorMsg[] = 'Required Customer ZIP/Postal Code not provided';
}
+ if (!isset($payment['charge']) || (trim($payment['charge'])-0) <= 0) {
+ $errorMsg[] = 'Required Charge Amount not provided';
+ }
+ // If there's a problem with submitted information
+ if ( count( $errorMsg ) > 0 ) {
+ $resp = array(
+ 'gateway' => 'Square',
+ 'status' => 2,
+ 'statusText' => 'Bad data supplied',
+ 'authCode' => '',
+ 'transId' => '',
+ 'refId' => $refId,
+ 'description' => implode(', ', $errorMsg)
+ );
+ return $resp;
+ }
$buyerInfo = array(
'buyer_email_address' => $customer['email'],
'billing_address' => array(