cancel
Showing results for 
Search instead for 
Did you mean: 

redirect the user back to your site

How do i redirect the user atfter entering there credit card information redircet theuser back to my site. I am using a iframe below is the code class

 

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[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\":false}";

settings[3] = new settingType();

settings[3].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();

settings[3].settingValue = "{\"showEmail\": true, \"requiredEmail\":false}";

settings[4] = new settingType();

settings[4].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();

settings[4].settingValue = "{\"showReceipt\" : true, \"url\":\"http://www.marshallville-meats.com/test/checkoutfinal.aspx\", \"urlText\": \"Continue\", \"cancelUrl\": \"http://www.marshallville-meats.com/test\", \"cancelUrlText\": \"Cancel\"}";

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 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;

}

}

 

rrr944276
Contributor
1 REPLY 1

i found at https://developer.authorize.net/api/reference/features/accept_hosted.html that i need hostedpaymentiframecommunicatorurl  i made the page from the sample listed than added the following: I this correct code or am i missing something i need to get this to work to get the site working. or if anyone has code that works that i can see in ap.net

 

settingType[] settings = new settingType[6];

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\":false}";

settings[3] = new settingType();

settings[3].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();

settings[3].settingValue = "{\"showEmail\": true, \"requiredEmail\":false}";

settings[4] = new settingType();

settings[4].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();

settings[4].settingValue = "{\"url\":\"http://www.marshallville-meats.com/IframeCommunicator.html\"}";

settings[5] = new settingType();

settings[5].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();

settings[5].settingValue = "{\"showReceipt\" : true, \"url\":\"https://www.marshallville-meats.com/CheckOutFinal.aspx\", \"urlText\": \"Continue\", \"cancelUrl\": \"https://YOUR_SITE.com/cancel\", \"cancelUrlText\": \"Cancel\"}";

 

rrr944276
Contributor