-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathGetCustomerProfile.cs
53 lines (44 loc) · 1.92 KB
/
GetCustomerProfile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Controllers.Bases;
namespace net.authorize.sample
{
public class GetCustomerProfile
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
{
Console.WriteLine("Get Customer Profile sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var request = new getCustomerProfileRequest();
request.customerProfileId = customerProfileId;
// instantiate the controller that will call the service
var controller = new getCustomerProfileController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
Console.WriteLine("Customer Profile Id: " + response.profile.customerProfileId);
}
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
return response;
}
}
}