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 bool PassedAVSCheck(this CardConnectAuthorizationResponse attempt)
 {
     if (attempt.WasSuccessful())
     {
         return(true);
     }
     return(attempt.avsresp != null && (attempt.avsresp != "N" && attempt.avsresp != "A" && attempt.avsresp != "Z"));
 }
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 static PaymentTransaction Map(Payment payment, CardConnectAuthorizationResponse response)
        {
            var t = new PaymentTransaction()
            {
                Amount        = payment.Amount,
                DateExecuted  = DateTime.Now,
                ResultCode    = response.authcode,
                ResultMessage = response.resptext,
                Succeeded     = response.WasSuccessful(),
                Type          = "CreditCard",
                xp            = new
                {
                    CardConnectResponse = response
                }
            };

            return(t);
        }