Skip to content

Commit

Permalink
Implemented new methods in customer profile area and modified the fun…
Browse files Browse the repository at this point in the history
…ction in samplecode to remove the refID
  • Loading branch information
bhav18 committed Aug 11, 2015
1 parent 979cab5 commit 4f1e96c
Show file tree
Hide file tree
Showing 13 changed files with 381 additions and 42 deletions.
57 changes: 54 additions & 3 deletions CustomerProfiles/CreateCustomerPaymentProfile.cs
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);
}

}
}
}
94 changes: 91 additions & 3 deletions CustomerProfiles/CreateCustomerProfile.cs
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);
}

}
}
}
41 changes: 38 additions & 3 deletions CustomerProfiles/CreateCustomerProfileFromTransaction.cs
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);
}

}
}
}
50 changes: 47 additions & 3 deletions CustomerProfiles/CreateCustomerShippingAddress.cs
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);
}

}
}
}
50 changes: 47 additions & 3 deletions CustomerProfiles/DeleteCustomerPaymentProfile.cs
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);
}

}
}
}
41 changes: 38 additions & 3 deletions CustomerProfiles/DeleteCustomerProfile.cs
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);
}

}
}
}
Loading

0 comments on commit 4f1e96c

Please sign in to comment.