Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            // Create Soap Client
            CreditSoapClient soapClient = new CreditSoapClient("CreditSoap");
            // Create MerchantCredentails object
            MerchantCredentials merchantCredentials = new MerchantCredentials
            {
                MerchantName   = "TEST MERCHANT",
                MerchantSiteId = "XXXXXXXX",
                MerchantKey    = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
            };
            // Create PaymentData object
            PaymentData paymentData = new PaymentData
            {
                Source = "PreviousTransaction",
                Token  = "1234567890"
            };
            // Create RefundRequest Object
            RefundRequest refundRequest = new RefundRequest
            {
                Amount                 = "1.01",
                InvoiceNumber          = "INV1234",
                CardAcceptorTerminalId = "01"
            };
            // Run Refund
            TransactionResponse45 transactionResponse45 = soapClient.Refund(merchantCredentials, paymentData, refundRequest);

            //Print Results
            Console.WriteLine("Refund Response: {0}{3} Token: {1}{3} Amount: ${2}{3}", transactionResponse45.ApprovalStatus, transactionResponse45.Token, transactionResponse45.Amount, Environment.NewLine);
            Console.WriteLine("Press Any Key to Close");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            // Create Soap Client
            CreditSoapClient soapClient = new CreditSoapClient("CreditSoap");
            // Create MerchantCredentails object
            MerchantCredentials merchantCredentials = new MerchantCredentials
            {
                MerchantName   = "TEST MERCHANT",
                MerchantSiteId = "XXXXXXXX",
                MerchantKey    = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
            };
            // Create PaymentData object
            PaymentData paymentData = new PaymentData
            {
                Source    = "Reader",
                TrackData = "%B4012000033330026^TEST CARD/GENIUS^181210054321000000000000000 150 A?;4012000033330026=18121011000012345678?",
            };
            // Create RefundRequest Object
            RefundRequest refundRequest = new RefundRequest
            {
                Amount                 = "1.01",
                InvoiceNumber          = "INV1234",
                CardAcceptorTerminalId = "01"
            };
            // Run Refund
            TransactionResponse45 transactionResponse45 = soapClient.Refund(merchantCredentials, paymentData, refundRequest);

            // Print Results
            Console.WriteLine("Refund Response: {0} Token: {1} Amount: ${2}", transactionResponse45.ApprovalStatus, transactionResponse45.Token, transactionResponse45.Amount);
            Console.WriteLine("Press Any Key to Close");
            Console.ReadKey();
        }
        public async Task <CaptureResponse> CaptureAsync(CaptureRequest request, MerchantCredentials credentials = null)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (_credentials == null && credentials == null)
            {
                throw new InvalidOperationException("Credentials are null");
            }

            var currentCredentials = credentials ?? _credentials;

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantId))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantId is null");
            }

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantKey))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantKey is null");
            }

            var httpRequest = new RestRequest(@"v2/sales/{paymentId}/capture", Method.PUT)
            {
                RequestFormat = DataFormat.Json
            };

            httpRequest.AddHeader("Content-Type", "application/json");
            httpRequest.AddHeader("MerchantId", currentCredentials.MerchantId);
            httpRequest.AddHeader("MerchantKey", currentCredentials.MerchantKey);
            httpRequest.AddHeader("RequestId", Guid.NewGuid().ToString());
            httpRequest.AddUrlSegment("paymentId", request.PaymentId);
            httpRequest.AddQueryParameter("amount", request.Amount.ToString(CultureInfo.InvariantCulture));

            if (request.ServiceTaxAmount.HasValue)
            {
                httpRequest.AddQueryParameter("serviceTaxAmount", request.ServiceTaxAmount.Value.ToString(CultureInfo.InvariantCulture));
            }

            var cancellationTokenSource = new CancellationTokenSource();

            var httpResponse = await RestClientApi.ExecuteTaskAsync(httpRequest, cancellationTokenSource.Token);

            if (httpResponse.StatusCode != HttpStatusCode.OK)
            {
                return(new CaptureResponse
                {
                    HttpStatus = httpResponse.StatusCode,
                    ErrorDataCollection = JsonDeserializer.Deserialize <List <ErrorData> >(httpResponse)
                });
            }

            var jsonResponse = JsonDeserializer.Deserialize <CaptureResponse>(httpResponse);

            jsonResponse.HttpStatus = httpResponse.StatusCode;
            return(jsonResponse);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a client that will use the domain and version provided instead of the testing endpoint.
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="domain">The domain of the endpoint (ex: "https://api.gidx-service.in").</param>
        /// <param name="version">The API version number you want to use.</param>
        public GIDXClient(MerchantCredentials credentials, string domain, string version)
        {
            if (version[0] != 'v')
            {
                version = "v" + version;
            }

            var path = string.Format("/{0}/api/", version);

            Init(credentials, new Uri(new Uri(domain), path));
        }
