Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Sep 26, 2012 @ 17:55
    Alex Skrypnyk
    0

    PayPal payment

    Hi Umbraco developers,

    We solve problem with crash, now we have worked PayPal payment. But,

    Orders doesn't appears in ucommerce admin part,

    Code of order creation : 

     

                    catalog = ProductCatalog.Get(catalogId);
    
                    SiteContext.Current.CatalogContext.CurrentCatalogName = catalog.Name;
    
                    Product product = Product.Get(Convert.ToInt32(e.CommandArgument));
    
                    Basket basket = SiteContext.Current.OrderContext.NewBasket(Currency.FirstOrDefault(x => x.ExchangeRate == 100));
    
                    PurchaseOrder purchaseOrder = basket.PurchaseOrder;
    
                    purchaseOrder.AddProduct(catalog, product, 1);
    
                    var userService = new UserService();
                    var profile = userService.GetCurrentUserProfile();
    
                    Library.ExecuteBasketPipeline();
    
                    var address = purchaseOrder.BillingAddress ?? new OrderAddress();
                    address.AddressName = "Billing";
                    address.FirstName = profile.FirstName;
                    address.LastName = profile.LastName;
                    address.EmailAddress = profile.UserName;
                    address.PhoneNumber = profile.PhoneNumber;
                    address.MobilePhoneNumber = "mobilePhoneNumber";
                    address.CompanyName = "company";
                    address.Line1 = "line1";
                    address.Line2 = "line2";
                    address.PostalCode = profile.Zip;
                    address.City = profile.City;
                    address.State = profile.State;
                    address.Country = Country.FirstOrDefault(x => x.Name == "Great Britain");
                    address.PurchaseOrder = purchaseOrder;
    
                    Customer customer = Customer.Create(address);
    
                    purchaseOrder.Customer = customer;
                    purchaseOrder.BillingAddress = address;
                    purchaseOrder.Save(); // Saves cascade to children, so the address is saved as well
    
                    var paymentMethod = PaymentMethod.All().Single(x => x.Name == "PayPal");
    
                    var service = paymentMethod.GetPaymentMethodService();
    
                    var paymentFactory = paymentMethod.GetPaymentMethodService() as IPaymentFactory;
                    Payment payment = paymentFactory.CreatePayment(new PaymentRequest(purchaseOrder, paymentMethod,
                      new Money(purchaseOrder.OrderTotal.Value, purchaseOrder.BillingCurrency)));
    
                    payment.Save();
    
                    payment = service.RequestPayment(new PaymentRequest(purchaseOrder, paymentMethod,
                      new Money(purchaseOrder.OrderTotal.Value, purchaseOrder.BillingCurrency)));
    

    Please help us ))

     

    Thanks,

    Alexandr

  • Fabio Milheiro 74 posts 136 karma points
    Oct 29, 2012 @ 18:31
    Fabio Milheiro
    0

    Hi Alex,

    Did you find an answer to this?

    Thanks,

    Fab

Please Sign in or register to post replies

Write your reply to:

Draft