Example #1
0
        public ActionResult GetProfileByName(Customer customer)
        {
            string apiLoginId        = WebConfigurationManager.AppSettings["ApiLoginID"];
            string apiTransactionKey = WebConfigurationManager.AppSettings["ApiTransactionKey"];

            string profileId = "";

            var profileIds = GetCustomerProfileIds.Run(apiLoginId, apiTransactionKey);

            foreach (var id in profileIds)
            {
                var profiles = GetCustomerProfile.Run(apiLoginId, apiTransactionKey, id);
                for (int i = 0; i < profiles.Length; i++)
                {
                    if (profiles[i].FirstName == customer.FirstName && profiles[i].LastName == customer.LastName &&
                        profiles[i].Email == customer.Email)
                    {
                        profileId = profiles[i].ProfileId;
                    }
                }
            }
            decimal totalAmnt = 0;

            if (profileId.IsNullOrWhiteSpace())
            {
            }
            else
            {
                totalAmnt = GetCustomerProfileAmount.Run(apiLoginId, apiTransactionKey, profileId);
            }

            return(RedirectToAction("GetDiscount", new { amount = totalAmnt }));
        }
Example #2
0
        public ANetApiResponse TestGetCustomerProfile()
        {
            var response        = (createCustomerProfileResponse)CreateCustomerProfile.Run(apiLoginId, transactionKey, GetEmail());
            var profileResponse = GetCustomerProfile.Run(apiLoginId, transactionKey, response.customerProfileId);

            DeleteCustomerProfile.Run(apiLoginId, transactionKey, response.customerProfileId);

            return(profileResponse);
        }
Example #3
0
        public ActionResult <AcceptResponse> ValidateCustomer(string apiLoginId, string apiTransactionKey, string customerId)
        {
            AcceptResponse objAcceptResponse = new AcceptResponse();

            try
            {
                ProxyMethod();

                // validates customer by calling the sample code API
                ANetApiResponse response = GetCustomerProfile.Run(apiLoginId, apiTransactionKey, customerId);


                if (response != null)
                {
                    if (response.messages.resultCode.ToString().ToLower() == "ok")
                    {
                        objAcceptResponse.status       = true;
                        objAcceptResponse.successValue = response.messages.message[0].code + " " + response.messages.message[0].text;
                    }
                    else
                    {
                        objAcceptResponse.status       = false;
                        objAcceptResponse.errorMessage = "Error: " +
                                                         response.messages.message[0].code + "  " +
                                                         response.messages.message[0].text;
                    }
                }
                else
                {
                    objAcceptResponse.status = false;
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                objAcceptResponse.status = false;

                objAcceptResponse.errorMessage = "Error . " + e.Message;
            }


            return(objAcceptResponse);
        }
Example #4
0
        private static void RunMethod(string methodName)
        {
            // These are default transaction keys.
            // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/
            string apiLoginId     = "5KP3u95bQpv";
            string transactionKey = "4Ktq966gC55GAX7S";

            string transactionAmount;
            string transactionId = string.Empty;

            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;

            case "GetCustomerProfileIds":
                GetCustomerProfileIds.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerProfile":
                GetCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerPaymentProfile":
                GetCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerShippingAddress":
                DeleteCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerProfile":
                DeleteCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerPaymentProfile":
                DeleteCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerShippingAddress":
                CreateCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfileFromTransaction":
                CreateCustomerProfileFromTransaction.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionDetails":
                GetTransactionDetails.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionList":
                GetTransactionList.Run(apiLoginId, transactionKey);
                break;

            //case "CreateAnApplePayTransaction":
            //    CreateAnApplePayTransaction.Run(apiLoginId, transactionKey);
            //    break;
            case "DecryptVisaCheckoutData":
                DecryptVisaCheckoutData.Run(apiLoginId, transactionKey);
                break;

            case "CreateVisaCheckoutTransaction":
                CreateVisaCheckoutTransaction.Run(apiLoginId, transactionKey);
                break;

            case "ChargeCreditCard":
                ChargeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "CaptureOnly":
                CaptureOnly.Run(apiLoginId, transactionKey);
                break;

            case "CapturePreviouslyAuthorizedAmount":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CapturePreviouslyAuthorizedAmount.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "CaptureFundsAuthorizedThroughAnotherChannel":
                CaptureFundsAuthorizedThroughAnotherChannel.Run(apiLoginId, transactionKey);
                break;

            case "AuthorizeCreditCard":
                AuthorizeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "Refund":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                RefundTransaction.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "Void":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                VoidTransaction.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "DebitBankAccount":
                DebitBankAccount.Run(apiLoginId, transactionKey);
                break;

            case "CreditBankAccount":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CreditBankAccount.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "ChargeCustomerProfile":
                ChargeCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "ChargeTokenizedCard":
                ChargeTokenizedCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "PayPalVoid":
                PayPalVoid.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeCapture":
                PayPalAuthorizeCapture.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeCaptureContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeOnly":
                PayPalAuthorizeOnly.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeOnlyContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalCredit":
                PayPalCredit.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalGetDetails":
                PayPalGetDetails.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalPriorAuthorizationCapture":
                PayPalPriorAuthorizationCapture.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "CancelSubscription":
                CancelSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateSubscription":
                CreateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionList":
                GetListSubscriptions.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionStatus":
                GetSubscriptionStatus.Run(apiLoginId, transactionKey);
                break;

            case "UpdateSubscription":
                UpdateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfile":
                CreateCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerPaymentProfile":
                CreateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetUnsettledTransactionList":
                GetUnsettledTransactionList.Run(apiLoginId, transactionKey);
                break;

            case "GetBatchStatistics":
                GetBatchStatistics.Run(apiLoginId, transactionKey);
                break;

            case "GetSettledBatchList":
                GetSettledBatchList.Run(apiLoginId, transactionKey);
                break;

            default:
                ShowUsage();
                break;
            }
        }