Example #1
0
        /// <summary>
        /// 跟踪
        /// </summary>
        /// <returns></returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError("臻顺溜支付不支持跟踪");
            return(result);
        }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError("Capture method not supported");
            return(result);
        }
Example #3
0
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var webClient = new WebClient();
            var form      = new NameValueCollection();
            var order     = capturePaymentRequest.Order;
            var result    = new CapturePaymentResult();

            form.Add("mid", _easyPay2PaymentSettings.mid);
            form.Add("ref", order.OrderGuid.ToString());
            form.Add("cur", _easyPay2PaymentSettings.cur);
            form.Add("amt", order.OrderTotal.ToString());
            form.Add("paytype", "3");
            form.Add("transtype", "capture");
            var responseData = webClient.UploadValues(GetPaymentProcessUrl(), form);
            var reply        = Encoding.ASCII.GetString(responseData);

            string[]      responseFields = reply.Split('&');
            List <String> errorList      = new List <String>();

            if (("YES").Equals(responseFields[4].Split('=')[1]))
            {
                _logger.Information("Void action success !!!");
                result.NewPaymentStatus = PaymentStatus.Paid;
            }
            else
            {
                errorList.Add(responseFields[5].Split('=')[1]);
                errorList.Add(responseFields[11].Split('=')[1]);
                result.Errors = errorList;
                _logger.Error("OOPS void action !!!" + responseFields[5].Split('=')[1] + " " + responseFields[11].Split('=')[1]);
            }
            return(result);
        }
Example #4
0
        public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result   = new DoCaptureResponseType();
            var settings = CommonServices.Settings.LoadSetting <PayPalExpressPaymentSettings>(capturePaymentRequest.Order.StoreId);

            // build the request
            var req = new DoCaptureReq
            {
                DoCaptureRequest = new DoCaptureRequestType()
            };

            //execute request
            using (var service = new PayPalAPIAASoapBinding())
            {
                service.Url = PayPalHelper.GetPaypalServiceUrl(settings);
                service.RequesterCredentials = PayPalHelper.GetPaypalApiCredentials(settings);
                result = service.DoCapture(req);
            }

            var capturePaymentResult = new CapturePaymentResult();

            if (result.Ack == AckCodeType.Success)
            {
                capturePaymentResult.CaptureTransactionId     = result.DoCaptureResponseDetails.PaymentInfo.TransactionID;
                capturePaymentResult.CaptureTransactionResult = "Success";
            }
            else
            {
                capturePaymentResult.CaptureTransactionResult = "Error";
                capturePaymentResult.Errors.Add(result.Errors.FirstOrDefault().LongMessage);
            }

            return(capturePaymentResult);
        }
Example #5
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result    = new CapturePaymentResult();
            var bpManager = new BluePayManager
            {
                AccountId = _bluePayPaymentSettings.AccountId,
                UserId    = _bluePayPaymentSettings.UserId,
                SecretKey = _bluePayPaymentSettings.SecretKey,
                IsSandbox = _bluePayPaymentSettings.UseSandbox,
                MasterId  = capturePaymentRequest.Order.AuthorizationTransactionId,
                Amount    = GetUsdAmount(capturePaymentRequest.Order.OrderTotal).ToString("F", new CultureInfo("en-US"))
            };

            bpManager.Capture();

            if (bpManager.IsSuccessful)
            {
                result.NewPaymentStatus         = PaymentStatus.Paid;
                result.CaptureTransactionId     = bpManager.TransactionId;
                result.CaptureTransactionResult = bpManager.Message;
            }
            else
            {
                result.AddError(bpManager.Message);
            }

            return(result);
        }
 public void PreAuth_CapturePayment_ReturnValidData()
 {
     var client = CreateRapidApiClient();
     //Arrange
     var transaction = TestUtil.CreateTransaction(false);
     var preAuthTransaction = client.Create(PaymentMethod.Direct, transaction);
     //Act
     var preAuthRequest = new CapturePaymentRequest()
     {
         Payment = new Payment()
         {
             CurrencyCode = preAuthTransaction.Transaction.PaymentDetails.CurrencyCode,
             InvoiceDescription = preAuthTransaction.Transaction.PaymentDetails.InvoiceDescription,
             InvoiceNumber = preAuthTransaction.Transaction.PaymentDetails.InvoiceNumber,
             InvoiceReference = preAuthTransaction.Transaction.PaymentDetails.InvoiceReference,
             TotalAmount = preAuthTransaction.Transaction.PaymentDetails.TotalAmount
         },
         TransactionId = preAuthTransaction.TransactionStatus.TransactionID.ToString()
     };
     var preAuthResponse = client.CapturePayment(preAuthRequest);
     //Assert
     Assert.IsNotNull(preAuthResponse);
     Assert.IsTrue(preAuthResponse.TransactionStatus);
     Assert.IsNotNull(preAuthResponse.ResponseMessage);
     Assert.IsNotNull(preAuthResponse.ResponseCode);
     Assert.IsNotNull(preAuthResponse.TransactionID);
 }
