2014-10-31 82 views
1

我試圖使用Acumatica Web服務API創建銷售訂單。我已經能夠通過除付款設置以外的所有必填字段。我們的安裝使用Authorize.NET(PX.CCProcessing.AuthorizeNetTokenizedProcessing)加載項。是否可以通過API與Authorize.NET加載項進行交互,方法是創建新的付款方式並授權付款,以便員工可以從Acumatica內部處理訂單並在那裏捕獲付款。如何通過Acumatica API創建包含付款設置的銷售訂單

以下是我用來創建我的銷售訂單的代碼。我不確定要通過API本身激活「創建新的付款資料ID」操作的結構。通過GUI,它打開一個彈出窗口,將該卡複製到Authorize.Net並在Acumatica中保存一個支付配置文件ID記錄。


 SO301000Content SO301000 = context.SO301000GetSchema(); 
     context.SO301000Clear(); 
     SO301000Content[] SO30100content = context.SO301000Submit 
     (
      new Command[] 
      { 
       //add header info 
       new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType }, 
       new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr }, 
       new Value { Value = "999999", LinkedCommand = SO301000.OrderSummary.Customer }, 

       //add line items 
       SO301000.DocumentDetails.ServiceCommands.NewRow, 
       new Value { Value = "SS1121", LinkedCommand = SO301000.DocumentDetails.InventoryID }, 
       new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity }, 
       SO301000.DocumentDetails.ServiceCommands.NewRow, 
       new Value { Value = "SS1122", LinkedCommand = SO301000.DocumentDetails.InventoryID }, 
       new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity }, 
       SO301000.DocumentDetails.ServiceCommands.NewRow, 
       new Value { Value = "SS1123", LinkedCommand = SO301000.DocumentDetails.InventoryID }, 
       new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity }, 

       //add shipping information 
       new Value { Value = "True", LinkedCommand = SO301000.ShippingSettingsShipToInfoOverrideContact.OverrideContact }, 
       new Value { Value = "DEMO CHURCH SHIP", LinkedCommand = SO301000.ShippingSettingsShipToInfoOverrideContact.BusinessName }, 
       new Value { Value = "True", LinkedCommand = SO301000.ShippingSettingsShipToInfo.OverrideAddress }, 
       new Value { Value = "123 TEST STREET", LinkedCommand = SO301000.ShippingSettingsShipToInfo.AddressLine1 }, 
       new Value { Value = "BUFORD", LinkedCommand = SO301000.ShippingSettingsShipToInfo.City }, 
       new Value { Value = "GA", LinkedCommand = SO301000.ShippingSettingsShipToInfo.State }, 
       new Value { Value = "30519", LinkedCommand = SO301000.ShippingSettingsShipToInfo.PostalCode }, 
       new Value { Value = "FREESHIP", LinkedCommand = SO301000.ShippingSettingsShippingInformation.ShipVia }, 

       //add totals 
       new Value { Value = "10.00", LinkedCommand = SO301000.Totals.PremiumFreight }, 
       new Value { Value = "94.0000", LinkedCommand = SO301000.Totals.PackageWeight }, 

       //add payment 

       SO301000.Actions.Save, 
       SO301000.OrderSummary.OrderNbr 
      } 
     ); 

新代碼錯誤 - 我現在可以嘗試該卡插入到現有的銷售訂單時,插入客戶付款記錄,但收到一個錯誤。

這裏是我的代碼:

 SO301000Content SO301000 = context.SO301000GetSchema(); 
     context.SO301000Clear(); 
     SO301000Content[] SO30100content = context.SO301000Submit 
     (
      new Command[] 
       { 
        //add header info 
        new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType }, 
        new Value { Value = "000129", LinkedCommand = SO301000.OrderSummary.OrderNbr }, 
        //add payment 
        new Value { Value = "VISA", LinkedCommand = SO301000.PaymentSettings.PaymentMethod }, 
        new Value { Value = "VISA:****-****-****-7261", LinkedCommand = SO301000.PaymentSettings.CardAccountNo }, 

        SO301000.Actions.Save 
       } 
     ); 

如果任何人有任何想法,我將不勝感激。謝謝。

+0

您能否提供示例源代碼來顯示您正在做什麼,以及詳細描述您遇到的錯誤? – Gabriel 2014-10-31 01:21:17

