Handle error codes and messages

This commit is contained in:
Dat Hoang
2020-08-31 22:35:28 +07:00
parent 3dde550c88
commit d039192043
3 changed files with 119 additions and 54 deletions
+67
View File
@@ -28,6 +28,73 @@ class WooViet_OnePay_Domestic extends WooViet_OnePay_Abstract {
return $testmode ? 'https://mtf.onepay.vn/onecomm-pay/Vpcdps.op' : 'https://onepay.vn/onecomm-pay/Vpcdps.op';
}
public function OnePay_getResponseDescription( $responseCode ) {
switch ( $responseCode ) {
case "0" :
$result = "Giao dịch thành công - Approved";
break;
case "1" :
$result = "Ngân hàng từ chối giao dịch - Bank Declined";
break;
case "3" :
$result = "Mã đơn vị không tồn tại - Merchant not exist";
break;
case "4" :
$result = "Không đúng access code - Invalid access code";
break;
case "5" :
$result = "Số tiền không hợp lệ - Invalid amount";
break;
case "6" :
$result = "Mã tiền tệ không tồn tại - Invalid currency code";
break;
case "7" :
$result = "Lỗi không xác định - Unspecified Failure ";
break;
case "8" :
$result = "Số thẻ không đúng - Invalid card Number";
break;
case "9" :
$result = "Tên chủ thẻ không đúng - Invalid card name";
break;
case "10" :
$result = "Thẻ hết hạn/Thẻ bị khóa - Expired Card";
break;
case "11" :
$result = "Thẻ chưa đăng ký sử dụng dịch vụ - Card Not Registed Service(internet banking)";
break;
case "12" :
$result = "Ngày phát hành/Hết hạn không đúng - Invalid card date";
break;
case "13" :
$result = "Vượt quá hạn mức thanh toán - Exceeds the maximum limit";
break;
case "21" :
$result = "Số tiền không đủ để thanh toán - Insufficient fund";
break;
case "22" :
$result = "Thông tin tài khoản không đúng - Invalid account ìnfo";
break;
case "23" :
$result = "Tài khoản bị khóa - Account locked";
break;
case "24" :
$result = "Thông tin thẻ không đúng - Incorrect card number";
break;
case "25" :
$result = "OTP không đúng - Incorrect OTP";
break;
case "99" :
$result = "Người sủ dụng hủy giao dịch - User cancel";
break;
default :
$result = "Giao dịch thất bại - Failure";
}
return $result;
}
/**
* Initialise Gateway Settings Form Fields.
*/
@@ -28,6 +28,57 @@ class WooViet_OnePay_International extends WooViet_OnePay_Abstract {
return $testmode ? 'https://mtf.onepay.vn/vpcpay/Vpcdps.op' : 'https://onepay.vn/vpcpay/Vpcdps.op';
}
public function OnePay_getResponseDescription( $responseCode ) {
switch ( $responseCode ) {
case "0" :
$result = "Giao dịch thành công - Approved";
break;
case "1" :
case "2" :
$result = "Ngân hàng từ chối giao dịch - Bank Declined";
break;
case "3" :
$result = "OnePay không nhận được kết quả giao dịch từ ngân hàng - OnePAY did not received payment result
from Issuer bank";
break;
case "4" :
$result = "Thẻ hết hạn hoặc sai thông tin hết hạn thẻ - Card expired or incorrect expired date";
break;
case "5" :
$result = "Số tiền không đủ để thanh toán - Insufficient fund";
break;
case "6" :
case "7" :
$result = "Quá trình xử lý giao dịch phát sinh lỗi - An error was encountered while processing your transaction";
break;
case "8" :
$result = "Thẻ không hỗ trợ giao
dịch thanh toán trên Internet - Ecommerce transaction is not supported for this card";
break;
case "9" :
$result = "Ngân hàng từ chối giao dịch - Bank Declined";
break;
case "99" :
$result = "Người sủ dụng hủy giao dịch - User cancel";
break;
case "B" :
case "F" :
$result = "Không xác thực được 3D-Secure - 3D Secure Authentication Failed";
break;
case "E" :
$result = "Nhập sai CSC (Card Security Card) hoặc ngân hàng từ chối cấp phép cho giao dịch - You have entered wrong CSC or Issuer Bank declided transaction";
break;
case "Z" :
$result = "Transaction restricted due to OFDs policies - vi phạm quy định của hệ thống";
break;
default :
$result = "Giao dịch thất bại - Failure";
}
return $result;
}
/**
* Initialise Gateway Settings Form Fields.
*/
+1 -54
View File
@@ -355,60 +355,7 @@ abstract class WooViet_OnePay_Abstract extends WC_Payment_Gateway {
*
* @return string
*/
public function OnePay_getResponseDescription( $responseCode ) {
switch ( $responseCode ) {
case "0" :
$result = "Giao dịch thành công - Approved";
break;
case "1" :
$result = "Ngân hàng từ chối giao dịch - Bank Declined";
break;
case "3" :
$result = "Mã đơn vị không tồn tại - Merchant not exist";
break;
case "4" :
$result = "Không đúng access code - Invalid access code";
break;
case "5" :
$result = "Số tiền không hợp lệ - Invalid amount";
break;
case "6" :
$result = "Mã tiền tệ không tồn tại - Invalid currency code";
break;
case "7" :
$result = "Lỗi không xác định - Unspecified Failure ";
break;
case "8" :
$result = "Số thẻ không đúng - Invalid card Number";
break;
case "9" :
$result = "Tên chủ thẻ không đúng - Invalid card name";
break;
case "10" :
$result = "Thẻ hết hạn/Thẻ bị khóa - Expired Card";
break;
case "11" :
$result = "Thẻ chưa đăng ký sử dụng dịch vụ - Card Not Registed Service(internet banking)";
break;
case "12" :
$result = "Ngày phát hành/Hết hạn không đúng - Invalid card date";
break;
case "13" :
$result = "Vượt quá hạn mức thanh toán - Exist Amount";
break;
case "21" :
$result = "Số tiền không đủ để thanh toán - Insufficient fund";
break;
case "99" :
$result = "Người sủ dụng hủy giao dịch - User cancel";
break;
default :
$result = "Giao dịch thất bại - Failured";
}
return $result;
}
abstract public function OnePay_getResponseDescription( $responseCode );
/**
* Handle the IPN POST request from OnePay