Yii Framework和Authorize.net创建配置文件

时间:2018-07-31 17:58:34

标签: php ajax api yii authorize.net

我对authorize.net和yiiframework有点问题 我需要使用来自我的webiste的数据在authorize.net系统中创建一个客户帐户。 我正在使用此扩展名https://www.yiiframework.com/extension/authorize-net-cim-yii-extension,但没有成功。 与您分享我的尝试 Ajax返回代码为500 可变错误应该返回错误或成功,但实际上什么也不会返回 预先感谢

            $userInfo = [
                'type' => 'Payment',    //Payment OR Withdraw
                'user_id' => 12314,
                'profile_id' => 1231231,
                'email' => $this->data['email_address'],
            ];
            echo Yii::app()->authorizenetCIM->authNetCreateProfile($userInfo);
            // $result = Yii::app()->authorizenetCIM->authNetCreateProfile($userInfo);
            if ($result != "error") {
                $this->msg = t("success");
                return ;
            } else {
                $this->msg=t("error");
                return ;
            }



    public function authNetCreateProfile($data) //$type = Payment OR Withdraw
{
    //build xml to post
    $content =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
        "<createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
        $this->getMerchantAuthenticationBlock().
        "<profile>".
        "<merchantCustomerId>" . CHtml::encode(strip_tags($data['type']))."-".CHtml::encode(strip_tags($data['user_id']))."-".CHtml::encode(strip_tags($data['profile_id']))  ."</merchantCustomerId>". // Your own identifier for the customer.
        "<description></description>".
        "<email>" . CHtml::encode(strip_tags($data['email'])) . "</email>".
        "</profile>".
        "</createCustomerProfileRequest>";  

    $response = $this->sendXMLRequest($content);    
    $parsedresponse = $this->parseAPIResponse($response);   

    if ("Ok" == $parsedresponse->messages->resultCode) {
        return htmlspecialchars($parsedresponse->customerProfileId);
    }   

    return "error";
}

0 个答案:

没有答案