我有一个 dovoid 函数,我从经典 api 的各种教程中获取(我们网站的其余部分使用经典 api,所以我一直在使用它,直到我能够解决这个问题并使用更好的 api)。该函数似乎在执行,我没有收到错误消息,但我没有看到沙箱中的交易无效。
这是 dovoid 函数:
public function DoVoid($auth_id,$note)
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>'.
ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
'.
'<SOAP-ENV:Header>
'.
'<RequesterCredentials
xmlns="urn:ebay:api:PayPalAPI"
SOAP-ENV:mustUnderstand="1">
'.
'<Credentials xmlns="urn:ebay:apis:eBLBaseComponents">
'.
'<Username>'.utf8_encode($PayPalApiUsername).'</Username> '.
'<Password>'.utf8_encode($PayPalApiPassword).'</Password> '.
'<Subject>'.utf8_encode("Voiding Transaction").'</Subject>'.
'
</Credentials>'.
'
</RequesterCredentials>'.
'
</SOAP-ENV:Header>'.
'<SOAP-ENV:Body>
'.
'<DoVoidReq xmlns="urn:ebay:api:PayPalAPI">
'.
'<DoVoidRequest xmlns="urn:ebay:api:PayPalAPI">
'.
'<Version xmlns="urn:ebay:apis:eBLBaseComponents"
xsi:type="xsd:string">60.0</Version>'.
'<AuthorizationID>'.utf8_encode($auth_id).'</AuthorizationID>'.
'<Note>'.utf8_encode($note).'</Note>'.
'
</DoVoidRequest>'.
'
</DoVoidReq>'.
'
</SOAP-ENV:Body>'.
'
</SOAP-ENV:Envelope>';
//send query
$response = $this->sendQuery($xml);
if ($response)
{
//check XML response data
if (isset($response["SOAP-ENV:Envelope"][0]["SOAP-ENV:Body"][0]["DoVoidResponse"][0]))
{
$a = $response["SOAP-ENV:Envelope"][0]["SOAP-ENV:Body"][0]["DoVoidResponse"][0];
//check is there transaction error
if (isset($a["Errors"]))
{
$this->is_error = true;
foreach ($a["Errors"] as $key=>$value)
{
$this->error_messages[] = $value["ShortMessage"][0].(trim($value["ShortMessage"][0])!=trim($value["LongMessage"][0])?(" - ".$value["LongMessage"][0]):"");
}
return $this->error_messages;
}
//potentially all is good
else
{
$this->PaymentAction = $a;
//check tocken is the same as sent
if ($a["Ack"][0] == "Success")
{
if (isset($a["AuthorizationID"][0]))
{
//return payment data
return $a["AuthorizationID"][0];
}
}
else
{
$this->is_error = true;
$this->error_messages[] = "Incorrect transaction status";
return false;
}
}
}
}
}
现在我不确定(因为我刚开始使用这个 API)一件事是授权 ID 应该是什么样子。目前,我从我们系统的其他地方提取的那些以“ec_”开头,我认为这是不正确的。这些授权 ID 应该是什么样子才能作废?
我想做的是在订单值发生变化时取消授权,因为我们遇到了很多麻烦,因为人们因为他们更改订单、重新授权而获得多个待处理交易,并且我们的系统变得困惑。虽然我正在尝试解决更大的结构性问题,但我需要将此作为短期解决方案,因此我们每个订单只有一个有效授权。
最佳答案
为了使授权无效,您需要引用它的交易 ID。以“EC”开头的字符串是安全 token 。 PayPal 交易 ID 包含 16 个字母数字字符,例如 5DE44868BF3911546。
关于php - PayPal DoVoid 函数未作废,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24042807/