From cb7f8d36c01593f7df65ed89264cccc426d61e00 Mon Sep 17 00:00:00 2001 From: hitsword Date: Mon, 20 May 2019 18:30:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hitsword --- class-wc-huayi-score.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/class-wc-huayi-score.php b/class-wc-huayi-score.php index 29d9e5c..e31c63d 100644 --- a/class-wc-huayi-score.php +++ b/class-wc-huayi-score.php @@ -172,7 +172,7 @@ class WC_Huayi_Score extends WC_Payment_Gateway { return; } } else { //积分不足 - $error_message = '积分余额不足.'; + $error_message = sprintf( __('积分余额不足.剩余%s积分.'), $balanceResult['data']['score']); wc_add_notice( __('结算失败:', 'huayi_score') . $error_message, 'error' ); return; } @@ -184,7 +184,7 @@ class WC_Huayi_Score extends WC_Payment_Gateway { } /** - * 发起退款 + * 发起退还 * @param int $order_id * @param float $amount * @param string $reason @@ -197,10 +197,15 @@ class WC_Huayi_Score extends WC_Payment_Gateway { if ( $huayi_uid > 0 ) { $huayiScoreSdk = new HuayiScoreSdk(array('apiurl'=>$this->apiurl,'token'=>$this->token)); - $result = $huayiScoreSdk->refund($huayi_uid,$amount,get_bloginfo('name').'退款订单号:'.$order_id.'.退款原因:'.$reason);//执行退款 + $result = $huayiScoreSdk->refund($huayi_uid,$amount,get_bloginfo('name').'退还订单号:'.$order_id.'.退还原因:'.$reason);//执行退还 + + if (!$result) { + wc_add_notice( __('退还失败:', 'huayi_score') . $huayiScoreSdk->getError(), 'error' ); + return; + } if ( $result['data']['refund_status'] == 'success' ) {//TODO TEST - $order->add_order_note( sprintf( __( '退款时间: %s - 退款会员ID: %s', 'huayi_score' ), date("Y-m-d H:i:s"),$result['uid'] ) ); + $order->add_order_note( sprintf( __( '退还时间: %s - 退还会员ID: %s', 'huayi_score' ), date("Y-m-d H:i:s"),$result['uid'] ) ); return true; } else { return new WP_Error( 'error', $result );