cancel
Showing results for 
Search instead for 
Did you mean: 

GetHostedProfilePage sample code (how to call)

Hi,

 

I am not sure where the GetHostedProfilePage function call is and I'm not sure how to call it.

 

I've poured over the sample code and I see where there are a couple of samples on how to setup the HTML and JavaScript for placing the hosted CIM pages, but I have not found any source code to show how to get a valid token for placing in the 'formAuthorizeNetPopup' form.

 

To make matters worse, we have been using CIM with calls like:

 

CreateCustomerPaymentProfileResponseType createPaymentProfileResponse = SoapAPIUtilities.Service.CreateCustomerPaymentProfile
                    (SoapAPIUtilities.MerchantAuthentication, customerProfileId, customerPaymentProfileType, ValidationModeEnum.none);

But I cannot find the GetHostedProfilePage API routine...   ...it doesn't appear to be located off of the SoapAPIUtilities.Service namespace.  Used NuGet to import the AuthorizeNet package, but I'm not finding the GetHostedProfilePage routine in the object browser.

 

So, I could use some assistance in figuring out how to get the token for hosted CIM; some assistance in sorting out how to integrate with my ASP.NET MVC solution; and the calling sequence for hosted CIM.

 

Please help!

 

Thanks,
Martin

2 REPLIES 2

Okay, for where the GetHostedProfilePage call is, just update web reference (no need to add NuGet package).  The new APIs were added to the "v1" API (which is a bit confusing).

 

SoapAPIUtilities.Service.GetHostedProfilePage(SoapAPIUtilities.MerchantAuthentication, customerProfileId, hostedProfileSettings);

 Could still use some guidance, but I'm making progress at least.

 

Thanks,

Martin

I figured this out and the hosted CIM popup page is showing up.  

 

Here's the code which is currently returning the token:

 

        /// <summary>
        /// Gets the hosted profile page token.
        /// </summary>
        /// <param name="customerProfileId">The customer profile identifier.</param>
        /// <returns></returns>
        public static StatusWithData<string> GetHostedProfilePageToken(long customerProfileId)
        {
            ILog log = LogManager.GetLogger(typeof(AuthorizeNetHelper));

            try
            {
                SettingType[] settings = new SettingType[0];
                GetHostedProfilePageResponseType response = SoapAPIUtilities.Service.GetHostedProfilePage(SoapAPIUtilities.MerchantAuthentication, customerProfileId, settings);

                bool isSuccess = response != null && response.resultCode == MessageTypeEnum.Ok;
                return isSuccess
                           ? new StatusWithData<string> {Success = true, Data = response.token, Messages = new List<string>()}
                           : new StatusWithData<string> {Success = false, Messages = new List<string> {"Error: unable to retrieve hosted profile page token from auth.net"}};
            }
            catch (Exception ex)
            {
                string msg = string.Format("Error: unhandled exception in AuthorizeNetHelper.GetHostedProfilePageToken.  {0}", ex.Message);
                log.Error(msg, ex);
                return new StatusWithData<string> {Success = false, Messages = new List<string> {msg}};
            }
        }

 I utilized the "CIM - hosted popu..." sample to determine how to integrate the JavaScript, etc. into my ASP.NET MVC application (Auth.net sample code).

 

The only part that I still need to solve is more seemlessly integrating this into my web site and how to eliminate the address information, since at this point the client only wants to store the cardholder data on auth.net.  I am hoping that the hosted CIM page code is flexible enough to let me control some of the client presentation (UX).

 

If anyone has some pointers on how to display the hosted CIM page as an embeded asset instead of a pop up, please reply to this message thread.

 

Thanks,

Martin