예제 #1
0
        public ProcessPaymentResult Process(PaymentProcessingContext context)
        {
            if (context.Amount < (decimal)1.19)
            {
                throw new FormatException("Amount cannot be less than € 1,19");
            }

            var settings = context.ProcessorConfig as IDealConfig;

            var instance    = CommerceInstance.Current.Name;
            var httpContext = HttpContextAccessor();
            var reportUrl   = Strings.AreaName + "/iDeal/Callback?instance=" + instance;
            var returnUrl   = Strings.AreaName
                              + "/iDeal/Return?instance=" + instance
                              + "&paymentId=" + context.Payment.Id
                              + "&commerceReturnUrl=" + HttpUtility.UrlEncode(context.ReturnUrl);

            var idealFetch = new IdealFetch(
                settings.PartnerId
                , context.Payment.Description
                , reportUrl.ToFullUrl(httpContext)
                , returnUrl.ToFullUrl(httpContext)
                , ""
                , context.Amount
                );

            if (idealFetch.Error)
            {
                throw new PaymentProcessorException(idealFetch.ErrorMessage);
            }

            return(ProcessPaymentResult.Pending(idealFetch.Url, idealFetch.TransactionId));
        }
예제 #2
0
        private ProcessPaymentResult ProcessResponse(Payment payment, BuckarooConfig settings)
        {
            var signature = BuckarooUtil.GetSignature(Request.Form, settings.SecretKey);

            if (signature != Request["brq_signature"])
            {
                throw new InvalidOperationException("Invalid response.");
            }

            var statusCode      = Request["brq_statuscode"];
            var transactionType = Request["brq_transaction_type"];
            var statusMessage   = Request["brq_statusmessage"];
            var transactionId   = Request["brq_transactions"];
            var methodId        = Request["Brq_payment_method"];

            // Failed / Validation Failure / Technical Failure
            if (statusCode == "490" || statusCode == "491" || statusCode == "492")
            {
                return(ProcessPaymentResult.Failed(statusCode + ": " + statusMessage));
            }
            // Rejected by the (third party) payment provider
            if (statusCode == "690")
            {
                return(ProcessPaymentResult.Failed(statusCode + ": " + statusMessage));
            }
            // Cancelled by Customer / Merchant
            if (statusCode == "890" || statusCode == "891")
            {
                return(ProcessPaymentResult.Cancelled());
            }

            // 190: Success (but might later become reserved)
            if (statusCode != "190")
            {
                return(ProcessPaymentResult.Pending(null));
            }

            if (methodId == "simplesepadirectdebit")
            {
                // Reserved
                if (transactionType == "C501")
                {
                    return(ProcessPaymentResult.Pending(transactionId));
                }

                return(ProcessPaymentResult.Pending(null));
            }
            else if (methodId == "ideal")
            {
                return(ProcessPaymentResult.Success(transactionId));
            }
            else if (methodId == "paypal")
            {
                return(ProcessPaymentResult.Success(transactionId));
            }

            throw new NotSupportedException("Not support payment method: " + methodId + ".");
        }
예제 #3
0
        public ProcessPaymentResult Process(PaymentProcessingContext context)
        {
            var instance    = CommerceInstance.Current.Name;
            var redirectUrl = Strings.AreaName
                              + "/Home/Gateway?instance=" + instance
                              + "&paymentId=" + context.Payment.Id
                              + "&currency=" + context.CurrencyCode
                              + "&commerceReturnUrl=" + HttpUtility.UrlEncode(context.ReturnUrl);

            redirectUrl = redirectUrl.ToFullUrl(HttpContextAccessor());

            return(ProcessPaymentResult.Pending(redirectUrl, Guid.NewGuid().ToString("N")));
        }