Пример #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);
        }
Пример #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"));
 }
 public CreditCardAuthorizationException(string errorCode, string message, CardConnectAuthorizationResponse data)
 {
     ApiError = new ApiError()
     {
         Data      = data,
         ErrorCode = errorCode,
         Message   = message
     };
     Response = data;
 }
Пример #4
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");
 }
Пример #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);
        }
Пример #6
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);
        }
Пример #7
0
 public static bool IsDeclined(this CardConnectAuthorizationResponse attempt)
 {
     return(attempt.respcode == "500");
 }
Пример #8
0
 public static bool IsExpired(this CardConnectAuthorizationResponse attempt)
 {
     return(attempt.respcode == "101");
 }
Пример #9
0
 public static bool WasSuccessful(this CardConnectAuthorizationResponse attempt)
 {
     return(attempt.respstat == "A" && (attempt.respcode == "0" || attempt.respcode == "00" || attempt.respcode == "000"));
 }
 public CreditCardAuthorizationException(ApiError error, CardConnectAuthorizationResponse response)
 {
     ApiError = error;
     Response = response;
 }