我目前在Paypal退款测试中遇到了一些问题。
通过以下方式获取帐户的令牌:
public function __construct(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $this->clientID.":".$this->secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$result = curl_exec($ch);
$json = json_decode($result);
$this->auth = $json->access_token;
// echo "Auth?" . $this->auth;
}
当我尝试退还促销时,它只返回1个无效的东西。交易ID是正确的,但它就像没有设置正确的标题 - 有人可以帮助我吗?
public function RefundSale($transaction_id){
$url = self::getPath() . "/payments/sale/".$transaction_id."/refund";
echo "URL:" . $url;
self::rest($url);
}
public function rest($url,$data=""){
$ch = curl_init();
if ( !empty($data)): $data=json_encode($data); endif; //Array to json?
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
if ( !empty($data)): curl_setopt($ch, CURLOPT_POSTFIELDS, $data); endif;
curl_setopt($ch, CURLOPT_USERPWD, $this->clientID . ":" . $this->secret);
$result = curl_exec($ch);
var_dump($result);
}
答案 0 :(得分:0)
一些事情