Skip to content

Commit

Permalink
Merge pull request #15 from hpreslier/master
Browse files Browse the repository at this point in the history
Thanks Heather, all the very best of luck for next year.   Thanks again for all the code :-)
  • Loading branch information
brianmc committed Aug 16, 2015
2 parents b911986 + 78c64a9 commit c82ebd1
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CustomerProfiles/CreateCustomerProfileFromTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CreateCustomerProfileFromTransaction
{
public static void Run(string ApiLoginID, string ApiTransactionKey)
{
Console.WriteLine("CreateCustomerProfile Sample");
Console.WriteLine("CreateCustomerProfileFromTransaction Sample");

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
Expand Down
2 changes: 1 addition & 1 deletion CustomerProfiles/DeleteCustomerPaymentProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DeleteCustomerPaymentProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("CreateCustomerShippingAddress Sample");
Console.WriteLine("DeleteCustomerPaymentProfile Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
Expand Down
2 changes: 1 addition & 1 deletion CustomerProfiles/DeleteCustomerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DeleteCustomerProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("CreateCustomerShippingAddress Sample");
Console.WriteLine("DeleteCustomerProfile Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
Expand Down
65 changes: 65 additions & 0 deletions CustomerProfiles/UpdateCustomerPaymentProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,75 @@
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
{
class UpdateCustomerPaymentProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Update Customer payment 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 creditCard = new creditCardType
{
cardNumber = "4111111111111111",
expirationDate = "0718"
};

var paymentType = new paymentType { Item = creditCard };

var paymentProfile = new customerPaymentProfileExType
{
billTo = new customerAddressType
{
// change information as required for billing
firstName = "John",
lastName = "Doe",
address = "123 Main St.",
city = "Bellevue",
state = "WA",
zip = "98004",
country = "USA",
phoneNumber = "000-000-000",
},
payment = paymentType,
customerPaymentProfileId = "33093910"
};

var request = new updateCustomerPaymentProfileRequest();
request.customerProfileId = "36605093";
request.paymentProfile = paymentProfile;
request.validationMode = validationModeEnum.liveMode;


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

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

if (response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
}
}
}
44 changes: 44 additions & 0 deletions CustomerProfiles/UpdateCustomerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,54 @@
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
{
class UpdateCustomerProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Update 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 profile = new customerProfileExType
{
merchantCustomerId = "custId123",
description = "some description",
email = "[email protected]",
customerProfileId = "36605093"
};

var request = new updateCustomerProfileRequest();
request.profile = profile;

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

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

if (response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
}
}
}
59 changes: 59 additions & 0 deletions CustomerProfiles/UpdateCustomerShippingAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,69 @@
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
{
class UpdateCustomerShippingAddress
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Update customer shipping address 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 creditCard = new creditCardType
{
cardNumber = "4111111111111111",
expirationDate = "0718"
};

var paymentType = new paymentType { Item = creditCard };

var address = new customerAddressExType
{
firstName = "Newfirstname",
lastName = "Doe",
address = "123 Main St.",
city = "Bellevue",
state = "WA",
zip = "98004",
country = "USA",
phoneNumber = "000-000-000",
customerAddressId = "34750930"
};

var request = new updateCustomerShippingAddressRequest();
request.customerProfileId = "36605093";
request.address = address;


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

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

if (response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
}
}
}
39 changes: 39 additions & 0 deletions CustomerProfiles/ValidateCustomerPaymentProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,49 @@
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
{
class ValidateCustomerPaymentProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Validate customer payment 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 validateCustomerPaymentProfileRequest();
request.customerProfileId = "36594444";
request.customerPaymentProfileId = "33084787";
request.validationMode = validationModeEnum.liveMode;


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

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

if (response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
}
}
}
16 changes: 16 additions & 0 deletions SampleCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ private static void SelectMethod()

private static void ShowMethods()
{
Console.WriteLine(" ValidateCustomerPaymentProfile");
Console.WriteLine(" UpdateCustomerShippingAddress");
Console.WriteLine(" UpdateCustomerProfile");
Console.WriteLine(" UpdateCustomerPaymentProfile");
Console.WriteLine(" GetCustomerShippingAddress");
Console.WriteLine(" GetCustomerProfileId");
Console.WriteLine(" GetCustomerProfile");
Expand Down Expand Up @@ -118,6 +122,18 @@ private static void RunMethod(String methodName)

switch (methodName)
{
case "ValidateCustomerPaymentProfile":
ValidateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
break;
case "UpdateCustomerShippingAddress":
UpdateCustomerShippingAddress.Run(apiLoginId, transactionKey);
break;
case "UpdateCustomerProfile":
UpdateCustomerProfile.Run(apiLoginId, transactionKey);
break;
case "UpdateCustomerPaymentProfile":
UpdateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
break;
case "GetCustomerShippingAddress":
GetCustomerShippingAddress.Run(apiLoginId, transactionKey);
break;
Expand Down
Binary file modified SampleCode.exe
Binary file not shown.

0 comments on commit c82ebd1

Please sign in to comment.