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.

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

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。