3
votes

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?

1
Do you have the payment methods enabled in the admin config, and do they work when you do a checkout whilst just browsing the web-site not via soap? My guess is the payment methods are not enabled for the store view/web-site you are creating the cart in as you are not getting any payment methods back in your cart payment list call. You could try doing int idCarrello = proxy.shoppingCartCreate(sessionId);. Also the final param store view is normally a code like en_gb and not a number.Ashley Swatton

1 Answers

2
votes

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();