Example #7
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            try
            {
                if (capturePaymentRequest == null)
                {
                    throw new ArgumentException(nameof(capturePaymentRequest));
                }

                //capture transaction
                var captureStatus = _sezzleHttpClient.CapturePayment(capturePaymentRequest.Order.OrderGuid.ToString())
                                    .GetAwaiter()
                                    .GetResult();
                if (!captureStatus)
                {
                    throw new NopException("Something went while capturing.");
                }

                //successfully captured
                return(new CapturePaymentResult
                {
                    NewPaymentStatus = PaymentStatus.Paid,
                    CaptureTransactionId = capturePaymentRequest.Order.OrderGuid.ToString(),
                    CaptureTransactionResult = "Payment has been captured successfully"
                });
            }
            catch (Exception e)
            {
                return(new CapturePaymentResult {
                    Errors = new[] { e.Message }
                });
            }
        }
Example #8
0
        public void PreAuth_CapturePayment_ReturnValidData()
        {
            var client = CreateRapidApiClient();
            //Arrange
            var transaction        = TestUtil.CreateTransaction(false);
            var preAuthTransaction = client.Create(PaymentMethod.Direct, transaction);
            //Act
            var preAuthRequest = new CapturePaymentRequest()
            {
                Payment = new Payment()
                {
                    CurrencyCode       = preAuthTransaction.Transaction.PaymentDetails.CurrencyCode,
                    InvoiceDescription = preAuthTransaction.Transaction.PaymentDetails.InvoiceDescription,
                    InvoiceNumber      = preAuthTransaction.Transaction.PaymentDetails.InvoiceNumber,
                    InvoiceReference   = preAuthTransaction.Transaction.PaymentDetails.InvoiceReference,
                    TotalAmount        = preAuthTransaction.Transaction.PaymentDetails.TotalAmount
                },
                TransactionId = preAuthTransaction.TransactionStatus.TransactionID.ToString()
            };
            var preAuthResponse = client.CapturePayment(preAuthRequest);

            //Assert
            Assert.IsNotNull(preAuthResponse);
            Assert.IsTrue(preAuthResponse.TransactionStatus);
            Assert.IsNotNull(preAuthResponse.ResponseMessage);
            Assert.IsNotNull(preAuthResponse.ResponseCode);
            Assert.IsNotNull(preAuthResponse.TransactionID);
        }
Example #9
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError("Common.Payment.NoCaptureSupport");
            return(result);
        }
Example #10
0
        /// <summary>
        /// Captures payment.
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request.</param>
        /// <returns>Capture payment result.</returns>
        public virtual Task <CapturePaymentResult> CaptureAsync(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.Errors.Add(T("Common.Payment.NoCaptureSupport"));
            return(Task.FromResult(result));
        }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError(_localizationService.GetResource("Common.Payment.NoCaptureSupport"));
            return(result);
        }
Example #12
0
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            try
            {
                var stripeCharge = _chargeService.Capture(capturePaymentRequest.Order.AuthorizationTransactionId);

                result.NewPaymentStatus         = PaymentStatus.Paid;
                result.CaptureTransactionResult = stripeCharge.Status;
                result.CaptureTransactionId     = stripeCharge.Id;

                return(result);
            }
            catch (StripeException exception)
            {
                if (!string.IsNullOrEmpty(exception.StripeError.Code))
                {
                    result.AddError(exception.StripeError.Message + " Error code: " + exception.StripeError.Code);
                }
                else
                {
                    result.AddError(exception.StripeError.Message);
                }

                return(result);
            }
        }
