Categories
PHP

Yii Framework and Authorize.net Create profile

I have a little problem with authorize.net and yiiframework
I need to create a customer account in authorize.net system with data from my webiste with api.
I’m using this extension https://www.yiiframework.com/extension/authorize-net-cim-yii-extension , but without success.
Share with you what I’m trying to do
ajax return is with code 500
The variable error should return error or success, but actually return nothing
thanks in advance

            $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";
}

Leave a comment