forked from AuthorizeNet/sample-code-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented new methods in customer profile area and modified the fun…
…ction in samplecode to remove the refID
- Loading branch information
Showing
13 changed files
with
381 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class CreateCustomerPaymentProfile | ||
{ | ||
public static void Run(String ApiLoginID, String ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerPaymentProfile Sample"); | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
var bankAccount = new bankAccountType | ||
{ | ||
accountNumber = "0123454321", | ||
routingNumber = "000000204", | ||
accountType = bankAccountTypeEnum.checking, | ||
echeckType = echeckTypeEnum.WEB, | ||
nameOnAccount = "test", | ||
bankName = "Bank Of America" | ||
}; | ||
|
||
paymentType echeck = new paymentType {Item = bankAccount}; | ||
customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType(); | ||
echeckPaymentProfile.payment = echeck; | ||
|
||
var request = new createCustomerPaymentProfileRequest | ||
{ | ||
customerProfileId = "36537239", | ||
paymentProfile = echeckPaymentProfile, | ||
validationMode = validationModeEnum.none | ||
}; | ||
|
||
//Prepare Request | ||
var controller = new createCustomerPaymentProfileController(request); | ||
controller.Execute(); | ||
|
||
//Send Request to EndPoint | ||
createCustomerPaymentProfileResponse response = controller.GetApiResponse(); | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, CustomerProfileID : " + response.customerPaymentProfileId); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class CreateCustomerProfile | ||
{ | ||
public static void Run(string ApiLoginID, string ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerProfile Sample"); | ||
|
||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
|
||
var creditCard = new creditCardType | ||
{ | ||
cardNumber = "4111111111111111", | ||
expirationDate = "0718" | ||
}; | ||
|
||
var bankAccount = new bankAccountType | ||
{ | ||
accountNumber = "0123454321", | ||
routingNumber = "000000204", | ||
accountType = bankAccountTypeEnum.checking, | ||
echeckType = echeckTypeEnum.WEB, | ||
nameOnAccount = "test", | ||
bankName = "Bank Of America" | ||
}; | ||
|
||
//standard api call to retrieve response | ||
paymentType cc = new paymentType { Item = creditCard }; | ||
paymentType echeck = new paymentType {Item = bankAccount}; | ||
|
||
List<customerPaymentProfileType> paymentProfileList = new List<customerPaymentProfileType>(); | ||
customerPaymentProfileType ccPaymentProfile = new customerPaymentProfileType(); | ||
ccPaymentProfile.payment = cc; | ||
|
||
customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType(); | ||
echeckPaymentProfile.payment = echeck; | ||
|
||
paymentProfileList.Add(ccPaymentProfile); | ||
paymentProfileList.Add(echeckPaymentProfile); | ||
|
||
List<customerAddressType> addressInfoList = new List<customerAddressType>(); | ||
customerAddressType homeAddress = new customerAddressType(); | ||
homeAddress.address = "10900 NE 8th St"; | ||
homeAddress.city = "Seattle"; | ||
homeAddress.zip = "98006"; | ||
|
||
|
||
customerAddressType officeAddress = new customerAddressType(); | ||
officeAddress.address = "1200 148th AVE NE"; | ||
officeAddress.city = "NorthBend"; | ||
officeAddress.zip = "92101"; | ||
|
||
addressInfoList.Add(homeAddress); | ||
addressInfoList.Add(officeAddress); | ||
|
||
|
||
customerProfileType customerProfile = new customerProfileType(); | ||
customerProfile.merchantCustomerId = "Test CustomerID"; | ||
customerProfile.email = "[email protected]"; | ||
customerProfile.paymentProfiles = paymentProfileList.ToArray(); | ||
customerProfile.shipToList = addressInfoList.ToArray(); | ||
|
||
var request = new createCustomerProfileRequest{ profile = customerProfile, validationMode = validationModeEnum.none}; | ||
|
||
var controller = new createCustomerProfileController(request); // instantiate the contoller that will call the service | ||
controller.Execute(); | ||
|
||
createCustomerProfileResponse response = controller.GetApiResponse(); // get the response from the service (errors contained if any) | ||
|
||
//validate | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, CustomerProfileID : " + response.customerProfileId); | ||
Console.WriteLine("Success, CustomerPaymentProfileID : " + response.customerPaymentProfileIdList[0]); | ||
Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class CreateCustomerProfileFromTransaction | ||
{ | ||
public static void Run(string ApiLoginID, string ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerProfile Sample"); | ||
|
||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
var request = new createCustomerProfileFromTransactionRequest { transId = "2238147175" }; | ||
|
||
var controller = new createCustomerProfileFromTransactionController(request); | ||
controller.Execute(); | ||
|
||
createCustomerProfileResponse response = controller.GetApiResponse(); | ||
|
||
//validate | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, CustomerProfileID : " + response.customerProfileId); | ||
Console.WriteLine("Success, CustomerPaymentProfileID : " + response.customerPaymentProfileIdList[0]); | ||
Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class CreateCustomerShippingAddress | ||
{ | ||
public static void Run(String ApiLoginID, String ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerShippingAddress Sample"); | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
customerAddressType officeAddress = new customerAddressType(); | ||
officeAddress.firstName = "Chris"; | ||
officeAddress.lastName = "brown"; | ||
officeAddress.address = "1200 148th AVE NE"; | ||
officeAddress.city = "NorthBend"; | ||
officeAddress.zip = "92101"; | ||
|
||
|
||
var request = new createCustomerShippingAddressRequest | ||
{ | ||
customerProfileId = "36537239", | ||
address = officeAddress, | ||
}; | ||
|
||
//Prepare Request | ||
var controller = new createCustomerShippingAddressController(request); | ||
controller.Execute(); | ||
|
||
//Send Request to EndPoint | ||
createCustomerShippingAddressResponse response = controller.GetApiResponse(); | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, customerAddressId : " + response.customerAddressId); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class DeleteCustomerPaymentProfile | ||
{ | ||
public static void Run(String ApiLoginID, String ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerShippingAddress Sample"); | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
customerAddressType officeAddress = new customerAddressType(); | ||
officeAddress.firstName = "Chris"; | ||
officeAddress.lastName = "brown"; | ||
officeAddress.address = "1200 148th AVE NE"; | ||
officeAddress.city = "NorthBend"; | ||
officeAddress.zip = "92101"; | ||
|
||
|
||
var request = new createCustomerShippingAddressRequest | ||
{ | ||
customerProfileId = "36537239", | ||
address = officeAddress, | ||
}; | ||
|
||
//Prepare Request | ||
var controller = new createCustomerShippingAddressController(request); | ||
controller.Execute(); | ||
|
||
//Send Request to EndPoint | ||
createCustomerShippingAddressResponse response = controller.GetApiResponse(); | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, customerAddressId : " + response.customerAddressId); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AuthorizeNet.Api.Controllers; | ||
using AuthorizeNet.Api.Contracts.V1; | ||
using AuthorizeNet.Api.Controllers.Bases; | ||
|
||
namespace net.authorize.sample | ||
{ | ||
class DeleteCustomerProfile | ||
{ | ||
public static void Run(String ApiLoginID, String ApiTransactionKey) | ||
{ | ||
Console.WriteLine("CreateCustomerShippingAddress Sample"); | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; | ||
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() | ||
{ | ||
name = ApiLoginID, | ||
ItemElementName = ItemChoiceType.transactionKey, | ||
Item = ApiTransactionKey, | ||
}; | ||
|
||
var request = new deleteCustomerProfileRequest | ||
{ | ||
customerProfileId = "36537239" | ||
}; | ||
|
||
//Prepare Request | ||
var controller = new deleteCustomerProfileController(request); | ||
controller.Execute(); | ||
|
||
//Send Request to EndPoint | ||
deleteCustomerProfileResponse response = controller.GetApiResponse(); | ||
if (response != null && response.messages.resultCode == messageTypeEnum.Ok) | ||
{ | ||
if (response != null && response.messages.message != null) | ||
{ | ||
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.