|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using AuthorizeNet.Api.Contracts.V1; |
| 7 | +using AuthorizeNet.Api.Controllers.Bases; |
| 8 | +using AuthorizeNet.Api.Controllers; |
| 9 | + |
| 10 | +namespace net.authorize.sample |
| 11 | +{ |
| 12 | + public class GetAcceptCustomerProfilePage |
| 13 | + { |
| 14 | + public static ANetApiResponse Run(string ApiLoginId, string ApiTransactionKey, string customerProfileId) |
| 15 | + { |
| 16 | + Console.WriteLine("Get Accept Customer Profile Page sample"); |
| 17 | + |
| 18 | + ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; |
| 19 | + // define the merchant information (authentication / transaction id) |
| 20 | + ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() |
| 21 | + { |
| 22 | + name = ApiLoginId, |
| 23 | + ItemElementName = ItemChoiceType.transactionKey, |
| 24 | + Item = ApiTransactionKey, |
| 25 | + }; |
| 26 | + |
| 27 | + settingType[] settings = new settingType[]{ |
| 28 | + new settingType() |
| 29 | + // More settings can be added here as and when required |
| 30 | + }; |
| 31 | + settings[0] = new settingType(); |
| 32 | + settings[0].settingName = settingNameEnum.hostedProfileReturnUrl.ToString(); |
| 33 | + settings[0].settingValue = "https://returnurl.com/return/"; |
| 34 | + |
| 35 | + |
| 36 | + var request = new getHostedProfilePageRequest(); |
| 37 | + request.customerProfileId = customerProfileId; |
| 38 | + request.hostedProfileSettings = settings; |
| 39 | + |
| 40 | + var controller = new getHostedProfilePageController(request); |
| 41 | + controller.Execute(); |
| 42 | + |
| 43 | + var response = controller.GetApiResponse(); |
| 44 | + |
| 45 | + if (response != null && response.messages.resultCode == messageTypeEnum.Ok) |
| 46 | + { |
| 47 | + Console.WriteLine(response.messages.message[0].code); |
| 48 | + Console.WriteLine(response.messages.message[0].text); |
| 49 | + Console.WriteLine("Token: " + response.token.ToString()); |
| 50 | + } |
| 51 | + else if(response != null) |
| 52 | + { |
| 53 | + Console.WriteLine("Error: " + response.messages.message[0].code + " " + |
| 54 | + response.messages.message[0].text); |
| 55 | + } |
| 56 | + |
| 57 | + return response; |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments