Beispiel #1
0
        /// <summary>
        /// Return a previous card payment that was not made through Beanstream. Use this if you would like to
        /// return a payment but that payment was performed on another gateway.
        ///
        /// You must have this capability enabled on your account by calling Beanstream support. It is dangerous to
        /// have it enabled as the API will not check if you have a transaction ID.
        /// </summary>
        /// <returns>The return result</returns>
        /// <param name="returnRequest">Return request.</param>
        /// <param name="adjId">Reference the transaction identification number (trnId) from the original purchase</param>
        public PaymentResponse UnreferencedReturn(UnreferencedCardReturnRequest returnRequest)
        {
            Gateway.ThrowIfNullArgument(returnRequest, "returnRequest");

            var url = BeanstreamUrls.ReturnsUrl
                      .Replace("{v}", string.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                      .Replace("{id}", "0"); // uses ID 0 since there is no existing payment ID for this transaction

            var req = CreateWebRequest();

            returnRequest.MerchantId = _configuration.MerchantId.ToString();

            var response = req.ProcessTransaction(HttpMethod.Post, url, returnRequest);

            return(JsonConvert.DeserializeObject <PaymentResponse>(response));
        }
Beispiel #2
0
        public LegatoTokenResponse CreateToken(LegatoTokenRequest tokenRequest)
        {
            Gateway.ThrowIfNullArgument(tokenRequest, "tokenRequest");
            Gateway.ThrowIfNullArgument(tokenRequest.Number, "tokenRequest.Number");
            Gateway.ThrowIfNullArgument(tokenRequest.ExpiryMonth, "tokenRequest.ExpiryMonth");
            Gateway.ThrowIfNullArgument(tokenRequest.ExpiryYear, "tokenRequest.ExpiryYear");
            Gateway.ThrowIfNullArgument(tokenRequest.Cvd, "tokenRequest.Cvd");

            var url = BeanstreamUrls.TokenUrl
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform);

            var req = CreateWebRequest();

            var response = req.ProcessTransaction(HttpMethod.Post, url, tokenRequest);

            return(JsonConvert.DeserializeObject <LegatoTokenResponse>(response));
        }
