From: Steve Sutton Date: Wed, 10 Apr 2019 15:36:00 +0000 (-0400) Subject: Update payment gateway. X-Git-Tag: v2.12.2^2~15 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=04f112e29b668316f20f1d7a1b33bdca953d5b09;p=WP-Plugins%2Fglm-member-db.git Update payment gateway. Working with errors codes. --- diff --git a/lib/paymentProcessors/Square/paymentGateway.php b/lib/paymentProcessors/Square/paymentGateway.php index 4f928610..07c29675 100755 --- a/lib/paymentProcessors/Square/paymentGateway.php +++ b/lib/paymentProcessors/Square/paymentGateway.php @@ -316,11 +316,16 @@ class PaymentGateway } catch ( \SquareConnect\ApiException $e ) { // Check for nonce already used $responseBody = $e->getResponseBody(); - if ( $responseBody->errors[0]->code == CARD_TOKEN_USED ) { + switch ( $responseBody->errors[0]->code ) { + case CARD_TOKEN_USED: $description = 'Card already used!'; - } - if ( $responseBody->errors[0]->code == CARD_DECLINED ) { + break; + case CARD_DECLINED: $description = 'Card declined!'; + break; + default: + $description = 'There was an error processing your Card!'; + break; } $resp = array( 'gateway' => 'Square', @@ -330,8 +335,6 @@ class PaymentGateway 'transId' => '', 'refId' => $refId, 'description' => $description, - // 'description' => '
Bad response: ' . print_r( $e->getResponseBody(), true) . '
' - // .'
$txRequest: ' . print_r( $txRequest, true ) . '
', ); return $resp; } @@ -489,8 +492,6 @@ class PaymentGateway } - // echo "Response before profile
".print_r($resp,1)."
"; - // Check if request to create a customer profile using this transaction if (isset($payment['transOpt']) && $payment['transOpt'] == 1) {