Reputation: 3764
I have a dovoid function I've taken from various tutorials for the classic api (the rest of our site uses the classic api, so I'm stuck using it until i can gut the thing and use the better apis). The function appears to execute and I am not getting error messages, but I am not seeing the transactions voided in the sandbox.
Here is the dovoid function:
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;
}
}
}
}
}
Now one thing I am not sure of (since I just started using this API) is what the authorization ID should look like. Currently, the ones I am pulling from elsewhere in our system start with "ec_" which I don't think is correct. What should these authorization ids look like for voiding?
What I am trying to do is void an authorization when the order's values change, as we have had a lot of trouble with people getting multiple pending transactions because they change their order, reauthorize, and our system gets confused. While I am trying to fix the larger structural problems, I need this as a short term fix so we only have one active authorization per order.
Upvotes: 0
Views: 204
Reputation: 1945
In order to void an authorization you will need to reference it's transaction ID. The string that begins with "EC" is the secure token. A PayPal transaction ID contains 16 alphanumeric characters, for example 5DE44868BF3911546.
Upvotes: 1