Php PayPal DoVoid函数未作废
我有一个dovoid函数,它是从各种经典api教程中获得的(我们网站的其余部分都使用经典api,所以我一直在使用它,直到我能够理解并使用更好的api为止)。该函数似乎正在执行,我没有收到错误消息,但我没有看到沙盒中的事务无效 以下是dovoid函数:Php PayPal DoVoid函数未作废,php,api,paypal,Php,Api,Paypal,我有一个dovoid函数,它是从各种经典api教程中获得的(我们网站的其余部分都使用经典api,所以我一直在使用它,直到我能够理解并使用更好的api为止)。该函数似乎正在执行,我没有收到错误消息,但我没有看到沙盒中的事务无效 以下是dovoid函数: public function DoVoid($auth_id,$note) { $xml = '<?xml version="1.0" encoding="UTF-8"?>'. ENV:Envelope
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;
}
}
}
}
}
公共函数DoVoid($auth\u id,$note)
{
$xml=''。
环境:信封
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/">
'.
'
'.
'
'.
'
'.
''.utf8_编码($PayPalApiUsername)。''。
''.utf8_编码($PayPalApiPassword)。''。
''.utf8_编码(“作废交易”)。'。
'
'.
'
'.
'
'.
'
'.
'
'.
'
'.
'60.0'.
''.utf8_编码($auth_id)。''。
''.utf8_编码($note)。''。
'
'.
'
'.
'
'.
'
';
//发送查询
$response=$this->sendQuery($xml);
如果($答复)
{
//检查XML响应数据
如果(isset($response[“SOAP-ENV:Envelope”][0][“SOAP-ENV:Body”][0][“DoVoidResponse”][0]))
{
$a=$response[“SOAP-ENV:Envelope”][0][“SOAP-ENV:Body”][0][“DoVoidResponse”][0];
//检查是否存在交易错误
如果(isset($a[“错误]))
{
$this->is_error=true;
foreach($a[“Errors”]作为$key=>$value)
{
$this->error_messages[]=$value[“ShortMessage”][0]。(trim($value[“ShortMessage”][0])!=trim($value[“LongMessage”][0])?(“-”$value[“LongMessage”][0]):”;
}
返回$this->error\u消息;
}
//潜在的一切都是好的
其他的
{
$this->PaymentAction=$a;
//检查tocken是否与发送的相同
如果($a[“确认”][0]=“成功”)
{
如果(isset($a[“授权ID”][0]))
{
//返回付款数据
返回$a[“授权ID”][0];
}
}
其他的
{
$this->is_error=true;
$this->error_messages[]=“不正确的交易状态”;
返回false;
}
}
}
}
}
现在有一件事我不确定(因为我刚刚开始使用这个API),那就是授权ID应该是什么样子。目前,我从我们系统中的其他地方得到的答案都是以“ec_2;”开头的,我认为这是不正确的。这些授权ID在作废时应该是什么样子
我试图做的是在订单的值发生变化时取消授权,因为我们遇到了很多麻烦,人们无法获得多个挂起的交易,因为他们改变了订单,重新授权,我们的系统变得混乱。当我试图解决更大的结构问题时,我需要将此作为短期解决方案,以便每个订单只有一个活动授权。为了使授权无效,您需要引用它的事务ID。以“EC”开头的字符串是安全令牌。PayPal交易ID包含16个字母数字字符,例如5DE44868BF3911546。谢谢,我最终解决了这个问题。到那时,我已经放弃了上面的内容,使用了一个Curl实现。