Exemplo n.º 5
0
 public CartaoProtegidoClient(CartaoProtegidoClientOptions options)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     _credentials = options.Credentials;
     RestClient   = _options.Environment == Environment.Production ? new RestClient {
         BaseUrl = new Uri(Endpoints.CartaoProtegidoProduction)
     } : new RestClient {
         BaseUrl = new Uri(Endpoints.CartaoProtegidoSandbox)
     };
     XmlDeserializer = new XmlDeserializer();
 }
        public async Task <SaleResponse> GetAsync(string paymentId, MerchantCredentials credentials = null)
        {
            if (string.IsNullOrWhiteSpace(paymentId))
            {
                throw new ArgumentNullException(nameof(paymentId));
            }

            if (_credentials == null && credentials == null)
            {
                throw new InvalidOperationException("Credentials are null");
            }

            var currentCredentials = credentials ?? _credentials;

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantId))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantId is null");
            }

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantKey))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantKey is null");
            }

            var httpRequest = new RestRequest(@"v2/sales/{paymentId}", Method.GET)
            {
                RequestFormat = DataFormat.Json
            };

            httpRequest.AddHeader("Content-Type", "application/json");
            httpRequest.AddHeader("MerchantId", currentCredentials.MerchantId);
            httpRequest.AddHeader("MerchantKey", currentCredentials.MerchantKey);
            httpRequest.AddHeader("RequestId", Guid.NewGuid().ToString());
            httpRequest.AddUrlSegment("paymentId", paymentId);

            var cancellationTokenSource = new CancellationTokenSource();

            var httpResponse = await RestClientQueryApi.ExecuteTaskAsync(httpRequest, cancellationTokenSource.Token);

            if (httpResponse.StatusCode != HttpStatusCode.OK)
            {
                return(new SaleResponse
                {
                    HttpStatus = httpResponse.StatusCode,
                    ErrorDataCollection = JsonDeserializer.Deserialize <List <ErrorData> >(httpResponse)
                });
            }

            var jsonResponse = JsonDeserializer.Deserialize <SaleResponse>(httpResponse);

            jsonResponse.HttpStatus = httpResponse.StatusCode;
            return(jsonResponse);
        }
        public async Task <SaleResponse> CreateSaleAsync(SaleRequest request, MerchantCredentials credentials = null)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (_credentials == null && credentials == null)
            {
                throw new InvalidOperationException("Credentials are null");
            }

            var currentCredentials = credentials ?? _credentials;

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantId))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantId is null");
            }

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantKey))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantKey is null");
            }

            var httpRequest = new RestRequest(@"v2/sales/", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            httpRequest.AddHeader("Content-Type", "application/json");
            httpRequest.AddHeader("MerchantId", currentCredentials.MerchantId);
            httpRequest.AddHeader("MerchantKey", currentCredentials.MerchantKey);
            httpRequest.AddHeader("RequestId", Guid.NewGuid().ToString());
            httpRequest.AddBody(new { request.MerchantOrderId, request.Customer, request.Payment });

            var cancellationTokenSource = new CancellationTokenSource();

            var httpResponse = await RestClientApi.ExecuteTaskAsync(httpRequest, cancellationTokenSource.Token);

            if (httpResponse.StatusCode != HttpStatusCode.Created)
            {
                return(new SaleResponse
                {
                    HttpStatus = httpResponse.StatusCode,
                    ErrorDataCollection = httpResponse.StatusCode != HttpStatusCode.Forbidden ? JsonDeserializer.Deserialize <List <ErrorData> >(httpResponse) : null
                });
            }

            var jsonResponse = JsonDeserializer.Deserialize <SaleResponse>(httpResponse);

            jsonResponse.HttpStatus = httpResponse.StatusCode;
            return(jsonResponse);
        }
 public PagadorClient(PagadorClientOptions options)
 {
     _options      = options ?? throw new ArgumentNullException(nameof(options));
     _credentials  = options.Credentials;
     RestClientApi = _options.Environment == Environment.Production ? new RestClient {
         BaseUrl = new Uri(Endpoints.PagadorApiProduction)
     } : new RestClient {
         BaseUrl = new Uri(Endpoints.PagadorApiSandbox)
     };
     RestClientQueryApi = _options.Environment == Environment.Production ? new RestClient {
         BaseUrl = new Uri(Endpoints.PagadorQueryApiProduction)
     } : new RestClient {
         BaseUrl = new Uri(Endpoints.PagadorQueryApiSandbox)
     };
     JsonDeserializer = new JsonDeserializer();
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //Create Soap Client
            CreditSoapClient soapClient = new CreditSoapClient("CreditSoap");
            //Create MerchantCredentails object
            MerchantCredentials merchantCredentials = new MerchantCredentials
            {
                MerchantName   = "TEST MERCHANT",
                MerchantSiteId = "XXXXXXXX",
                MerchantKey    = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
            };
            //Create PaymentData object
            PaymentData paymentData = new PaymentData
            {
                Source                = "Keyed",
                CardNumber            = "4012000033330026",
                ExpirationDate        = "1220",
                CardHolder            = "John Doe",
                AvsStreetAddress      = "1 Federal St",
                AvsZipCode            = "02110",
                CardVerificationValue = "123"
            };
            //Create SaleRequest Object
            SaleRequest saleRequest = new SaleRequest
            {
                Amount                     = "1.01",
                TaxAmount                  = "0.10",
                InvoiceNumber              = "INV1234",
                CardAcceptorTerminalId     = "01",
                CustomerCode               = "1234",
                PurchaseOrderNumber        = "PO1234",
                EnablePartialAuthorization = "true",
                ForceDuplicate             = "true"
            };
            //Run Sale
            TransactionResponse45 transactionResponse45 = soapClient.Sale(merchantCredentials, paymentData, saleRequest);

            // Print Results
            Console.WriteLine("Sale Response: {0} Token: {1} Amount: ${2}", transactionResponse45.ApprovalStatus, transactionResponse45.Token, transactionResponse45.Amount);
            Console.WriteLine("Press Any Key to Close");
            Console.ReadKey();
        }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            // Create Soap Client
            CreditSoapClient soapClient = new CreditSoapClient("CreditSoap");
            // Create MerchantCredentails object
            MerchantCredentials merchantCredentials = new MerchantCredentials
            {
                MerchantName   = "TEST MERCHANT",
                MerchantSiteId = "XXXXXXXX",
                MerchantKey    = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
            };
            // Create PaymentData object
            PaymentData paymentData = new PaymentData
            {
                Source    = "Reader",
                TrackData = "%B4012000033330026^TEST CARD/GENIUS^181210054321000000000000000 150 A?;4012000033330026=18121011000012345678?",
            };
            // Create SaleRequest Object
            SaleRequest saleRequest = new SaleRequest
            {
                Amount                     = "1.01",
                TaxAmount                  = "0.10",
                InvoiceNumber              = "INV1234",
                CardAcceptorTerminalId     = "01",
                CustomerCode               = "1234",
                PurchaseOrderNumber        = "PO1234",
                EnablePartialAuthorization = "true",
                ForceDuplicate             = "true"
            };
            // Run Sale
            TransactionResponse45 transactionResponse45 = soapClient.Sale(merchantCredentials, paymentData, saleRequest);

            // Print Results
            Console.WriteLine("Sale Response: {0} Token: {1} Amount: ${2}", transactionResponse45.ApprovalStatus, transactionResponse45.Token, transactionResponse45.Amount);
            Console.WriteLine("Press Any Key to Close");
            Console.ReadKey();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            //Create Soap Client
            CreditSoapClient soapClient = new CreditSoapClient("CreditSoap");
            //Create MerchantCredentails object
            MerchantCredentials merchantCredentials = new MerchantCredentials
            {
                MerchantName   = "TEST MERCHANT",
                MerchantSiteId = "XXXXXXXX",
                MerchantKey    = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
            };
            //Create PaymentData object
            PaymentData paymentData = new PaymentData
            {
                Source                = "Keyed",
                CardNumber            = "4012000033330026",
                ExpirationDate        = "1220",
                CardHolder            = "John Doe",
                AvsStreetAddress      = "1 Federal St",
                AvsZipCode            = "02110",
                CardVerificationValue = "123"
            };
            //Create RefundRequest Object
            RefundRequest refundRequest = new RefundRequest
            {
                Amount                 = "1.01",
                InvoiceNumber          = "INV1234",
                CardAcceptorTerminalId = "01"
            };
            //Run Refund
            TransactionResponse45 transactionResponse45 = soapClient.Refund(merchantCredentials, paymentData, refundRequest);

            //Print Results
            Console.WriteLine("Refund Response: {0}{3} Token: {1}{3} Amount: ${2}{3}", transactionResponse45.ApprovalStatus, transactionResponse45.Token, transactionResponse45.Amount, Environment.NewLine);
            Console.WriteLine("Press Any Key to Close");
            Console.ReadKey();
        }