+0

我已編輯我的帖子以包含當前的代碼以創建新的銷售訂單。我並沒有真正遇到錯誤,因爲我不確定添加卡並通過Authorize.NET插件連接它的步驟。 – 2014-10-31 03:44:16

+0

Thx,我正在努力:) – Gabriel 2014-10-31 15:34:03

回答

2

您不能使用「創建新的付款配置文件ID」,因爲它依賴於網頁瀏覽器中的實際用戶(我們只是在IFRAME中顯示Authorize.net新的配置文件頁面)。我們這樣做是爲了限制應用程序暴露給PCI合規性,這樣就不會有信用卡號碼或敏感信息觸及Acumatica服務器。您應該直接通過Authorize.net CIM站點或CIM API添加付款配置文件,並將配置文件ID傳遞給Acumatica。

不幸的是,您無法直接將客戶配置文件ID傳遞給訂單,只有付款配置文件值被接受爲輸入,因此您首先需要使用客戶付款方式屏幕API添加條目。

 AR303010Content AR301000 = context.AR303010GetSchema(); 
     context.AR303010Clear(); 
     AR303010Content[] AR303010content = context.AR303010Submit(
      new Command[] 
      { 
       new Value { Value = "999999", LinkedCommand = AR301000.PaymentMethodSelection.Customer }, 
       new Value { Value = "VISATOK", LinkedCommand = AR301000.PaymentMethodSelection.PaymentMethod }, 
       new Value { Value = "AUTHTOK", LinkedCommand = AR301000.PaymentMethodSelection.ProcCenterID }, 
       new Value { Value = "102000", LinkedCommand = AR301000.PaymentMethodSelection.CashAccount }, 
       new Value { Value = "23640304", LinkedCommand = AR301000.PaymentMethodSelection.CustomerProfileID }, 
       new Value { Value = "27187006", FieldName = "Value", ObjectName = "ccpIdDet"}, //Payment Profile ID, going directly to internal ccpIdDet view to bypass validation error when using AR301000.PaymentMethodDetails.Value 
       AR301000.Actions.Save, 
       AR301000.PaymentMethodSelection.CardAccountNo 
      }); 

     string cardAccountNo = AR303010content[0].PaymentMethodSelection.CardAccountNo.Value; 

然後,當你創建銷售訂單,你只需要指定要使用哪張牌,通過AR301000創建過程後返回的:

  //add payment 
     new Value { Value = "VISATOK", LinkedCommand = SO301000.PaymentSettings.PaymentMethod }, 
     new Value { Value = cardAccountNo, LinkedCommand = SO301000.PaymentSettings.CardAccountNoCardAccountNo }, //Use card account number returned earlier, like "VISATOK:****-****-****-1111" 
+0

謝謝加布裏埃爾。那正是我所期待的。 – 2014-10-31 17:36:08

+0

我快到了。我能夠創建客戶付款記錄,但是當我嘗試將新創建的卡插入現有銷售訂單時,出現錯誤,表明卡/帳戶號不能爲空。我會將我的代碼插入我的原始問題中。 – 2014-11-20 15:22:01

0

下面是示例演示如何設置在銷售訂單卡號通過基於屏幕的API:

Content orderSchema = context.GetSchema(); 

orderSchema.PaymentSettings.CardAccountNo.FieldName += "!Descr"; 

var commands = new Command[] 
{ 
    new Value 
    { 
     Value = "SO", 
     LinkedCommand = orderSchema.OrderSummary.OrderType, 
     Commit = true 
    }, 
    orderSchema.Actions.Insert, 

    new Value 
    { 
     Value = "ABARTENDE", 
     LinkedCommand = orderSchema.OrderSummary.Customer, 
     Commit = true 
    }, 

    new Value 
    { 
     Value = "VISA", 
     LinkedCommand = orderSchema.PaymentSettings.PaymentMethod 
    }, 
    new Value 
    { 
     Value = "VISA:****-****-****-7630", 
     LinkedCommand = orderSchema.PaymentSettings.CardAccountNo, 
     Commit = true 
    },  

    orderSchema.Actions.Save 
}; 
context.Submit(commands); 

這種模式是必要的框文本屬性在.aspx的設置每一個選擇。

相關問題