In the authorize.net PHP SDK library 'CreateCustomerProfileFromTransactionController' class showing an error.
It is included a response class ‘CreateCustomerProfileFromTransactionResponse’.
But it is not in this library. If you download the latest version of PHP SDK from git
You could not see this class.
The path where the class should present is ‘net\\authorize\\api\\contract\\v1\\CreateCustomerProfileFromTransactionResponse’.
Please see my code for creating a customer profile from transaction id.
function createCustomerProfile($transactionId) {
$this->paymentLog($transactionId, 'Webhook Response - Visited 1 - 9: ', 3, '', "Response : ");
$PaymentConfig = get_payment_config(null);
$merchantAuthentication = new AnetAPI\\MerchantAuthenticationType();
$merchantAuthentication->setName($PaymentConfig['anet_api_login_id']);
$merchantAuthentication->setTransactionKey($PaymentConfig['anet_translation_key']);
//$customerProfile = new AnetAPI\\CustomerProfileType();
$customerProfile = new AnetAPI\\CustomerProfileBaseType();
//$customerProfile->setMerchantCustomerId("123212");
//$customerProfile->setEmail(rand(0, 10000) . "@Test" .".com");
//$customerProfile->setDescription(rand(0, 10000) ."sample description");
$customerProfile->setDescription('Transaction:'.$transactionId);
//$request = new AnetAPI\\CreateCustomerProfileRequest();
//$request->setMerchantAuthentication($merchantAuthentication);
//$request->setProfile($customerProfile);
$request = new AnetAPI\\CreateCustomerProfileFromTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransId($transactionId);
$request->setCustomer($customerProfile);
//$controller = new AnetController\\CreateCustomerProfileController($request);
$controller = new AnetController\\CreateCustomerProfileFromTransactionController($request);
$controller->executeWithApiResponse(\\net\\authorize\\api\\constants\\ANetEnvironment::SANDBOX);
$this->paymentLog($transactionId, 'Webhook Response - Visited after controller 2 - 9: ', 14, '', "Response : ".json_encode($response));
if ($response != null && $response->getMessages()->getResultCode() == "Ok") {
$customerProfileId = $response->getCustomerProfileId();
$this->paymentLog($transactionId, 'Webhook Response - Visited 3 - 9: profile Id:'.$customerProfileId, 16, '', "Response : ");
} else {
// Handle customer profile creation errors
$customerProfileId = 0;
//$errorMessages = $response->getMessages()->getMessage();
$this->paymentLog($transactionId, 'Webhook Response - Visited 1 - 9: profile ID'.$customerProfileId, 16, '', "Response : ");
} return $customerProfileId;
}
I used the Authorize.net API
But because of the above pointed issue, it showing the below error
Throwable - : Class "net\\authorize\\api\\contract\\v1\\CreateCustomerProfileFromTransactionResponse" not found on File /var/www/html/web/application/libraries/sdk-php-master/lib/net/authorize/api/controller/base/ApiOperationBase.php at Line no. 150
If anybody faced this issue and solved , Please help
10-05-2023 11:25 PM
It looks like you are encountering an issue with the Authorize.net PHP SDK library, specifically related to the CreateCustomerProfileFromTransactionResponse class not being present in the library. This could be due to changes or updates in the library since your last update.
To address this issue professionally, here are some steps you can take to resolve it:
Update the SDK: The first step is to make sure you are using the latest version of the Authorize.net PHP SDK. You mentioned that you downloaded it from Git, so ensure that you have the most recent version.
You can update the SDK by running:
This command will update the SDK to the latest version using Composer.
Check SDK Documentation: After updating the SDK, check the official documentation for any changes or updates related to the CreateCustomerProfileFromTransactionResponse class or the method you are using. Make sure you are using the correct class and method names.
Documentation: Authorize.net PHP SDK
Verify Namespace: Ensure that the namespace for the CreateCustomerProfileFromTransactionResponse class is correct. You mentioned it should be in net\\authorize\\api\\contract\\v1\\, so double-check that the class is in the correct namespace in the updated SDK.
Use Appropriate Classes and Methods: Update your code to use the correct classes and methods based on the updated SDK. You may need to make changes to your code to match the new SDK structure.
Error Handling: Implement proper error handling in your code. In case the class or method is not found or there are other errors, handle them gracefully and log detailed error messages for debugging purposes.
Testing: After making the necessary changes, thoroughly test your code to ensure it works as expected. Test different scenarios, including success and error cases.
Community Support: Check if there are any community forums, GitHub issues, or support channels related to the Authorize.net PHP SDK. Others may have faced similar issues and can provide guidance or solutions.
Contact Authorize.net Support: If you are unable to resolve the issue on your own, consider reaching out to Authorize.net support for assistance. They may be able to provide specific guidance or updates regarding the SDK.
By following these steps, you should be able to resolve the issue with the Authorize.net PHP SDK and create customer profiles from transaction IDs successfully. At the end make sure that the Internet Packages you have using must be a good speed.
10-07-2023 11:53 PM