Example #13
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            string authorizationId = capturePaymentRequest.Order.AuthorizationTransactionId;
            var    req             = new DoCaptureReq();

            req.DoCaptureRequest                   = new DoCaptureRequestType();
            req.DoCaptureRequest.Version           = GetApiVersion();
            req.DoCaptureRequest.AuthorizationID   = authorizationId;
            req.DoCaptureRequest.Amount            = new BasicAmountType();
            req.DoCaptureRequest.Amount.value      = Math.Round(capturePaymentRequest.Order.OrderTotal, 2).ToString("N", new CultureInfo("en-us"));
            req.DoCaptureRequest.Amount.currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
            req.DoCaptureRequest.CompleteType      = CompleteCodeType.COMPLETE;

            var service = GetService();
            DoCaptureResponseType response = service.DoCapture(req);

            string error;
            bool   success = PaypalHelper.CheckSuccess(response, out error);

            if (success)
            {
                result.NewPaymentStatus         = PaymentStatus.Paid;
                result.CaptureTransactionId     = response.DoCaptureResponseDetails.PaymentInfo.TransactionID;
                result.CaptureTransactionResult = response.Ack.ToString();
            }
            else
            {
                result.AddError(error);
            }
            return(result);
        }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            var config = new HpsServicesConfig();

            config.SecretApiKey  = _secureSubmitPaymentSettings.SecretApiKey;
            config.DeveloperId   = "002914";
            config.VersionNumber = "1513";

            var creditService = new HpsCreditService(config);

            try
            {
                var response = creditService.Capture(Convert.ToInt32(capturePaymentRequest.Order.AuthorizationTransactionId), capturePaymentRequest.Order.OrderTotal);

                result.NewPaymentStatus         = PaymentStatus.Paid;
                result.CaptureTransactionId     = response.TransactionId.ToString();
                result.CaptureTransactionResult = response.ResponseText;
            }
            catch (HpsException ex)
            {
                result.AddError(ex.Message);
            }

            return(result);
        }
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            CapturePaymentResult capture = new CapturePaymentResult();

            capture.AddError("Capture method not supported.");
            return(capture);
        }
Example #16
0
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();
            var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);

            var captureRequest = new CaptureTransactionRequest()
            {
                Amount        = (int)(Math.Round(capturePaymentRequest.Order.OrderTotal, 2) * 100),
                Currency      = primaryStoreCurrency.CurrencyCode,
                Descriptor    = _paylikePaymentSettings.CaptureDescriptor,
                TransactionId = capturePaymentRequest.Order.AuthorizationTransactionId
            };

            var captureResponse = _paylikeTransactionService.CaptureTransaction(captureRequest);

            if (captureResponse.IsError)
            {
                result.AddError(captureResponse.ErrorMessage);
                result.AddError(captureResponse.ErrorContent);
            }
            else
            {
                result.CaptureTransactionId = captureResponse.Content.Id;
                result.NewPaymentStatus     = PaymentStatus.Paid;
            }

            return(result);
        }
Example #17
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public async Task <CapturePaymentResult> Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError("Capture method not supported");
            return(await Task.FromResult(result));
        }
Example #18
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            PayfirmaTransaction         payfirma         = new PayfirmaTransaction();
            PayfirmaTransactionResponse payfirmaResponse =
                payfirma.ProcessCapture(this.PopulateMerchantCredentials(), capturePaymentRequest.Order.AuthorizationTransactionId,
                                        Convert.ToDouble(capturePaymentRequest.Order.OrderTotal), _payfirmaPaymentSettings.IsTest);

            if (!String.IsNullOrEmpty(payfirmaResponse.Error))
            {
                result.AddError(payfirmaResponse.Error);
            }
            else if (!payfirmaResponse.Result)
            {
                result.AddError(payfirmaResponse.ResultMessage);
            }
            else
            {
                result.CaptureTransactionId     = payfirmaResponse.TransactionId;
                result.CaptureTransactionResult = payfirmaResponse.ResultMessage;
                result.NewPaymentStatus         = PaymentStatus.Paid;
            }

            return(result);
        }
Example #19
0
        public CapturePaymentResponse CapturePayment(CapturePaymentRequest captureRequest)
        {
            var request  = _mappingService.Map <CapturePaymentRequest, DirectCapturePaymentRequest>(captureRequest);
            var response = _rapidService.CapturePayment(request);

            return(_mappingService.Map <DirectCapturePaymentResponse, CapturePaymentResponse>(response));
        }
Example #20
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            //var result = new CapturePaymentResult();

            //PrepareAuthorizeNet();

            //var codes = capturePaymentRequest.Order.AuthorizationTransactionCode.Split(',');
            //var transactionRequest = new transactionRequestType
            //{
            //    transactionType = transactionTypeEnum.priorAuthCaptureTransaction.ToString(),
            //    amount = Math.Round(capturePaymentRequest.Order.OrderTotal, 2),
            //    refTransId = codes[0],
            //    currencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
            //};

            //var request = new createTransactionRequest { transactionRequest = transactionRequest };

            //// instantiate the contoller that will call the service
            //var controller = new createTransactionController(request);
            //controller.Execute();

            //// get the response from the service (errors contained if any)
            //var response = controller.GetApiResponse();

            ////validate
            //if (GetErrors(response, result.Errors))
            //    return result;

            //result.CaptureTransactionId = string.Format("{0},{1}", response.transactionResponse.transId, response.transactionResponse.authCode);
            //result.CaptureTransactionResult = string.Format("Approved ({0}: {1})", response.transactionResponse.responseCode, response.transactionResponse.messages[0].description);
            //result.NewPaymentStatus = PaymentStatus.Paid;

            //return result;
            throw new Exception("this method not implemented");
        }
Example #21
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();


            return(result);
        }
Example #22
0
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            if (capturePaymentRequest == null)
            {
                throw new ArgumentNullException(nameof(capturePaymentRequest));
            }

            var currentStore = EngineContext.Current.Resolve <IStoreContext>().CurrentStore;

            stripe.Charge charge = capturePaymentRequest.CreateCapture(this._stripePaymentSettings, currentStore);

            if (charge.GetStatus() == StripeChargeStatus.Succeeded)
            {
                //successfully captured
                return(new CapturePaymentResult
                {
                    NewPaymentStatus = PaymentStatus.Paid,
                    CaptureTransactionId = charge.Id
                });
            }
            else
            {
                //successfully captured
                return(new CapturePaymentResult
                {
                    Errors = new List <string>(new [] { $"An error occured attempting to capture charge {charge.Id}." }),
                    NewPaymentStatus = PaymentStatus.Authorized,
                    CaptureTransactionId = charge.Id
                });
            }
        }
        public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult
            {
                NewPaymentStatus = capturePaymentRequest.Order.PaymentStatus
            };

            var settings = Services.Settings.LoadSetting <TSetting>(capturePaymentRequest.Order.StoreId);
            var session  = new PayPalSessionData();

            var apiResult = PayPalService.EnsureAccessToken(session, settings);

            if (apiResult.Success)
            {
                apiResult = PayPalService.Capture(settings, session, capturePaymentRequest);

                if (apiResult.Success)
                {
                    result.NewPaymentStatus = PaymentStatus.Paid;
                }
            }

            if (!apiResult.Success)
            {
                result.Errors.Add(apiResult.ErrorMessage);
            }

            return(result);
        }
        /// <summary>
        /// https://{{providerApiEndpoint}}/payments/{{paymentId}}/settlements
        /// </summary>
        /// <param name="paymentId">VTEX payment ID from this payment</param>
        /// <param name="capturePaymentRequest"></param>
        /// <returns></returns>
        public async Task <IActionResult> CapturePayment(string paymentId)
        {
            var bodyAsText = await new System.IO.StreamReader(HttpContext.Request.Body).ReadToEndAsync();
            CapturePaymentRequest capturePaymentRequest = JsonConvert.DeserializeObject <CapturePaymentRequest>(bodyAsText);
            var captureResponse = await this._flowFinancePaymentService.CapturePaymentAsync(capturePaymentRequest);

            return(Json(captureResponse));
        }
        public static PtsV2PaymentsCapturesPost201Response Run()
        {
            ServiceFeesWithCreditCardTransaction.CaptureTrueForProcessPayment = false;
            var id = ServiceFeesWithCreditCardTransaction.Run().Id;

            string clientReferenceInformationCode = "TC50171_3";
            Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
                Code: clientReferenceInformationCode
                );

            string orderInformationAmountDetailsTotalAmount      = "2325.00";
            string orderInformationAmountDetailsCurrency         = "USD";
            string orderInformationAmountDetailsServiceFeeAmount = "30.00";
            Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency,
                ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount
                );

            Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation(
                AmountDetails: orderInformationAmountDetails
                );

            string merchantInformationServiceFeeDescriptorName    = "Vacations Service Fee";
            string merchantInformationServiceFeeDescriptorContact = "8009999999";
            string merchantInformationServiceFeeDescriptorState   = "CA";
            Ptsv2paymentsMerchantInformationServiceFeeDescriptor merchantInformationServiceFeeDescriptor = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor(
                Name: merchantInformationServiceFeeDescriptorName,
                Contact: merchantInformationServiceFeeDescriptorContact,
                State: merchantInformationServiceFeeDescriptorState
                );

            Ptsv2paymentsidcapturesMerchantInformation merchantInformation = new Ptsv2paymentsidcapturesMerchantInformation(
                ServiceFeeDescriptor: merchantInformationServiceFeeDescriptor
                );

            var requestObj = new CapturePaymentRequest(
                ClientReferenceInformation: clientReferenceInformation,
                OrderInformation: orderInformation,
                MerchantInformation: merchantInformation
                );

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new CaptureApi(clientConfig);
                PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, id);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
