public async Task<StandardPaymentResponse> StandardPaymentAsync(StandardPaymentRequest request) { var requestMessage = new PaymentRequestMessage(); var transaction = requestMessage.Payment.PaymentList.Transaction; transaction.TransactionType = PaymentTransactionType.StandardPayment; transaction.TransactionSource = PaymentTransactionSource.Xml; transaction.PurchaseOrderNumber = request.PurchaseOrder; transaction.Amount = request.Amount; transaction.Currency = request.Currency; transaction.CreditCardInfo = new CreditCardInfo { CardNumber = request.CreditCard.CardNumber, Cvv = request.CreditCard.Cvv, ExpiryDate = request.CreditCard.Expires.ToSecurePayString(), }; var responseMessage = await PostAsync<PaymentRequestMessage, PaymentResponseMessage>(requestMessage); transaction = responseMessage.Payment.PaymentList.Transaction; var response = new StandardPaymentResponse { Approved = transaction.Approved == "Yes", PurchaseOrder = transaction.PurchaseOrderNumber, ResponseCode = transaction.ResponseCode, ResponseText = transaction.ReponseText, Amount = transaction.Amount, Currency = transaction.Currency, TransactionId = transaction.TransactionId, SettlementDate = DateUtils.ParseYyyymmdd(transaction.SettlementDate), }; if (transaction.CreditCardInfo != null) { response.CreditCard = new CreditCardResponse { Expires = new YearMonth(transaction.CreditCardInfo.ExpiryDate), TruncatedCardNumber = transaction.CreditCardInfo.TruncatedCreditCardNumber, CardDescription = transaction.CreditCardInfo.CardDescription, }; } return response; }
private async Task<StandardPaymentResponse> StandardPayment(bool expectSuccess = true) { var request = new StandardPaymentRequest { Amount = PaymentAmount, PurchaseOrder = PurchaseOrder, CreditCard = new CreditCardRequest { CardNumber = CardNumber, Expires = Expires, Cvv = Ccv, } }; try { var response = await Client.StandardPaymentAsync(request); Assert.AreEqual(expectSuccess, response.Approved); return response; } catch { LogMessages(); throw; } }