cancel
Showing results for 
Search instead for 
Did you mean: 

CIM - GetHostedProfilePage

The authnet .NET SDKs do not have any examples of the GetHostedProfilePage API call. I'm having trouble building this from scratch because I'm working directly with the soap proxy in VS. Does anyone have a working example of how to call GetHostedProfilePage from within the Visual Studio .NET SDK?

 

So far this is what I've strung together, but it's not working at all:

 

public string GetHostedProfilePage(string apiLogin, string transactionKey, string customerProfileID)
        {
            AuthNetAPITest.MerchantAuthenticationType merchant = new AuthNetAPITest.MerchantAuthenticationType();
            merchant.name = apiLogin;
            merchant.transactionKey = transactionKey;
            AuthNetAPITest.GetHostedProfilePageRequest request = new AuthNetAPITest.GetHostedProfilePageRequest(merchant, long.Parse(customerProfileID), null);
            
            AuthNetAPITest.GetHostedProfilePageResponseType responseType = new AuthNetAPITest.GetHostedProfilePageResponseType();
            AuthNetAPITest.GetHostedProfilePageResponse response = new AuthNetAPITest.GetHostedProfilePageResponse(responseType);


            string token = response.GetHostedProfilePageResult.token;
            var resultCode = responseType.resultCode;
            return token;
        }

 I don't get any errors, I just get back null for all the response object properties. Please help. Thanks!

ZeroGravPro
Contributor
2 ACCEPTED SOLUTIONS

Accepted Solutions

Not sure why the example 1 didn't work, It based on the updated web reference from the c# sample code from http://developer.authorize.net/downloads/samplecode/ .

example 2 was based on how SDKs usually call a web service, I through that what you are trying to do.

 

This is using "service reference" not the web reference on vs2010. Basically the same as example 1, except it call ServiceSoapClient to create the object. If this still don't work for you, don't know what else to do cause both 1 and this work for me.

public string GetHostedProfilePage(string apiLogin, string transactionKey, string customerProfileID)
	{
		AuthNetAPITest.MerchantAuthenticationType merchant = new AuthNetAPITest.MerchantAuthenticationType();
		merchant.name = apiLogin;
		merchant.transactionKey = transactionKey;

		AuthNetAPITest.ServiceSoapClient _ssc = new AuthNetAPITest.ServiceSoapClient();
		AuthNetAPITest.GetHostedProfilePageResponseType responseType = _ssc.GetHostedProfilePage(merchant, long.Parse(customerProfileID), null);

		string token = responseType.token;
		var resultCode = responseType.resultCode;
		return token;
	}

 

 

View solution in original post

RaynorC1emen7
Expert

In the provided popup.js I believe this line has to be uncommented: AuthorizeNetPopup.options.useTestEnvironment=true;

 

 

View solution in original post

9 REPLIES 9
CustomerProfileWS.Service service = new CustomerProfileWS.Service();
			service.Url = "https://apitest.authorize.net/soap/v1/Service.asmx";

			CustomerProfileWS.MerchantAuthenticationType auth = new CustomerProfileWS.MerchantAuthenticationType();
			auth.name = YOUR_ID;
			auth.transactionKey = YOUR_KEY;

			CustomerProfileWS.GetHostedProfilePageResponseType resp = service.GetHostedProfilePage(auth, custProfId, null);

			if (resp.resultCode == CustomerProfileWS.MessageTypeEnum.Ok)
			{
				return resp.token;
			}
			else
			{
				foreach (CustomerProfileWS.MessagesTypeMessage message in resp.messages)
					System.Diagnostics.Debug.WriteLine(string.Format("[Code: {0}] {1}", message.code, message.text));
			}
			return string.Empty;

It based on the C# CIM sample code with updated web reference.

RaynorC1emen7
Expert

If you are using the SDK,

It usually is something like

var response = (GetHostedProfilePageResponse)_gateway.Send(request);

 

Thanks for your posts, but neither are helpful. Your 1st post was essentially a copy of what I already posted, that doesn't work, except that you changed the name of the proxy object. Your 2nd post is not valid because it won't compile. The GetHostedProfilePageResponse class does not exist in the SDK. It does exist in the proxy web service call, but this is an invalid cast with _gateway.

 

I don't wish to sound mean, but it seems you posted these 2 comments without carefully reading the problem, and the posts were not helpful. I can tell you're knowledgeable about this stuff and I would loving getting a bit more help.

 

