Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more samples and update some console messages #15

Merged
merged 1 commit into from
Aug 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.