09-27-2023 09:09 AM
In CreateCustomerProfileFromTransactionController class we have included the response class net\authorize\api\contract\v1\CreateCustomerProfileFromTransactionResponse. But it is not in PHP SDK latest version.
So the error showing is
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
09-27-2023 10:10 AM
The code we used is below
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;
}
10-05-2023 07:04 AM