Magento API 的创建发票方法无法正常工作

编程入门 行业动态 更新时间:2024-10-25 00:25:08
本文介绍了Magento API 的创建发票方法无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用 XMLRPC 在 android 应用程序中使用 Magento API 创建销售订单发票.我正在使用方法sales_order_invoice.create"来创建发票.此方法在magento wiki 中提到的给定数量的响应.但是问题是 magento 商店中的发票数量未更新.另一件事是订单状态正在更改为正在处理,这是正确的,并且已创建发票的条目也存在于商店的发票列表中,但将支付金额显示为 $0.0 这是不正确的.

I am trying to create sales order Invoice using Magento API in android application using XMLRPC.I am using the method "sales_order_invoice.create" for creating invoice.This method is giving me Invoice Id in the response for given quantity as mention in magento wiki.But the problem is that the Invoice qty isn't updated on magento store.Other thing is Order status is changing to Processing which is correct and the entry of created invoice is also present in invoice list of store but It is displaying the paid amount as $0.0 which is not correct.

不知道在调用sales_order_invoice.create之前是否需要调用其他方法或者方法有问题??
下面是我调用方法的部分代码:

I don't know if I need to call another method before calling sales_order_invoice.create or is there any problem in the method??
Below is some part of my code for calling method:

import java.util.HashMap;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class MagentoStore extends Activity {

private XMLRPCClient client;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
            String sessionId = "";


client = new XMLRPCClient("http://www.mystore/index.php/api/xmlrpc");
        try {

            sessionId = (String)client.call("login", "tester", "tester");
            Log.d("MY_XMLRPC_SUCCESS_SESSION_ID", sessionId);
            }
         catch (XMLRPCException e) {

            Log.d("MY_XMLRPCException_MSG", e.getMessage());
        }

        Object salesorderInfo = null;
        Object[] methodParams = new Object[]{"100000028"};
        Object[] callParams = new Object[]{sessionId,"sales_order.info", methodParams};
        String salesorderinvoice= null;
        try {
             salesorderInfo = (Object)client.callEx("call",callParams);
             HashMap map = (HashMap)salesorderInfo;
             Object[]items=(Object[])map.get("items");
             for(Object item :items)
             {
                 HashMap itemlist=(HashMap)item;
                 String item_id=(String)itemlist.get("item_id");
                 int itemids=Integer.parseInt(item_id);
                 String base_price=(String)itemlist.get("base_price");
                 if(base_price.equals("0.0000"))
                 {
                  continue;  
                 }   
                 String name=(String)itemlist.get("name");
                 Double qty=1.0;
                 String qty_ordered =(String)itemlist.get("qty_ordered");
                 String qty_invoiced=(String)itemlist.get("qty_invoiced");
                 Object[] methodParams1 = new Object[]{"100000028",itemids,qty};
                 Object[] callParams1 = new Object[]{sessionId,"sales_order_invoice.create", methodParams1};
                 salesorderinvoice= (String)client.callEx("call",callParams1);

             } 
            } catch (Exception e) {
            Log.d("APP_INFO", "Exception: " + e.getMessage());
            }               
    }
}

有人有什么想法吗??提前致谢

Anyone have any Idea?? Thanks in advance

推荐答案

仅供参考

调用 API sales_order_invoice.create 时,必须分配数组指针名称.

when you call the API sales_order_invoice.create, you must assign the array pointer name.

String qty_ordered =(String)itemlist.get("qty_ordered");
                 String qty_invoiced=(String)itemlist.get("qty_invoiced");
                 Object[] methodParams1 = new Object[]{"100000028",itemids,qty};

尝试使用

methodParams1.toString();

必须与

array(
      'orderIncrementId' => '200000008', 
      array(
            'order_item_id' => '11', 
            'qty' => '1'
      )
);

因为这是将参数放入sales_order_invoice.create

$result = $client->call(
    $session,
    'sales_order_invoice.create',
    array('orderIncrementId' => '200000008', array('order_item_id' => '11', 'qty' => '1'))
);

这篇关于Magento API 的创建发票方法无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 07:12:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/932690.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   发票   方法   工作   Magento

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!