I have a few question
1. Phone number will not show on the token form
2. shipping address or email will not show on receipt
3. how do you do the contuine button or cancel button
Below is the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Controllers.Bases;
using System.Net;
using AuthorizeNet.Api.Contracts.V1;
using System.Security.Authentication;
/// <summary>
/// Summary description for CreditCardClass
/// </summary>
public class CreditCardClass
{
public CreditCardClass()
{
//
// TODO: Add constructor logic here
//
}
public static string CreditCardMain(decimal amount, string OrderNo, string email, string firstname, string lastname, string address, string city, string state, string Zip, string ShipFirstName, string ShipLastName, string ShipAddressIn, string ShipCity, string ShipState, string ShipZip)
{
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = "",
ItemElementName = ItemChoiceType.transactionKey,
Item = "",
};
settingType[] settings = new settingType[2];
settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Pay\"}";
settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
settings[1].settingValue = "{\"show\": false}";
var orderIn = new orderType
{
invoiceNumber = OrderNo
};
var billingAddress = new customerAddressType
{
email = email,
firstName = firstname,
lastName = lastname,
address = address,
city = city,
state = state,
zip = Zip
};
var ShipAddress = new customerAddressType
{
firstName = ShipFirstName,
lastName = ShipLastName,
address = ShipAddressIn,
city = ShipCity,
zip = ShipZip
};
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
amount = amount,
billTo = billingAddress,
order = orderIn,
shipTo = ShipAddress
};
const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
const SecurityProtocolType Tls12 = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.SecurityProtocol = Tls12;
var request = new getHostedPaymentPageRequest();
request.transactionRequest = transactionRequest;
request.hostedPaymentSettings = settings;
var controller = new getHostedPaymentPageController(request);
controller.Execute();
var response = controller.GetApiResponse();
string token = response.token;
return token;
}
}
09-14-2017 01:46 PM
To enable your requested items, the Hosted Form Paremeter Settings should be like below:
settingType[] settings = new settingType[4]; settings[0] = new settingType(); settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString(); settings[0].settingValue = "{\"text\": \"Pay\"}"; settings[1] = new settingType(); settings[1].settingName = settingNameEnum.hostedPaymentShippingAddressOptions.ToString(); settings[1].settingValue = "{\"show\": true, \"required\":true}"; settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString(); settings[2].settingValue = "{\"showEmail\": true, \"requiredEmail\":true}"; settings[3] = new settingType(); settings[3].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString(); settings[3].settingValue = "{\"showReceipt\" : true, \"url\":\"https://YOUR_SITE.com/receipt\", \"urlText\": \"Continue\", \"cancelUrl\": \"https://YOUR_SITE.com/cancel\", \"cancelUrlText\": \"Cancel\"}";
09-14-2017 04:46 PM - edited 09-14-2017 04:53 PM
Ok that helped some but there is still a few problems
The email will not show on billing address the other information will firstname, lastname but not the email
var billingAddress = new customerAddressType
{
email = email,
firstName = firstname,
lastName = lastname,
address = address,
city = city,
state = state,
zip = Zip
};
The shipaddress also is not showing on receipt
var ShipAddress = new customerAddressType
{
firstName = ShipFirstName,
lastName = ShipLastName,
address = ShipAddressIn,
city = ShipCity,
zip = ShipZip
};
below is part of the email receipt.
also when user press continue it puts it in the iframe instead of opening in new page. how can i close the iframe and return to the webpage and show the receipt.
09-15-2017 05:34 AM
settingType[] settings = new settingType[5];
settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Pay\"}";
settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();
settings[1].settingValue = "{\"show\": true, \"required\":true}";
settings[2] = new settingType();
settings[2].settingName = settingNameEnum.hostedPaymentShippingAddressOptions.ToString();
settings[2].settingValue = "{\"show\": true, \"required\":true}";
settings[3] = new settingType();
settings[3].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();
settings[3].settingValue = "{\"showEmail\": true, \"requiredEmail\":true}";
settings[4] = new settingType();
settings[4].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();
settings[4].settingValue = "{\"showReceipt\" : true, \"url\":\"https://YOUR_SITE.com/receipt\", \"urlText\": \"Continue\", \"cancelUrl\": \"https://YOUR_SITE.com/cancel\", \"cancelUrlText\": \"Cancel\"}";
Check out https://developer.authorize.net/api/reference/features/accept_hosted.html for more details.
09-15-2017 05:44 AM