How to proceed to complete the pending payments

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hi and thanks for this great work !!
All is in title : How to proceed to complete the pending payments.
I have a list of pending payments for clients who don't cancel their order but didn't pay on paypal web site.
I think that i can add Complete Payment button on Customers Orders pages. But how can i link my bouton with the appropriate payment method (Paypal).
Thank you !!
13 年 前
Hi !!
Here is my code if it help someone:

CustomerOrders.ascx

<tr>
                               <td colspan="2">
                               <table cellspacing="0" cellpadding="2" border="0">
                                    <tbody>
                                        <div><b><%=GetLocaleResourceString("PDFInvoice.OrderDetails")%></b></div>
                                        <div>
                                            <%=GetLocaleResourceString("Admin.OrderDetails.PaymentMethod")%>
                                            <%#GetPaymentMethod(Container.DataItem as Order) %>
                                        </div>
                                        <div>
                                            <%=GetLocaleResourceString("Admin.OrderDetails.PaymentStatus")%>:
                                            <%#GetPaymentStatus(Container.DataItem as Order)%>
                                        </div>
                                        <div>
                                            <%=GetLocaleResourceString("PDFInvoice.Paidamount")%>:
                                            <%#GetPaidAmount(Container.DataItem as Order)%>
                                        </div>
                                        <div>
                                            <%=GetLocaleResourceString("PDFInvoice.Remainingamount")%>:
                                            <%#GetRemainingAmount(Container.DataItem as Order)%>
                                        </div>
                                        <div>
                                        <br />
                                        
                                        <asp:Button runat="server" ID="btnPaiement" OnCommand="btnPaiement_Click"
                                        Text="<% $NopResources:Common.Payment %>" ValidationGroup="OrderDetails" CommandArgument='<%# Eval("OrderId") %>'
                                        CssClass="orderdetailsbutton" Visible='<%#GetRemainingAmount(Container.DataItem as Order) != "0,00 $" %>' />
                                        
                                        </div>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>



CutomerOrders.cs

