Search code examples
magentomagento-soap-api

Magento SOAP V_2 creating order error: Payment not allowed


I am trying to create an order on Magento 1.7.2 using SOAP API V_2 using .NET consol.

I am always getting the same error "Payment not allowerd" using every payment method.

//create an order with Magento API

        MagentoService proxy = new MagentoService();
        string sessionId = proxy.login("xxx", "xxx");
        int idCarrello = proxy.shoppingCartCreate(sessionId, "1");
        proxy.UnsafeAuthenticatedConnectionSharing = false;

        shoppingCartCustomerEntity clienteMagento = new shoppingCartCustomerEntity();

        clienteMagento.firstname = "name";
        clienteMagento.lastname = "surname";
        clienteMagento.email = "[email protected]";
        clienteMagento.mode = "guest";

        proxy.shoppingCartCustomerSet(sessionId, idCarrello, clienteMagento, "1");

        shoppingCartCustomerAddressEntity indirizzoSpedizione = new shoppingCartCustomerAddressEntity();
        shoppingCartCustomerAddressEntity indirizzoBill = new shoppingCartCustomerAddressEntity();


        indirizzoSpedizione.mode = "shipping";
        indirizzoSpedizione.firstname = clienteMagento.firstname;
        indirizzoSpedizione.lastname = clienteMagento.lastname;
        indirizzoSpedizione.street = "viale europa 32";
        indirizzoSpedizione.city = "Foggia";

        indirizzoSpedizione.region = "FG";
        indirizzoSpedizione.telephone = "111";
        indirizzoSpedizione.postcode = "71122";
        indirizzoSpedizione.country_id = "IT";
        indirizzoSpedizione.is_default_billing = 0;
        indirizzoSpedizione.is_default_shipping = 0;

        indirizzoBill.mode = "billing";
        indirizzoBill.firstname = clienteMagento.firstname;
        indirizzoBill.lastname = clienteMagento.lastname;
        indirizzoBill.street = "viale europa 32";
        indirizzoBill.city = "Foggia";

        indirizzoBill.region = "FG";
        indirizzoBill.telephone = "111";
        indirizzoBill.postcode = "71122";
        indirizzoBill.country_id = "IT";
        indirizzoBill.is_default_billing = 0;
        indirizzoBill.is_default_shipping = 0;

        shoppingCartCustomerAddressEntity[] indirizzi = new shoppingCartCustomerAddressEntity[] { indirizzoSpedizione, indirizzoBill };

        proxy.shoppingCartCustomerAddresses(sessionId, idCarrello, indirizzi, "1");
        proxy.shoppingCartShippingMethod(sessionId, idCarrello, "flatrate_flatrate", "1");

        shoppingCartPaymentMethodResponseEntity[] paymentMethods = proxy.shoppingCartPaymentList(sessionId, idCarrello, "1");

        Console.WriteLine(paymentMethods); //paymentMethods is always empty!!

        shoppingCartPaymentMethodEntity modoPagamento = new shoppingCartPaymentMethodEntity();

        modoPagamento.po_number = null;
        modoPagamento.method = "checkmo";
        modoPagamento.cc_cid = null;
        modoPagamento.cc_owner = null;
        modoPagamento.cc_number = null;
        modoPagamento.cc_type = null;
        modoPagamento.cc_exp_year = null;
        modoPagamento.cc_exp_month = null;

        proxy.shoppingCartPaymentMethod(sessionId, idCarrello, modoPagamento, "1");

Here is the Exception:

         //Payment method is not allowed (I tryed checkmo, banktransfer, etc)
        //proxy.shoppingCartOrder(sessionId, idCarrello, "1", new string[] { });

Any idea?


Solution

  • Ifaced with the saeme issue. This is the solution - You forgot product, just add product to sale. Also you must do it according to this order (it will not works in other order):

    shoppingCartCustomerSet(guest for simplicity);
    shoppingCartCustomerAddresses();
    shoppingCartProductAdd();
    shoppingCartShippingMethod();
    shoppingCartPaymentMethod();