Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Customer Profile with merchantCustomerID #405

Open
xzitlou opened this issue Jan 27, 2021 · 3 comments
Open

Get Customer Profile with merchantCustomerID #405

xzitlou opened this issue Jan 27, 2021 · 3 comments

Comments

@xzitlou
Copy link

xzitlou commented Jan 27, 2021

I'm trying the API using this endpoint https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile and in the Request Field information I see that I can send merchantCustomerId, but every time I tried it always return the error Failed to get customer profile information with id None

@jdavidzapatab
Copy link

I am trying the same query using the PHP SDK, but this time it returns

{
    "messages": {
        "resultCode": "Error",
        "message": [
            {
                "code": "E00040",
                "text": "The record cannot be found."
            }
        ]
    }
}

Here is an example of the request I am making. Not sure what is wrong:

<?php
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\contract\v1\GetCustomerProfileIdsResponse;
use net\authorize\api\controller as AnetController;
use net\authorize\util\LogFactory;

// ...

$tmpFullLogFilePath = $this->generateTemporaryLogFilePath();

$logger = LogFactory::getLog(get_class($this));
$logger->setLogFile($tmpFullLogFilePath);

$merchantAuthentication = $this->getAuthenticator();

$request = new AnetAPI\GetCustomerProfileRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setMerchantCustomerId($merchantId); // <----- Use the merchantCustomerID instead of the customerProfileId
$controller = new AnetController\GetCustomerProfileController($request);

/** @var AnetAPI\GetCustomerProfileResponse $response */
$response = $controller->executeWithApiResponse($this->getEndpoint());
$result   = $this->evaluateAuthorizeNetResponse($response);

if ($result->isError()) {
    dump(file_get_contents($tmpFullLogFilePath));
    return $result;
}

The log captures the following contents:

 Wed, 26 May 2021 14:03:50 -0700 INFO : [execute] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 114) - Request Creation Begin
 Wed, 26 May 2021 14:03:50 -0700 DEBUG : [execute] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 115) - net\authorize\api\contract\v1\GetCustomerProfileRequest Object
(
    [customerProfileId:net\authorize\api\contract\v1\GetCustomerProfileRequest:private] => 
    [merchantCustomerId:net\authorize\api\contract\v1\GetCustomerProfileRequest:private] => 778156132
    [email:net\authorize\api\contract\v1\GetCustomerProfileRequest:private] => 
    [unmaskExpirationDate:net\authorize\api\contract\v1\GetCustomerProfileRequest:private] => 
    [includeIssuerInfo:net\authorize\api\contract\v1\GetCustomerProfileRequest:private] => 
    [merchantAuthentication:net\authorize\api\contract\v1\ANetApiRequestType:private] => net\authorize\api\contract\v1\MerchantAuthenticationType Object
        (
            [name:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [transactionKey:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [sessionToken:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [password:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [impersonationAuthentication:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [fingerPrint:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [clientKey:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [accessToken:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
            [mobileDeviceId:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => 
        )

    [clientId:net\authorize\api\contract\v1\ANetApiRequestType:private] => sdk-php-2.0.2
    [refId:net\authorize\api\contract\v1\ANetApiRequestType:private] => 
)

 Wed, 26 May 2021 14:03:50 -0700 INFO : [execute] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 126) - Request  Creation End
 Wed, 26 May 2021 14:03:50 -0700 INFO : [_sendRequest] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 75) -  Url: https://apitest.authorize.net/xml/v1/request.api
 Wed, 26 May 2021 14:03:50 -0700 INFO : [_sendRequest] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 77) - Request to AnetApi: 
{"getCustomerProfileRequest":{"merchantAuthentication":{"name":"xxxx","transactionKey":"xxxx"},"clientId":"sdk-php-2.0.2","merchantCustomerId":778156132}}
 Wed, 26 May 2021 14:03:50 -0700 INFO : [_sendRequest] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 89) - Sending 'XML' Request type
 Wed, 26 May 2021 14:03:50 -0700 INFO : [_sendRequest] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 94) - Sending http request via Curl
 Wed, 26 May 2021 14:03:50 -0700 INFO : [_sendRequest] (/var/www/lf/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 96) - Response from AnetApi: {"messages":{"resultCode":"Error","message":[{"code":"E00040","text":"The record cannot be found."}]}}

One of the last lines of the log shows the JSON request body. If I use that exact request body through Postman, it works:

2021-05-26 16_18_18

Thanks.

@jdavidzapatab
Copy link

Initially I thought the issue was due to the Authorize.net API having an issue when invoked through the PHP SDK. But it seems the actual issue is that,. right after creating an Authorize.net Customer record including a custom, Merchant ID, it is not possible to immediately get that customer record from Authorize.net through the API when searching by Merchant ID. It seems their service require some time (a few seconds at least) to allow this search mechanism.

@gregorysandoval
Copy link

Initially I thought the issue was due to the Authorize.net API having an issue when invoked through the PHP SDK. But it seems the actual issue is that,. right after creating an Authorize.net Customer record including a custom, Merchant ID, it is not possible to immediately get that customer record from Authorize.net through the API when searching by Merchant ID. It seems their service require some time (a few seconds at least) to allow this search mechanism.

I believe this has been a known issue for years. I recall raising it when trying to use the CreateSubscriptionFromCustomerProfile example in the SDK. If you literally insert a 2-3 second wait() in the code it will then be available. It's obviously a backend limitation they have been unable or unwilling to resolve to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants