/// <summary> /// Executes the charge operation. /// </summary> /// <param name="paymentInfo">The payment info.</param> public void ExecuteCharge(Litium.Foundation.Modules.ECommerce.Payments.PaymentInfo paymentInfo) { bool isRedirected = false; try { // If the order is already reserved, CanCompleteTransaction will be true. // Call complete transaction on the already reserved order, else call direct charge customer account. if (paymentInfo.PaymentProvider.CanCompleteCurrentTransaction) paymentInfo.PaymentProvider.CompletePayment(new DirectPayCompletePaymentArgs(), FoundationContext.Token); else { DirectPayPaymentArgs args = new DirectPayPaymentArgs(); args.PaymentMode = ExecutePaymentMode.Charge; args.UserHostAddress = Request.UserHostAddress; paymentInfo.PaymentProvider.ExecutePayment(args, FoundationContext.Token); } } catch (PaymentProviderException) { } if (!isRedirected) { Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2"); } }
/// <summary> /// Creates the payment args. /// </summary> /// <param name="checkoutFlowInfo">The checkout flow info.</param> /// <param name="paymentProviderType">Type of the payment provider.</param> /// <returns>Instance of <see cref="ExecutePaymentArgs"/> if checkout info can be /// converted to <see cref="ExtendedCheckoutFlowInfo"/> else a null reference.</returns> public virtual ExecutePaymentArgs CreatePaymentArgs(CheckoutFlowInfo checkoutFlowInfo) { DirectPayPaymentArgs args = new DirectPayPaymentArgs(); //store end-users IP address HttpContext currentContext = HttpContext.Current; if (currentContext != null && currentContext.Request != null) args.UserHostAddress = HttpContext.Current.Request.UserHostAddress; //set the payment mode if its being set, otherwise leave it at its default value. if (checkoutFlowInfo.ExecutePaymentMode != ExecutePaymentMode.Unset) args.PaymentMode = checkoutFlowInfo.ExecutePaymentMode; return args; }
/// <summary> /// Executes the reserve operation. /// </summary> /// <param name="paymentInfo">The payment info.</param> public void ExecuteReserve(Litium.Foundation.Modules.ECommerce.Payments.PaymentInfo paymentInfo) { bool isRedirected = false; try { DirectPayPaymentArgs args = new DirectPayPaymentArgs(); args.PaymentMode = ExecutePaymentMode.Reserve; args.UserHostAddress = Request.UserHostAddress; paymentInfo.PaymentProvider.ExecutePayment(args, FoundationContext.Token); } catch (PaymentProviderException) { } if (!isRedirected) { Response.Redirect(UrlConstants.VIEW_PAYMENT + "?" + ParameterConstants.ECOM_SELECTED_NAVBAR_PAGE + "=" + ((int)Litium.Studio.UI.ECommerce.Common.Enums.FilterType.Payments).ToString() + "&" + ParameterConstants.FROM_PAYMENT + "=true&" + ParameterConstants.ECOM_ORDER_ID + "=" + paymentInfo.OrderID + "&" + ParameterConstants.ECOM_PAYMENT_INFO_ID + "=" + paymentInfo.ID + "&" + ParameterConstants.QUERY_STRING_NAVIGATE_FROM + "=2"); } }