Exemplo n.º 1
0
        /// <summary>
        /// Charge Credit Card Async.
        /// </summary>
        /// <returns>ANetChargeCreateTransactionResponse instance</returns>
        /// <param name="creditCard">Credit card</param>
        /// <param name="refId">Reference identifier</param>
        /// <param name="amount">Amount</param>
        public async Task <ANetChargeTransactionResponse> ChargeAsync(ANetCreditCard creditCard, string refId, decimal amount)
        {
            var createRequest          = new ANetChargeCreateTransactionRequest();
            var requestBody            = new ANetChargeTransactionRequestBody();
            var merchantAuthentication = getMerchantAuthentication();
            var transaction            = new ANetChargeTransactionRequest();
            var payment = new ANetPayment
            {
                CreditCard = creditCard
            };

            transaction.Payment                = payment;
            transaction.Amount                 = amount;
            transaction.TransactionType        = ANetTransactionType.authCaptureTransaction;
            requestBody.TransactionRequest     = transaction;
            requestBody.MerchantAuthentication = merchantAuthentication;
            requestBody.RefId = refId;
            createRequest.CreateTransactionRequest = requestBody;
            return(await chargeAsync(createRequest));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Authorize Credit Card Async.
        /// </summary>
        /// <returns>ANetAuthorizeCreateTransactionResponse instance</returns>
        /// <param name="creditCard">Credit card.</param>
        /// <param name="refId">Reference identifier.</param>
        /// <param name="billing">Billing.</param>
        /// <param name="amount">Amount.</param>
        public async Task <ANetAuthorizeTransactionResponse> AuthorizeAsync(ANetCreditCard creditCard, ANetBillTo billing, string refId, decimal amount)
        {
            var createRequest          = new ANetAuthorizeCreateTransactionRequest();
            var requestBody            = new ANetAuthorizeTransactionRequestBody();
            var merchantAuthentication = getMerchantAuthentication();
            var transaction            = new ANetAuthorizeTransactionRequest();
            var payment = new ANetPayment
            {
                CreditCard = creditCard
            };

            transaction.Payment                = payment;
            transaction.Amount                 = amount;
            transaction.TransactionType        = ANetTransactionType.authOnlyTransaction;
            transaction.BillTo                 = billing;
            requestBody.MerchantAuthentication = merchantAuthentication;
            requestBody.RefId = refId;
            requestBody.TransactionRequest         = transaction;
            createRequest.CreateTransactionRequest = requestBody;
            return(await authorizeAsync(createRequest));
        }