Reply
Member
Posts: 7
Registered: ‎12-12-2018

Accept Hosted - Prepopulate email and phone

Hi all, I am integrating accepted hosted to my page, and am using the below code, things work great, the email and phone do not carry through to the auth.net popup though. Has anyone else had this issue? 

 

 

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;




ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = moduleSettings["ApiLoginID"].ToString(),
ItemElementName = ItemChoiceType.transactionKey,
Item = moduleSettings["ApiTransactionKey"].ToString(),
};

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;




settingType[] settings = new settingType[10];

settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Submit Gift\"}";

settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
settings[1].settingValue = "{\"show\": false}";

settings[2] = new settingType();
settings[2].settingName = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();
settings[2].settingValue = "{\"show\": true}";

settings[3] = new settingType(); 
settings[3].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();
settings[3].settingValue = "{\"showReceipt\": false}";settings[4] = new settingType();

settings[4].settingName = settingNameEnum.hostedPaymentPaymentOptions.ToString();
settings[4].settingValue = "{\"cardCodeRequired\": true, \"showCreditCard\": true, \"showBankAccount\": false}";

settings[5] = new settingType();
settings[5].settingName = settingNameEnum.hostedPaymentSecurityOptions.ToString();
settings[5].settingValue = "{\"captcha\": true}";

settings[6] = new settingType();
settings[6].settingName = settingNameEnum.hostedPaymentStyleOptions.ToString(); 
settings[6].settingValue = "{\"bgColor\": \"#0f175e\"}";

settings[7] = new settingType();
settings[7].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();
settings[7].settingValue = "{\"url\": \"" + System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Scheme) + System.Web.HttpContext.Current.Request.Url.Host + "/xxx/hosted.html\"}";settings[8] = new settingType();

settings[8].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();
settings[8].settingValue = "{\"showEmail\": true}";



var billTo = new customerAddressType();
billTo.firstName = firstName;
billTo.lastName = lastName;
billTo.country = country;
billTo.zip = zip;
billTo.address = address;
billTo.city = city;
billTo.state = state;
billTo.email = email;

if (phoneNumber != "null") billTo.phoneNumber = phoneNumber;


var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), 
amount = amount,
billTo = billTo
};



var request = new getHostedPaymentPageRequest();
request.transactionRequest = transactionRequest;
request.hostedPaymentSettings = settings;

// instantiate the controller that will call the service
var controller = new getHostedPaymentPageController(request); 
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();

I can create the customer separately through the createCustomerProfileRequest, I just don't know how to tie it into this when a payment is made. I was told to do it in the transactionRequestType object by setting the customer object in there but it doesn't work for me, the request comes back as a success, but then the call to the payment url for Authorize.NET popup comes back with a 404 so nothing is displayed (https://test.authorize.net/payment/payment?token=...). Leaving it as shown above shoes the email and phone fields just not populated like the other fields. Any help would be so greatly appreciated.  

 

Trusted Contributor
Posts: 411
Registered: ‎11-05-2018

Re: Accept Hosted - Prepopulate email and phone

@marco_envision

You pass those under a CustomerDataType object.
Member
Posts: 7
Registered: ‎12-12-2018

Re: Accept Hosted - Prepopulate email and phone

Hi, thank you for the response!

 

I did and nothing works, it throws a 404 when loading the popup if I try doing either of the below:

 

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only
                amount = amount,
                billTo = billTo,
                //customer = new customerDataType()
                //customer = new customerDataType() { id = _merchantCustomerId, email = billTo.email, type = customerTypeEnum.individual }
            };

Any ideas?

 

Many thanks,

 

Marco

 

Member
Posts: 7
Registered: ‎12-12-2018

Re: Accept Hosted - Prepopulate email and phone

I also just tried sending the customer object in only with the email as I've seen instructed, if I pass the customer object at all through, the auth.net popup iframe throws a 404 every time. But the initial handshake returns a success. 

Highlighted
Trusted Contributor
Posts: 411
Registered: ‎11-05-2018

Re: Accept Hosted - Prepopulate email and phone

[ Edited ]

@marco_envision 

 

 

  var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only
                amount = amount,
                billTo = billTo,
                //customer = new customerDataType()
                //customer = new customerDataType() { id = _merchantCustomerId, email = billTo.email, type = customerTypeEnum.individual }
            };

Try defining the customer outside of the transactionRequestType object. In the above code you have the customer commented out, so I can imagine it throwing an error. What I type below won't be correct syntax, but will give you an idea.

 

 

var billTo = new customerAddressType();
billTo.firstName = firstName;
billTo.lastName = lastName;
billTo.country = country;
billTo.zip = zip;
billTo.address = address;
billTo.city = city;
billTo.state = state;
billTo.email = email;

var customer = new customerDataType();
customer.email = email;
//corrected customer object

if (phoneNumber != "null") customer.phoneNumber = phoneNumber;


var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), 
amount = amount,
billTo = billTo,
customer = customer
};

 

 

 

Member
Posts: 7
Registered: ‎12-12-2018

Re: Accept Hosted - Prepopulate email and phone

HI, yes I had commented it out, I was merely showing you the things I've tried. I've also tried creating a customer object and passing it in, as you mentioned, with no success. I'm at a loss why the object is there to be sent but does not work in any case when passed in. Has anyone been able to pass a customerDataType object to a transactionRequestType object? I would be so grateful for any assistance.

 

- Marco

Trusted Contributor
Posts: 411
Registered: ‎11-05-2018

Re: Accept Hosted - Prepopulate email and phone

@marco_envision 

 

I have passed it no problem on 3 separate web applications, at least 100 times. Did you try the code I posted? I think that should work, although you might have to make syntax changes.