protected string GetPaymentMethod(Order order)
        {
            return (order.PaymentMethodName);
        }
        
        
        protected string GetPaymentStatus(Order order)
        {
            var OrderPaymentStatus = "";
            if (order.PaymentStatusId == 10) // En attente
            {
                OrderPaymentStatus = "En attente";
            }
            else if (order.PaymentStatusId == 30) // Payé
            {
                if (order.PaymentMethodId.Equals(2) || order.PaymentMethodId.Equals(17)) // Paiement complet
                {
                  OrderPaymentStatus = "Paiement complet";
                }
                else if (order.PaymentMethodId.Equals(40) || order.PaymentMethodId.Equals(41)) // Depot 20%
                {
                  OrderPaymentStatus = "Paiement partiel (Dépôt de 20%)";
                }
            }

            return OrderPaymentStatus;
        }

        protected string GetPaidAmount(Order order)
        {
            var OrderPaidAmount = 0m;

            if (order.PaymentStatusId == 10) // En attente
            {
                OrderPaidAmount = 0;
            }
            else if (order.PaymentStatusId == 30) // Payé
            {
                if (order.PaymentMethodId.Equals(2) || order.PaymentMethodId.Equals(17)) // Paiement complet
                {
                    OrderPaidAmount = order.OrderTotalInCustomerCurrency;
                }
                else if (order.PaymentMethodId.Equals(40) || order.PaymentMethodId.Equals(41)) // Depot 20%
                {
                    OrderPaidAmount = order.OrderTotalInCustomerCurrency * 0.2m;
                }
            }

            return PriceHelper.FormatPrice(OrderPaidAmount, true, order.CustomerCurrencyCode, false);
        }

        
        protected string GetRemainingAmount(Order order)
        {
            var OrderRemainingAmount = 0m;

            if (order.PaymentStatusId == 10) // En attente
            {
                OrderRemainingAmount = order.OrderTotalInCustomerCurrency;
            }
            else if (order.PaymentStatusId == 30) // Payé
            {
                if (order.PaymentMethodId.Equals(2) || order.PaymentMethodId.Equals(17)) // Paiement complet
                {
                    OrderRemainingAmount = 0;
                }
                else if (order.PaymentMethodId.Equals(40) || order.PaymentMethodId.Equals(41)) // Depot 20%
                {
                    OrderRemainingAmount = order.OrderTotalInCustomerCurrency * 0.8m;
                }
            }

            return PriceHelper.FormatPrice(OrderRemainingAmount, true, order.CustomerCurrencyCode, false);
        }

        protected decimal GetRemainingAmount(Order order, bool price)
        {
            var OrderRemainingAmount = 0m;

            if (order.PaymentStatusId == 10) // En attente
            {
                OrderRemainingAmount = order.OrderTotalInCustomerCurrency;
            }
            else if (order.PaymentStatusId == 30) // Payé
            {
                if (order.PaymentMethodId.Equals(2) || order.PaymentMethodId.Equals(17)) // Paiement complet
                {
                    OrderRemainingAmount = 0;
                }
                else if (order.PaymentMethodId.Equals(40) || order.PaymentMethodId.Equals(41)) // Depot 20%
                {
                    OrderRemainingAmount = order.OrderTotalInCustomerCurrency * 0.8m;
                }
            }

            return OrderRemainingAmount;
        }
        //

        protected void btnPaiement_Click(object sender, CommandEventArgs e)
        {
            int orderId = Convert.ToInt32(e.CommandArgument);
            Order order = new Order();
            order = OrderManager.GetOrderById(orderId);
                      
            if (Page.IsValid)
            {                
                try
                {
                    var paymentInfo = new PaymentInfo();
                    
                    paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress;
                    paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency;
                    paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage;
                    paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress;
                    paymentInfo.PaymentMethodId = 40;
                    paymentInfo.OrderTotal = GetRemainingAmount(order, false);
                    
                    
                    order.PaymentMethodId = paymentInfo.PaymentMethodId;
                    order.OrderTotal = paymentInfo.OrderTotal;
                    order.PaymentMethodName = "Paypal - Paiement complet (20% + 80%)";
                    
                                      
                    OrderManager.UpdateOrder(order.OrderId, order.OrderGuid, order.CustomerId, order.CustomerLanguageId, order.CustomerTaxDisplayType, order.CustomerIP, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax, order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax, order.OrderTax, order.OrderTotal, order.OrderDiscount, order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderSubtotalExclTaxInCustomerCurrency, order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.OrderDiscountInCustomerCurrency, order.CheckoutAttributeDescription, order.CheckoutAttributesXml, order.CustomerCurrencyCode, order.OrderWeight, order.AffiliateId, order.OrderStatus, order.AllowStoringCreditCardNumber, order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber, order.CardCvv2, order.CardExpirationMonth, order.CardExpirationYear, order.PaymentMethodId, order.PaymentMethodName, order.AuthorizationTransactionId, order.AuthorizationTransactionCode, order.AuthorizationTransactionResult, order.CaptureTransactionId, order.CaptureTransactionResult, order.SubscriptionTransactionId, order.PurchaseOrderNumber, order.PaymentStatus, order.PaidDate, order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber, order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1, order.BillingAddress2, order.BillingCity, order.BillingStateProvince, order.BillingStateProvinceId, order.BillingZipPostalCode, order.BillingCountry, order.BillingCountryId, order.ShippingStatus, order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber, order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany, order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity, order.ShippingStateProvince, order.ShippingStateProvinceId, order.ShippingZipPostalCode, order.ShippingCountry, order.ShippingCountryId, order.ShippingMethod, order.ShippingRateComputationMethodId, order.ShippedDate, order.TrackingNumber, order.Deleted, order.CreatedOn, order.OrderRemaining);
                    PaymentManager.PostProcessPayment(order);
                }
                catch (Exception exc)
                {
                    LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc);
                }
            }

13 年 前
i cannot help you but i agree with you, it's impossible to do not add a complet payement button on customer account ! I'm looking for a solution too ;)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.