douping7105 2014-06-04 16:30
浏览 30
已采纳

PayPal DoVoid功能不是空洞

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.

  • 写回答

1条回答 默认 最新

  • dougouqin0763 2014-06-04 19:16
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站