Could you please either:

1- post a working code sample that actually works with the .NET SDK

or

2- give me a working example of ANY api call that calls authnet web service - if I can see how to sort out the xxxResponse and xxxRequest calls, that would be great.

 

Thanks!!

I looked around and couldn't find an API example for the PHP API, which is what I used. Apparently it's well-hidden. But here's XML, you could theoretically just pass that and parse the result if all else fails:

 

Send:

<?xml version="1.0" encoding="utf-8"?> 
<getHostedProfilePageRequest 
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> 
  <merchantAuthentication> 
    <name>YourUserLogin</name> 
    <transactionKey>YourTranKey</transactionKey> 
  </merchantAuthentication> 
  <customerProfileId>YourProfileID</customerProfileId> 
  <hostedProfileSettings> 
    <setting> 
      <settingName>hostedProfileReturnUrl</settingName> 
      <settingValue>https://blah.com/blah/</settingValue> 
    </setting> 
    <setting> 
      <settingName>hostedProfileReturnUrlText</settingName> 
      <settingValue>Continue to blah.</settingValue> 
    </setting> 
    <setting> 
      <settingName>hostedProfilePageBorderVisible</settingName> 
      <settingValue>true</settingValue> 
    </setting> 
 </hostedProfileSettings> 
</getHostedProfilePageRequest> 

 Response:

<?xml version="1.0" encoding="utf-8"?> 
<getHostedProfilePageResponse 
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> 
  <messages> 
    <resultCode>Ok</resultCode> 
    <message> 
      <code>I00001</code> 
      <text>Successful.</text> 
    </message> 
  </messages> <token>+ZeWDaUOPoQPRGTHcKd7DYbMfcAFDrhO8GPOFNt+ACzJnvkz+aWO0SYSAA9x602jAI 
KKfUHUt2ybwQRaG8LzHluuR5dRgsuh+kjarKvD0hpieGjLHmnz0LHmFv1Xe9P3zpmawqBCSB/ 
d4jcSg9dAxecNBUzMwIuYzY+vGUGLUXgr9QPaRh93HqWZrV4Mbwop</token>
</getHostedProfilePageResponse> 

 This is from the CIM XML guide, incidently.

http://www.authorize.net/support/CIM_XML_guide.pdf

Not sure why the example 1 didn't work, It based on the updated web reference from the c# sample code from http://developer.authorize.net/downloads/samplecode/ .

example 2 was based on how SDKs usually call a web service, I through that what you are trying to do.

 

This is using "service reference" not the web reference on vs2010. Basically the same as example 1, except it call ServiceSoapClient to create the object. If this still don't work for you, don't know what else to do cause both 1 and this work for me.

public string GetHostedProfilePage(string apiLogin, string transactionKey, string customerProfileID)
	{
		AuthNetAPITest.MerchantAuthenticationType merchant = new AuthNetAPITest.MerchantAuthenticationType();
		merchant.name = apiLogin;
		merchant.transactionKey = transactionKey;

		AuthNetAPITest.ServiceSoapClient _ssc = new AuthNetAPITest.ServiceSoapClient();
		AuthNetAPITest.GetHostedProfilePageResponseType responseType = _ssc.GetHostedProfilePage(merchant, long.Parse(customerProfileID), null);

		string token = responseType.token;
		var resultCode = responseType.resultCode;
		return token;
	}

 

 

RaynorC1emen7
Expert

Raynor,

 

Thank you!! That did the trick. I've got this working great...but now when I try to load the lightbox with the hosted page I keep getting the error "Customer Information Manager is not enabled.". Some google searches on this revealed that this is a very common problem. Do you know what I'm doing wrong? It seems to me that CIM is enabled in my sandbox (else how could I successfully create CIM customers??). I checked all my settings, everything seems right. But I must be missing something.

 

I'm posting to this test URL: https://test.authorize.net/hosted/profile/manage

 

Please help.

Sandbox accounts come with almost everything, while production accounts need CIM turned on for it to work, since there's an additional monthly fee involved. If I remember correctly, you set that up by going into your account to Account -> User Profile and then maybe Edit Profile Information.

 

EDIT: I'm sure you know that the production account will not work through the test URL, right?

In the provided popup.js I believe this line has to be uncommented: AuthorizeNetPopup.options.useTestEnvironment=true;

 

 

nic73,

 

You're right! That did the trick and now I'm in business. Thanks so much.