HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot//ly.kntsleep.com/h.php
 
<?php

$clientId = 'AfFNXBdfrl8X-oX9gStJHf7lsasYY5QP1TDTzENcYPXxPsmz_G6fLnZ3t2EvoLZlKO6IRFTJ9KQrBAYA';
$clientSecret ='EMz1kZwRKAKTl4UIiJ-VLCB7WlH0aw43aZd3SVeYG6fNjiQj7bCph9h-uBCinLsdI4v5ERs4lioNJnnX';
 
// $clientId = 'AVc0lwtgvNbMYa9N9jeWXn_dTIkiJxTQEJWl9I7TJCJ06j9gfqCBpRjpluhdHJuQ6UB_O6Y1nlgB1hKS';//yzy商户
// $clientSecret ='EKOPum4XFGuuRKuoJhD4GPtxVkxDUbUVPtue0T-yXKTTYgcnWRGPO7owxn-DIizGdCdYBW3YMdGvjhB0';
// Step 1: 获取访问令牌(Access Token)
$tokenUrl = 'https://api.paypal.com/v1/oauth2/token';
$tokenData = http_build_query(array('grant_type' => 'client_credentials'));

$options = array(
    'http' => array(
        'header'  => "Authorization: Basic " . base64_encode($clientId . ':' . $clientSecret) . "\r\n" .
                     "Content-Type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => $tokenData,
    ),
);

$context = stream_context_create($options);
$response = file_get_contents($tokenUrl, false, $context);
$tokenData = json_decode($response, true);
$accessToken = $tokenData['access_token'];
// echo  $accessToken;
// Step 2: 发起查询请求
 

$url = 'https://api-m.paypal.com/v1/customer/disputes/?page=1&page_size=20';
 

$options = array(
    'http' => array(
        'header'  => "Content-Type: application/json\r\n" .
                     "Authorization: Bearer " . $accessToken . "\r\n",
        'method'  => 'GET',
    ),
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// echo $response; //这个可以输出很多的结果

 

$json = json_decode($response, true);
$reasonTranslations = array(
    "MERCHANDISE_OR_SERVICE_NOT_RECEIVED" => "客户没有收到商品或服务",
    "MERCHANDISE_OR_SERVICE_NOT_AS_DESCRIBED" => "客户报告商品或服务与描述不符",
    "UNAUTHORISED" => "客户未授权购买商品或服务",
    "CREDIT_NOT_PROCESSED" => "未为客户处理退款或积分",
    "DUPLICATE_TRANSACTION" => "该交易是重复的",
    "INCORRECT_AMOUNT" => "客户被收取了错误的金额",
    "PAYMENT_BY_OTHER_MEANS" => "客户通过其他方式支付交易费用",
    "CANCELED_RECURRING_BILLING" => "客户需要为已取消的订阅或重复",
    "PROBLEM_WITH_REMITTANCE" => "汇款时出现问题",
    "OTHER" => "其他"
);

$statusTranslations = array(
    "OPEN" => "争议是公开的",
    "WAITING_FOR_BUYER_RESPONSE" => "争议正在等待客户的答复",
    "WAITING_FOR_SELLER_RESPONSE" => "纠纷正在等待商家回复",
    "UNDER_REVIEW" => "该争议正在与 PayPal 进行审查",
    "RESOLVED" => "争议已解决",
    "OTHER" => "如果争议不具有其他状态之一,则为默认状态"
);
 
 
 $transaction_statusTranslations = array(
    "COMPLETED" => "交易处理完成",
    "UNCLAIMED" => "交易中的物品无人认领。如果 30 天内无人认领,资金将退还给汇款人",
    "DENIED" => "交易被拒绝",
    "FAILED" => "交易失败",
    "HELD" => "交易被搁置",
    "PENDING" => "交易正在等待处理",
    "PARTIALLY_REFUNDED" => "交易款项已部分退还",
    "REFUNDED" => "交易款项已成功退还",
    "REVERSED" => "由于退款或其他冲销类型,交易付款被冲销",
    "CANCELLED" => "交易被取消"
);
 
 
// 遍历纠纷记录并输出
foreach ($json['items'] as $item) {
    
    
//开始根据纠纷id重新客户的名字和交易码   开启这个会有点慢查询     
$disputes=$item['dispute_id'];
$url2 = 'https://api-m.paypal.com/v1/customer/disputes/'.$disputes.'';
$context2 = stream_context_create($options);
$response2 = file_get_contents($url2, false, $context2);

if ($response2 === FALSE) {
    echo "Error fetching data";
} else {
    // echo $response;//可以输出很多的结果
}
$jsonData = json_decode($response2, true);

 
$seller_transaction_id = $jsonData['disputed_transactions'][0]['seller_transaction_id'];
$transaction_status = $jsonData['disputed_transactions'][0]['transaction_status'];
$name = $jsonData['disputed_transactions'][0]['buyer']['name'];
 
echo "交易码: $seller_transaction_id\n". "<br>";;
  if (array_key_exists($transaction_status, $transaction_statusTranslations)) {
        echo "结果:" . $transaction_statusTranslations[$transaction_status] . "<br>";
    } else {
        echo "结果:未知结果<br>";
    }

echo "客户名字: $name\n". "<br>";
//结束根据纠纷id重新客户的名字和交易码    
 
 
 
 
 
    
    
    echo "纠纷ID:" . $item['dispute_id'] . "<br>";
    echo "创建时间:" . date('Y-m-d H:i:s', strtotime($item['create_time'])) . "<br>";
    echo "纠纷金额:" . $item['dispute_amount']['value'] . " " . $item['dispute_amount']['currency_code'] . "<br>";
    
    
    
  if (array_key_exists($item['reason'], $reasonTranslations)) {
        echo "原因:" . $reasonTranslations[$item['reason']] . "<br>";
    } else {
        echo "原因:未知原因<br>";
    }
    
    
       if (array_key_exists($item['status'], $statusTranslations)) {
        echo "状态:" . $statusTranslations[$item['status']] . "<br>";
    } else {
        echo "状态:未知状态<br>";
    }
    echo "截止日期:" . date('Y-m-d H:i:s', strtotime($item['seller_response_due_date'])) . "<br><br><br>";
 
 

    
}
 
 


 

?>