Browse Source

提交测试 api

lvhao 21 hours ago
parent
commit
dbb306a9cf
1 changed files with 127 additions and 0 deletions
  1. 127 0
      core/CoreApp/models/Model_api.php

+ 127 - 0
core/CoreApp/models/Model_api.php

@@ -752,6 +752,133 @@ function __construct(){
 			}
 		}
 		
+	}
+
+
+	public function authorization_bak($shop,$shopifyid)//shopify获取交易号
+    {
+		if($shop['brandname'] == 'yolissahair'){
+			$shopname = 'xxu7p0-3q';
+		}elseif ($shop['brandname'] == 'Yolissa') {
+		    $shopname = 'xxu7p0-3q';
+		}else{
+		    $shopname = $shop['brandname'];
+		}
+		$post = [];
+		$post['shopify_pay'] = [
+			"url"=> 'https://'.$shopname.'.myshopify.com/admin/api/2022-10/orders/'.$shopifyid.'/transactions.json',
+			"token"=>"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",
+		];
+		$ch = curl_init();
+		curl_setopt($ch,CURLOPT_URL,'https://edm.alipearl.net/soapapi.php');
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_HEADER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+		curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		//$this->logic_ding->sendToDing("独立站获取订单的店铺执行shopfiy支付信息【".$shopifyid."】".$res."}{".json_encode($post));
+		// $shopifyid = $shopifyid;
+		// $url = 'https://'.$shop['shopname'].'.myshopify.com/admin/api/2022-10/orders/'.$shopifyid.'/transactions.json';
+        // 	$headerA[] = "X-Shopify-Access-Token: ".$shop['token'];
+        // 	$ch = curl_init();
+        // 	curl_setopt($ch, CURLOPT_URL, $url);
+        // 	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        // 	curl_setopt($ch, CURLOPT_HTTPHEADER, $headerA);
+        // 	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        // 	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        // 	$res = curl_exec($ch);
+		// 	$headerA = curl_getinfo($ch)
+		
+		$a = json_decode($res,true);
+
+		if(!isset($a['transactions']))
+		{
+			return array('g'=>0);exit;
+		}
+		$tmp_pay_list = [];
+		foreach ($a['transactions'] as $v){
+			if(stripos($v['gateway'],'gift_card') === false){
+				$tmp_pay_list[] = $v;
+			}
+		}
+		$a['transactions'] = $tmp_pay_list;
+		if(count($a['transactions']) < 2){
+			//
+			if($a['transactions'][0]['gateway'] == 'Klarna' ){
+				return array('g'=>1,'d'=>$a['transactions'][0]['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($a['transactions'][0]['gateway'],'Payoneer Checkout Klarna') !== false){
+				return array('g'=>1,'d'=>$a['transactions'][0]['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($a['transactions'][0]['gateway'],'Afterpay') !== false){
+				return array('g'=>1,'d'=>$a['transactions'][0]['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($a['transactions'][0]['gateway'],'Airwallex') !== false){
+				return array('g'=>1,'d'=>$a['transactions'][0]['payment_id'],'protection_eligibility'=>"");
+			}else{
+				$a['transactions'] = array_reverse($a['transactions']);
+				if(isset($a['transactions'][0]['authorization']))
+				{
+					$protection_eligibility = "";
+					if(isset($a['transactions'][0]['receipt'])){
+						if(isset($a['transactions'][0]['receipt']['protection_eligibility'])){
+							$protection_eligibility = $a['transactions'][0]['receipt']['protection_eligibility'];
+						}elseif(isset($a['transactions'][0]['receipt']['purchase_units'])){
+							if(!empty($a['transactions'][0]['receipt']['purchase_units']['captures'])){
+								if(isset($a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection'])){
+									if(isset($a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection']['status'])){
+										$protection_eligibility = $a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection']['status'];
+									}
+								}
+							}
+						}
+					}
+					return array('g'=>1,'d'=>$a['transactions'][0]['authorization'],'protection_eligibility'=>$protection_eligibility);
+				}
+				else
+				{
+					return array('g'=>0);
+				}
+			}
+		}else{
+			$end_info = end($a['transactions']);
+			if($end_info['gateway'] == 'Klarna' ){
+				return array('g'=>1,'d'=>$end_info['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($end_info['gateway'],'Payoneer Checkout Klarna') !== false){
+				return array('g'=>1,'d'=>$end_info['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($end_info['gateway'],'Afterpay') !== false){
+				return array('g'=>1,'d'=>$end_info['payment_id'],'protection_eligibility'=>"");
+			}elseif(stripos($end_info['gateway'],'Airwallex') !== false){
+				return array('g'=>1,'d'=>$end_info['payment_id'],'protection_eligibility'=>"");
+			}
+			else{
+				$a['transactions'] = array_reverse($a['transactions']);
+				if(isset($a['transactions'][0]['authorization']))
+				{
+					$protection_eligibility = "";
+					if(isset($a['transactions'][0]['receipt'])){
+						if(isset($a['transactions'][0]['receipt']['protection_eligibility'])){
+							$protection_eligibility = $a['transactions'][0]['receipt']['protection_eligibility'];
+						}elseif(isset($a['transactions'][0]['receipt']['purchase_units'])){
+							if(!empty($a['transactions'][0]['receipt']['purchase_units']['captures'])){
+								if(isset($a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection'])){
+									if(isset($a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection']['status'])){
+										$protection_eligibility = $a['transactions'][0]['receipt']['purchase_units']['captures'][0]['seller_protection']['status'];
+									}
+								}
+							}
+						}
+					}
+					return array('g'=>1,'d'=>$a['transactions'][0]['authorization'],'protection_eligibility'=>$protection_eligibility);
+				}
+				else
+				{
+					return array('g'=>0);
+				}
+			}
+		}
 		
 	}