Example #26
0
        public async Task <IActionResult> CapturePayment([FromQuery] CapturePaymentRequest request)
        {
            var response = await mediator.Send(request);

            Log.Information(
                $"User #{HttpContext.GetCurrentUserId()} captured payment with token: {request.Token} and verified with status: {(response.IsVerified ? "VERIFIED" : "NOT VERIFIED")}");

            return(this.CreateResponse(response));
        }
Example #27
0
        /// <summary>
        /// Capture a Payment Include the payment ID in the POST request to capture the payment amount.
        /// </summary>
        /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="capturePaymentRequest"></param>
        /// <param name="id">The payment ID returned from a previous payment request. This ID links the capture to the payment. </param>
        /// <returns>PtsV2PaymentsCapturesPost201Response</returns>
        public PtsV2PaymentsCapturesPost201Response CapturePayment(CapturePaymentRequest capturePaymentRequest, string id)
        {
            logger.Debug("CALLING API \"CapturePayment\" STARTED");
            this.SetStatusCode(null);
            ApiResponse <PtsV2PaymentsCapturesPost201Response> localVarResponse = CapturePaymentWithHttpInfo(capturePaymentRequest, id);

            logger.Debug("CALLING API \"CapturePayment\" ENDED");
            this.SetStatusCode(localVarResponse.StatusCode);
            return(localVarResponse.Data);
        }
 public override CapturePaymentRequestResult CaptureProcessPayment(CapturePaymentRequest request)
 {
     //TODO
     //context.Payment.IsApproved = true;
     //context.Payment.PaymentStatus = PaymentStatus.Paid;
     //context.Payment.VoidedDate = DateTime.UtcNow;
     return(new CapturePaymentRequestResult {
         IsSuccess = true, NewPaymentStatus = PaymentStatus.Paid
     });
 }
        public static PtsV2PaymentsCapturesPost201Response Run()
        {
            var    processPaymentId = RestaurantAuthorization.Run().Id;
            string clientReferenceInformationCode = "1234567890";
            string clientReferenceInformationPartnerThirdPartyCertificationNumber            = "123456789012";
            Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner(
                ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber
                );

            Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
                Code: clientReferenceInformationCode,
                Partner: clientReferenceInformationPartner
                );

            string processingInformationIndustryDataType = "restaurant";
            Ptsv2paymentsidcapturesProcessingInformation processingInformation = new Ptsv2paymentsidcapturesProcessingInformation(
                IndustryDataType: processingInformationIndustryDataType
                );

            string orderInformationAmountDetailsTotalAmount    = "100";
            string orderInformationAmountDetailsCurrency       = "USD";
            string orderInformationAmountDetailsGratuityAmount = "11.50";
            Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency,
                GratuityAmount: orderInformationAmountDetailsGratuityAmount
                );

            Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation(
                AmountDetails: orderInformationAmountDetails
                );

            var requestObj = new CapturePaymentRequest(
                ClientReferenceInformation: clientReferenceInformation,
                ProcessingInformation: processingInformation,
                OrderInformation: orderInformation
                );

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new CaptureApi(clientConfig);

                PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, processPaymentId);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
        public static PtsV2PaymentsCapturesPost201Response Run()
        {
            var processPaymentId = ProcessPayment.Run().Id;

            var requestObj = new CapturePaymentRequest();

            var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation
            {
                Code = "test_capture"
            };

            requestObj.ClientReferenceInformation = clientReferenceInformationObj;

            var orderInformationObj = new Ptsv2paymentsidcapturesOrderInformation();

            var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo
            {
                Country            = "US",
                FirstName          = "John",
                LastName           = "Doe",
                Address1           = "1 Market St",
                PostalCode         = "94105",
                Locality           = "San Francisco",
                AdministrativeArea = "CA",
                Email = "*****@*****.**"
            };

            orderInformationObj.BillTo = billToObj;

            var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails
            {
                TotalAmount = "102.21",
                Currency    = "USD"
            };

            orderInformationObj.AmountDetails = amountDetailsObj;

            requestObj.OrderInformation = orderInformationObj;

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new CaptureApi(clientConfig);

                var result = apiInstance.CapturePayment(requestObj, processPaymentId);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
                return(null);
            }
        }