Beispiel #3
0
        /// <summary>
        /// Return a previous payment made through Beanstream
        /// </summary>
        /// <returns>The payment result</returns>
        /// <param name="paymentId">Payment identifier.</param>
        /// <param name="returnRequest">Return request.</param>
        public PaymentResponse Return(string paymentId, ReturnRequest returnRequest)
        {
            Gateway.ThrowIfNullArgument(returnRequest, "returnRequest");
            Gateway.ThrowIfNullArgument(paymentId, "paymentId");

            var url = BeanstreamUrls.ReturnsUrl
                      .Replace("{v}", string.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                      .Replace("{id}", string.IsNullOrEmpty(paymentId) ? "" : paymentId);

            var req = CreateWebRequest();

            returnRequest.MerchantId = _configuration.MerchantId.ToString();

            var response = req.ProcessTransaction(HttpMethod.Post, url, returnRequest);

            //Console.WriteLine(response);
            return(JsonConvert.DeserializeObject <PaymentResponse>(response));
        }
        /// <summary>
        /// Make a credit card payment.
        /// </summary>
        /// <returns>he payment result</returns>
        /// <param name="paymentRequest">Payment request.</param>
        public PaymentResponse MakePayment(PaymentRequest paymentRequest)
        {
            Gateway.ThrowIfNullArgument(paymentRequest, "paymentRequest");

            string url = BeanstreamUrls.BasePaymentsUrl
                         .Replace("{v}", String.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                         .Replace("{p}", String.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform);


            HttpsWebRequest req = new HttpsWebRequest()
            {
                MerchantId         = _configuration.MerchantId,
                Passcode           = _configuration.PaymentsApiPasscode,
                WebCommandExecutor = _webCommandExecuter
            };

            string response = req.ProcessTransaction(HttpMethod.Post, url, paymentRequest);

            return(JsonConvert.DeserializeObject <PaymentResponse>(response));
        }
Beispiel #5
0
        private ProfileResponse CreateProfile(Token token, Card card, Address billingAddress, CustomFields customFields, string language, string comment)
        {
            if (token == null && card == null)
            {
                Gateway.ThrowIfNullArgument(null, "Card and Token both null!");
            }

            if (token == null)
            {
                Gateway.ThrowIfNullArgument(card, "card");
                Gateway.ThrowIfNullArgument(card.Number, "card.number");
                Gateway.ThrowIfNullArgument(card.Name, "card.name");
                Gateway.ThrowIfNullArgument(card.ExpiryMonth, "card.expiryMonth");
                Gateway.ThrowIfNullArgument(card.ExpiryYear, "card.expiryYear");
            }
            if (card == null)
            {
                Gateway.ThrowIfNullArgument(token, "token");
                Gateway.ThrowIfNullArgument(token.Name, "token.name");
                Gateway.ThrowIfNullArgument(token.Code, "token.code");
            }

            var url = BeanstreamUrls.BaseProfilesUrl
                      .Replace("{v}", string.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform);

            var req = CreateWebRequest();

            var profile = new
            {
                card,
                token,
                billing = billingAddress,
                custom  = customFields
            };

            var response = req.ProcessTransaction(HttpMethod.Post, url, profile);

            return(JsonConvert.DeserializeObject <ProfileResponse>(response));
        }
Beispiel #6
0
        /// <summary>
        /// Void the specified paymentId.
        ///
        /// Voids generally need to occur before end of business on the same day that the transaction was processed.
        ///
        /// Voids are used to cancel a transaction before the item is registered against a customer credit card account.
        /// Cardholders will never see a voided transaction on their credit card statement. As a result, voids can only
        /// be attempted on the same day as the original transaction. After the end of day (roughly 11:59 pm EST/EDT),
        /// void requests will be rejected from the API if attempted.
        /// </summary>
        /// <returns>The return result</returns>
        /// <param name="paymentId">Payment identifier from a previous transaction.</param>
        public PaymentResponse Void(string paymentId, decimal amount)
        {
            Gateway.ThrowIfNullArgument(paymentId, "paymentId");

            var url = BeanstreamUrls.VoidsUrl
                      .Replace("{v}", string.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                      .Replace("{id}", paymentId);

            var req = CreateWebRequest();

            var voidPayment = new
            {
                merchant_id = _configuration.MerchantId,
                amount
            };

            var response = req.ProcessTransaction(HttpMethod.Post, url, voidPayment);

            //Console.WriteLine(response);
            return(JsonConvert.DeserializeObject <PaymentResponse>(response));
        }
        /// <summary>
        /// Return a previous swipe payment that was not made through Beanstream. Use this if you would like to
        /// return a payment but that payment was performed on another payment service.
        ///
        /// You must have this capability enabled on your account by calling Beanstream support. It is dangerous to
        /// have it enabled as the API will not check if you have a transaction ID.
        /// </summary>
        /// <returns>The return result</returns>
        /// <param name="returnRequest">Return request.</param>
        public PaymentResponse UnreferencedReturn(UnreferencedSwipeReturnRequest returnRequest)
        {
            Gateway.ThrowIfNullArgument(returnRequest, "returnRequest");

            string url = BeanstreamUrls.ReturnsUrl
                         .Replace("{v}", String.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                         .Replace("{p}", String.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                         .Replace("{id}", "0");        // uses ID 0 since there is no existing payment ID for this transaction


            HttpsWebRequest req = new HttpsWebRequest()
            {
                MerchantId         = _configuration.MerchantId,
                Passcode           = _configuration.PaymentsApiPasscode,
                WebCommandExecutor = _webCommandExecuter
            };

            returnRequest.MerchantId = _configuration.MerchantId.ToString();

            string response = req.ProcessTransaction(HttpMethod.Post, url, returnRequest);

            return(JsonConvert.DeserializeObject <PaymentResponse>(response));
        }