Completed
Push — master ( f977bb...eb1870 )
by Wei
06:18
created
src/service/Mchpay.php 1 patch
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 	 * @throws Exception
26 26
 	 */
27 27
 	public function transferWallet($partner_trade_no,$openid,$amount,$desc,$spbill_create_ip = null,$re_user_name = null,$check_name = WechatPay::CHECKNAME_FORCECHECK){
28
-		if($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) throw new Exception('Real name is required');
28
+		if($check_name == WechatPay::CHECKNAME_FORCECHECK && !$re_user_name) {
29
+			throw new Exception('Real name is required');
30
+		}
29 31
 		$data = [
30 32
 			"mch_appid" => $this->config["app_id"],
31 33
 			"mchid" => $this->config["mch_id"],
@@ -66,7 +68,9 @@  discard block
 block discarded – undo
66 68
 	 * @throws Exception
67 69
 	 */
68 70
 	public function transferBankCard($partner_trade_no,$bank_no,$true_name,$bank_code,$amount,$desc){
69
-		if(!in_array($bank_code,array_values(self::$BANKCODE))) throw new Exception("Unsupported bank code: $bank_code");
71
+		if(!in_array($bank_code,array_values(self::$BANKCODE))) {
72
+			throw new Exception("Unsupported bank code: $bank_code");
73
+		}
70 74
 		$data = [
71 75
 			"partner_trade_no" => $partner_trade_no,
72 76
 			"enc_bank_no" => $this->rsaEncrypt($bank_no),
@@ -79,13 +83,16 @@  discard block
 block discarded – undo
79 83
 	}
80 84
 
81 85
 	public function rsaEncrypt($data,$pubkey = null){
82
-		if(!$pubkey) $pubkey = $this->getPublicKey();
86
+		if(!$pubkey) {
87
+			$pubkey = $this->getPublicKey();
88
+		}
83 89
 		$encrypted = null;
84 90
 		$pubkey = openssl_get_publickey($pubkey);
85
-		if (@openssl_public_encrypt($data, $encrypted, $pubkey,OPENSSL_PKCS1_OAEP_PADDING))
86
-			$data = base64_encode($encrypted);
87
-		else
88
-			throw new Exception('Unable to encrypt data');
91
+		if (@openssl_public_encrypt($data, $encrypted, $pubkey,OPENSSL_PKCS1_OAEP_PADDING)) {
92
+					$data = base64_encode($encrypted);
93
+		} else {
94
+					throw new Exception('Unable to encrypt data');
95
+		}
89 96
 		return $data;
90 97
 	}
91 98
 
@@ -114,7 +121,7 @@  discard block
 block discarded – undo
114 121
 		if(!$this->publicKey) {
115 122
 			if (!$refresh && file_exists($this->config["rsa_pubkey_path"])) {
116 123
 				$this->publicKey = file_get_contents($this->config["rsa_pubkey_path"]);
117
-			}else{
124
+			} else{
118 125
 				$data = array();
119 126
 				$data["mch_id"] = $this->config["mch_id"];
120 127
 				$data["sign_type"] = $this->config["sign_type"];
Please login to merge, or discard this patch.