Example #31
0
        public virtual async Task <IList <string> > CaptureAsync(Order order)
        {
            Guard.NotNull(order, nameof(order));

            if (!await CanCaptureAsync(order))
            {
                throw new SmartException(T("Order.CannotCapture"));
            }

            CapturePaymentResult result = null;

            try
            {
                var request = new CapturePaymentRequest
                {
                    Order = order
                };

                result = await _paymentService.CaptureAsync(request);

                if (result.Success)
                {
                    var paidDate = result.NewPaymentStatus == PaymentStatus.Paid ? DateTime.UtcNow : order.PaidDateUtc;

                    order.CaptureTransactionId     = result.CaptureTransactionId;
                    order.CaptureTransactionResult = result.CaptureTransactionResult;
                    order.PaymentStatus            = result.NewPaymentStatus;
                    order.PaidDateUtc = paidDate;

                    order.AddOrderNote(T("Admin.OrderNotice.OrderCaptured"));

                    // INFO: CheckOrderStatus performs commit.
                    await CheckOrderStatusAsync(order);

                    if (order.PaymentStatus == PaymentStatus.Paid)
                    {
                        await _eventPublisher.PublishOrderPaidAsync(order);
                    }
                }
            }
            catch (Exception ex)
            {
                result ??= new();
                result.Errors.Add(ex.ToAllMessages());
            }

            if (result.Errors.Any())
            {
                ProcessErrors(order, result.Errors, "Admin.OrderNotice.OrderCaptureError");
                await _db.SaveChangesAsync();
            }

            return(result.Errors);
        }
Example #32
0
 public CapturePaymentResponse Capture(CapturePaymentRequest capturePaymentRequest)
 {
     var paymentMethod = GetPaymentMethodByKey(capturePaymentRequest.Order.PaymentMethod);
     return paymentMethod.Capture(capturePaymentRequest);
 }
 public CapturePaymentResponse Capture(CapturePaymentRequest capturePaymentRequest)
 {
     var result = new CapturePaymentResponse();
     result.AddError("Capture method not supported");
     return result;
 }