public ActionResult <AcceptResponse> AcceptJs(string apiLoginId, string apiTransactionKey, string token)
        {
            AcceptResponse objAcceptResponse = new AcceptResponse();

            try
            {
                ProxyMethod();

                ANetApiResponse profileResponse = CreateAnAcceptPaymentTransaction.Run(apiLoginId, apiTransactionKey, token);


                if (profileResponse != null)
                {
                    if (profileResponse.messages.resultCode.ToString().ToLower() == "ok")
                    {
                        objAcceptResponse.status       = true;
                        objAcceptResponse.successValue = ((AuthorizeNet.Api.Contracts.V1.createTransactionResponse)profileResponse)
                                                         .transactionResponse.transId;
                    }
                    else
                    {
                        objAcceptResponse.status = false;

                        if (profileResponse.messages.resultCode.ToString().ToLower() == "error")
                        {
                            objAcceptResponse.errorMessage = profileResponse.messages.message[0].code + " " +
                                                             profileResponse.messages.message[0].text;
                        }
                        else
                        {
                            objAcceptResponse.errorMessage = ((AuthorizeNet.Api.Contracts.V1.createTransactionResponse)profileResponse)
                                                             .transactionResponse
                                                             .errors[0].errorCode +
                                                             ((AuthorizeNet.Api.Contracts.V1.createTransactionResponse)profileResponse)
                                                             .transactionResponse.errors[0].errorText;
                        }
                    }
                }
                else
                {
                    objAcceptResponse.status = false;
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                objAcceptResponse.status = false;

                objAcceptResponse.errorMessage = "Error occured while executing payment. " + e.Message;
            }


            return(objAcceptResponse);
        }
Ejemplo n.º 2
0
        public ActionResult <AcceptResponse> AcceptHosted(string apiLoginId, string apiTransactionKey, string iFrameCommunicatorUrl, string customerId = null)
        {
            AcceptResponse objAcceptResponse = new AcceptResponse();

            try
            {
                ProxyMethod();

                // generates a token by calling the sample code API
                ANetApiResponse response = GetAnAcceptPaymentPage.Run(apiLoginId, apiTransactionKey, iFrameCommunicatorUrl, customerId);


                if (response != null)
                {
                    if (response.messages.resultCode.ToString().ToLower() == "ok")
                    {
                        objAcceptResponse.status       = true;
                        objAcceptResponse.successValue =
                            ((getHostedPaymentPageResponse)response).token;
                    }
                    else
                    {
                        objAcceptResponse.status       = false;
                        objAcceptResponse.errorMessage = "Failed to get hosted payment page 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 occured while executing payment. " + e.Message;
            }


            return(objAcceptResponse);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public ActionResult <AcceptResponse> AcceptHosted(string apiLoginId, string apiTransactionKey, string iFrameCommunicatorUrl)
        {
            AcceptResponse objAcceptResponse = new AcceptResponse();

            try
            {
                ProxyMethod();

                ANetApiResponse response = GetAnAcceptPaymentPage.Run(apiLoginId, apiTransactionKey, iFrameCommunicatorUrl);


                if (response != null)
                {
                    if (response.messages.resultCode.ToString() == "Ok")
                    {
                        objAcceptResponse.Status = true;
                        objAcceptResponse.Value  =
                            ((AuthorizeNet.Api.Contracts.V1.getHostedPaymentPageResponse)response).token;
                    }
                    else
                    {
                        objAcceptResponse.Status  = false;
                        objAcceptResponse.Message = "Failed to get hosted payment page Error: " +
                                                    response.messages.message[0].code + "  " +
                                                    response.messages.message[0].text;
                    }
                }
                else
                {
                    objAcceptResponse.Status = false;
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                objAcceptResponse.Status = false;

                objAcceptResponse.Message = "Error occured while executing payment. " + e.Message;
            }


            return(objAcceptResponse);
        }