protected void btnGenerateToken_Click(object sender, EventArgs e)
    {
        string token = "";

        GetAnAcceptPaymentPage.Run("89FVdsGYb7f", "5Lr795D69RH9b7c7", 1000.12m, this, out token);
        txtToken.Text = token;
    }
Esempio 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);
        }
        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);
        }
Esempio n. 4
0
 public ANetApiResponse TestGetAnAcceptPaymentPage()
 {
     return(GetAnAcceptPaymentPage.Run(apiLoginId, transactionKey, GetAmount()));
 }