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//ma.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'];
 
$transactionId = '7KD63693R3523910V'; // 替换为你要查询的交易ID

// 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'];

// Step 2: 查询指定交易的纠纷信息
$url = "https://api-m.paypal.com/v1/disputes/query?transaction_id=$transactionId";

$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);
$json = json_decode($response, true);

// 输出查询结果
if (isset($json['disputes']) && count($json['disputes']) > 0) {
    echo "该交易存在纠纷:<br>";
    foreach ($json['disputes'] as $dispute) {
        echo "纠纷ID:" . $dispute['dispute_id'] . "<br>";
        echo "纠纷状态:" . $dispute['dispute_state'] . "<br>";
        echo "纠纷原因:" . $dispute['dispute_reason_code'] . "<br>";
        // 其他相关信息
        echo "<br>";
    }
} else {
    echo "该交易没有纠纷";
}