Exemplo n.º 12
0
        protected ClientBase(MerchantCredentials credentials, Uri baseAddress, string service)
        {
            Credentials = credentials;

            if (!string.IsNullOrEmpty(service))
            {
                baseAddress = new Uri(baseAddress, service);
            }

            if (!baseAddress.AbsoluteUri.EndsWith("/"))
            {
                //Make sure baseAddress ends in slash so that we can just pass the method name when making requests
                baseAddress = new Uri(baseAddress.AbsoluteUri + "/");
            }

            _httpClient = new HttpClient()
            {
                BaseAddress = baseAddress
            };
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //Creating a JsonSerializer instead of using JsonConvert because we don't want to use any default settings set by the application
            _jsonSerializer = JsonSerializer.Create();
        }
 public CustomerIdentityClient(MerchantCredentials credentials, Uri baseAddress)
     : base(credentials, baseAddress, "CustomerIdentity")
 {
 }
Exemplo n.º 14
0
 public WebCashierClient(MerchantCredentials credentials, Uri baseAddress)
     : base(credentials, baseAddress, "WebCashier")
 {
 }
Exemplo n.º 15
0
        public async Task <GetCreditCardResponse> GetCreditCardAsync(GetCreditCardRequest request, MerchantCredentials credentials = null)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (_credentials == null && credentials == null)
            {
                throw new InvalidOperationException("Credentials are null");
            }

            var currentCredentials = credentials ?? _credentials;

            if (string.IsNullOrWhiteSpace(currentCredentials.MerchantKey))
            {
                throw new InvalidOperationException("Invalid credentials: MerchantKey is null");
            }

            var httpRequest = new RestRequest(@"v2/cartaoprotegido.asmx", Method.POST)
            {
                RequestFormat = DataFormat.Xml,
                XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer()
            };

            var sb = new StringBuilder();

            sb.AppendLine("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
            sb.AppendLine("<soap:Body>");
            sb.AppendLine("<GetCreditCard xmlns=\"http://www.cartaoprotegido.com.br/WebService/\">");
            sb.AppendLine("<getCreditCardRequestWS>");
            sb.AppendLine(request.RequestId.HasValue
                ? $"<RequestId>{request.RequestId.Value}</RequestId>"
                : $"<RequestId>{Guid.NewGuid()}</RequestId>");
            sb.AppendLine($"<MerchantKey>{currentCredentials.MerchantKey}</MerchantKey>");
            sb.AppendLine($"<JustClickKey>{request.JustClickKey}</JustClickKey>");
            sb.AppendLine($"<JustClickAlias>{request.JustClickAlias}</JustClickAlias>");
            sb.AppendLine("</getCreditCardRequestWS>");
            sb.AppendLine("</GetCreditCard>");
            sb.AppendLine("</soap:Body>");
            sb.AppendLine("</soap:Envelope>");

            httpRequest.AddParameter("text/xml", sb.ToString(), ParameterType.RequestBody);

            var cancellationTokenSource = new CancellationTokenSource();

            var httpResponse = await RestClient.ExecuteTaskAsync(httpRequest, cancellationTokenSource.Token);

            if (httpResponse.StatusCode != HttpStatusCode.OK)
            {
                return(new GetCreditCardResponse
                {
                    HttpStatus = httpResponse.StatusCode
                });
            }

            var jsonResponse = XmlDeserializer.Deserialize <GetCreditCardResponse>(httpResponse);

            jsonResponse.HttpStatus = httpResponse.StatusCode;
            return(jsonResponse);
        }
