Ejemplo n.º 1
0
        private async Task <CardConnectAuthorizationResponse> PostAuthorizationAsync(CardConnectAuthorizationRequest request)
        {
            CardConnectAuthorizationResponse attempt = new CardConnectAuthorizationResponse();

            if (ShouldMockCardConnectResponse())
            {
                attempt = MockCardConnectAuthorizationResponse(request);
            }
            else
            {
                attempt = await this
                          .Request("cardconnect/rest/auth", request.currency)
                          .PutJsonAsync(request)
                          .ReceiveJson <CardConnectAuthorizationResponse>();
            }

            if (attempt.WasSuccessful())
            {
                return(attempt);
            }
            throw new CreditCardAuthorizationException(new ApiError()
            {
                Data      = attempt,
                Message   = attempt.resptext, // response codes: https://developer.cardconnect.com/assets/developer/assets/authResp_2-11-19.txt
                ErrorCode = attempt.respcode
            }, attempt);
        }
Ejemplo n.º 2
0
        public static CardConnectAuthorizationRequest Map(BuyerCreditCard card, Order order, OrderCloudIntegrationsCreditCardPayment payment, string merchantID, decimal amount)
        {
            var address = card.xp.CCBillingAddress;
            var req     = new CardConnectAuthorizationRequest()
            {
                name     = $"{card.CardholderName}",
                account  = card.Token,
                address  = address.Street1,
                amount   = amount.ToString(),
                city     = address.City,
                country  = address.Country,
                currency = payment.Currency,
                cvv2     = payment.CVV,
                expiry   = $"{card.ExpirationDate.Value:MMyyyy}",
                merchid  = merchantID,
                orderid  = order.ID,
                postal   = address.Zip,
                region   = address.State
            };

            return(req);
        }
Ejemplo n.º 3
0
 public static bool PassedCvvCheck(this CardConnectAuthorizationResponse attempt, CardConnectAuthorizationRequest request)
 {
     if (attempt.WasSuccessful())
     {
         return(true);
     }
     if (request.cvv2 == null && (attempt.cvvresp == "P" || attempt.cvvresp == null))
     {
         return(true);
     }
     return(attempt.cvvresp != null && attempt.cvvresp != "N" && attempt.cvvresp != "P" && attempt.cvvresp != "U");
 }
Ejemplo n.º 4
0
 public async Task <CardConnectAuthorizationResponse> AuthWithCapture(CardConnectAuthorizationRequest request)
 {
     request.capture = "Y";
     return(await PostAuthorizationAsync(request));
 }
Ejemplo n.º 5
0
        private CardConnectAuthorizationResponse MockCardConnectAuthorizationResponse(CardConnectAuthorizationRequest request)
        {
            CardConnectAuthorizationResponse response;

            response = new CardConnectAuthorizationResponse()
            {
                amount   = decimal.Parse(request.amount, CultureInfo.InvariantCulture),
                resptext = "Success",
                cvvresp  = "U",
                commcard = "Mock Response",
                respstat = "A",
                respcode = "0"
            };

            return(response);
        }