Exemplo n.º 16
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            var token = this.TokenHolder.Text;

            var tokenRegex = new Regex(@"^[a-zA-Z0-9_]{1,40}$");

            if (tokenRegex.IsMatch(token))
            {
                using (var service = new CreditSoapClient())
                {
                    MerchantCredentials credentials = new MerchantCredentials
                    {
                        //Replace *YOUR MERCHANTNAME HERE* with test credentials provided
                        MerchantName = "YOUR MERCHANTNAME HERE",
                        //Replace *YOUR SITEID HERE* with test credentials provided
                        MerchantSiteId = "YOUR SITEID HERE",
                        //Replace *YOUR MERCHANTKEY HERE* with test credentials provided
                        MerchantKey = "YOUR MERCHANTKEY HERE"
                    };

                    PaymentData paymentData = new PaymentData
                    {
                        VaultToken = token,
                        // Email address is optional, but required for Kount FraudScoring
                        CustomerEmailAddress = EmailAddress.Text,
                        Source = "Vault"
                    };

                    SaleRequest saleRequest = new SaleRequest
                    {
                        Amount                 = this.Amount,
                        RegisterNumber         = "123",
                        MerchantTransactionId  = "1234",
                        CardAcceptorTerminalId = "01"
                    };

                    var response = service.Sale(credentials, paymentData, saleRequest);

                    this.CheckoutPlaceHolder.Visible = false;
                    var error = response.ErrorMessage;

                    if (error != "")
                    {
                        this.ResponseMessage.Visible     = false;
                        this.ReferenceNumber.Visible     = false;
                        this.KountScore.Visible          = false;
                        this.KountRecommendation.Visible = false;

                        this.ErrorMessage.Text = "<b>Error Message: </b>" + error;
                    }
                    else
                    {
                        this.ErrorMessage.Visible = false;
                        this.ResponseMessage.Text = "<b>Status: </b>" + response.ApprovalStatus;
                        this.ReferenceNumber.Text = "<b>Reference #: </b>" + response.Token;

                        if (response.FraudScoring != null)
                        {
                            this.KountScore.Text          = "<b>Kount Score: </b>" + response.FraudScoring.Score;
                            this.KountRecommendation.Text = "<b>Kount Recommendation: </b>" + response.FraudScoring.Recommendation;
                        }
                        else
                        {
                            this.KountScore.Visible          = false;
                            this.KountRecommendation.Visible = false;
                        }
                    }
                    this.TokenHolder.Text           = string.Empty;
                    this.ResultsPlaceHolder.Visible = true;
                }
            }
            else
            {
                Response.Redirect("Error.aspx", true);
            }
        }
Exemplo n.º 17
0
 private void Init(MerchantCredentials credentials, Uri baseAddress)
 {
     Credentials  = credentials;
     _baseAddress = baseAddress;
 }
Exemplo n.º 18
0
 public GIDXClient(MerchantCredentials credentials, string baseAddress)
 {
     Init(credentials, new Uri(baseAddress));
 }
 public DocumentLibraryClient(MerchantCredentials credentials, Uri baseAddress)
     : base(credentials, baseAddress, "DocumentLibrary")
 {
 }
Exemplo n.º 20
0
 public WebRegClient(MerchantCredentials credentials, Uri baseAddress)
     : base(credentials, baseAddress, "WebReg")
 {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a client that will use the testing endpoint.
 /// </summary>
 /// <param name="credentials"></param>
 public GIDXClient(MerchantCredentials credentials)
     : this(credentials, DefaultDomain, DefaultVersion)
 {
 }
Exemplo n.º 22
0
 public WebMyAccountClient(MerchantCredentials credentials, Uri baseAddress)
     : base(credentials, baseAddress, "WebMyAccount")
 {
 }
Exemplo n.º 23
0
 protected ClientBase(MerchantCredentials credentials, Uri baseAddress)
     : this(credentials, baseAddress, null)
 {
 }