2014-10-31 48 views
2

使用API​​創建客戶付款方式的正確方法是什麼?這也將回答如何使用具有關鍵值對的網格,而不是將值存儲到特定的字段中。Acumatica - 使用API​​創建客戶付款方式

此代碼已使用並正常運行近一年,現在本週早些時候開始不再有效。

// Connect to Acumatica 
    context = new acumatica.Screen(); 
    context.CookieContainer = new System.Net.CookieContainer(); 
    context.AllowAutoRedirect = true; 
    context.EnableDecompression = true; 
    context.Timeout = 1000000; 
    context.Url = Properties.Settings.Default.WebServiceURL; 
    LoginResult result = api.context.Login(Properties.Settings.Default.AcumaticaUserName, Properties.Settings.Default.AcumaticaPassword); 

    context.AR303010Clear(); 
    AR303010Content AR303010 = context.AR303010GetSchema(); 

    try 
    { 
    Debug.WriteLine("--- Payment Method Start ---"); 
     // Create Invoice 
     AR303010.Actions.Save.Commit = true; 
     AR303010Content[] AR303010Content = context.AR303010Submit 
     (
      new Command[] 
      { 

       new Value { Value = "ABARTENDE", LinkedCommand = AR303010.PaymentMethodSelection.Customer, Commit = true }, 

       AR303010.Actions.Insert, 

       new Value { Value = "VISA", LinkedCommand = AR303010.PaymentMethodSelection.PaymentMethod, Commit = true }, 

       new Key 
       { 
        ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName, 
        FieldName = AR303010.PaymentMethodDetails.Description.FieldName, 
        Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]" 
       }, 

       new Value {Value = "Card Number", LinkedCommand = AR303010.PaymentMethodDetails.Description}, 
       new Value {Value = "4000000000003636", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true}, 

       new Key 
       { 
        ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName, 
        FieldName = AR303010.PaymentMethodDetails.Description.FieldName, 
        Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]" 
       }, 

       new Value {Value = "Card Verification Code", LinkedCommand = AR303010.PaymentMethodDetails.Description}, 
       new Value {Value = "321", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true}, 

       new Key 
       { 
        ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName, 
        FieldName = AR303010.PaymentMethodDetails.Description.FieldName, 
        Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]" 
       }, 

       new Value {Value = "Expiration Date", LinkedCommand = AR303010.PaymentMethodDetails.Description}, 
       new Value {Value = "012015", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true}, 

       AR303010.Actions.Save 
      } 
     ); 

     Debug.WriteLine("--- Payment Method Created ---"); 
    } 
    catch (Exception ex) 
    { 
     Debug.WriteLine(" --- Failed to create Payment Method ---"); 
     Debug.WriteLine(ex.Message); 
    } 

代碼最初是從Acumatica論壇在拉:

http://forum.acumatica.com/forum/acumatica-reseller-and-isv-community/development-and-customization/5873-setting-credit-card-fields-though-web-services

http://forum.acumatica.com/forum/acumatica-reseller-and-isv-community/development-and-customization/885-help-on-add-new-payment-method-to-a-given-customer-by-webservice-ar303010

•我們已經使用在以前版本的代碼嘗試,我們知道100%它用於工作。 •我們嘗試取消發佈我們的定製。 •我們已經嘗試將數據發送到位於tryacumatica.com的acumatica演示版

我們測試過的每個站點/版本/計算機都返回相同的錯誤。

Error #12: Inserting 'Customer Payment Method Detail' record raised one or more errors. Please review. Error: 'Value' may not be empty. ---> PX.Data.PXOuterException: Error #12: Inserting 'Customer Payment Method Detail' record raised one or more errors. Please review. 

有人請指點我正確的方向嗎?

+0

稍後我會提供更詳細的樣本,但需要增加CPM爲authorize.net令牌化的方式付款方式今天問一個問題,看樣在http://stackoverflow.com/questions/26665541/how-do -i-create -a-sales-order-with-payment-settings-through-acumatica-api – Gabriel 2014-10-31 22:41:54

回答

3

好的例子,因此在這裏是工作從Acumatica提供的代碼。我仍然不知道爲什麼舊代碼在整個工作期間都會崩潰,但這裏是有效的代碼,因爲您不必處理鍵/值,所以它更簡潔一些。

 var context = new acumatica.Screen(); 
     context.CookieContainer = new System.Net.CookieContainer(); 
     context.AllowAutoRedirect = true; 
     context.EnableDecompression = true; 
     context.Timeout = 1000000; 
     LoginResult result = context.Login("admin", "admin"); 

     context.AR303010Clear(); 
     AR303010Content AR303010 = context.AR303010GetSchema(); 

     try 
     { 
      var commands = new Command[] 
        { 
         new Value { Value = "ABARTENDE", 
          LinkedCommand = AR303010.PaymentMethodSelection.Customer}, 
         AR303010.Actions.Insert, 
         new Value { Value = "VISA", 
          LinkedCommand = AR303010.PaymentMethodSelection.PaymentMethod}, 

         new Value 
         { 
          Value = "='CCDNUM'", 
          LinkedCommand = AR303010.PaymentMethodDetails.Description 
         }, 

         new Value { Value = "41111111111111118", 
            LinkedCommand = AR303010.PaymentMethodDetails.Value, 
            Commit = true 
         }, 

         new Value 
         { 
          Value = "='CVV'", 
          LinkedCommand = AR303010.PaymentMethodDetails.Description 
         }, 

         new Value { Value = "121", 
            LinkedCommand = AR303010.PaymentMethodDetails.Value, 
            Commit = true 
         }, 

         new Value 
         { 
          Value = "='EXPDATE'", 
          LinkedCommand = AR303010.PaymentMethodDetails.Description 
         }, 

         new Value {Value = "01/2019", 
            LinkedCommand = AR303010.PaymentMethodDetails.Value, 
            Commit = true 
         }, 

         new Value 
         { 
          Value = "='NAMEONCC'", 
          LinkedCommand = AR303010.PaymentMethodDetails.Description 
         }, 

         new Value {Value = "Mr Jon Doe 8", 
            LinkedCommand = AR303010.PaymentMethodDetails.Value, 
            Commit = true 
         }, 

         AR303010.Actions.Save}; 
      AR303010Content[] AR303010Content = context.AR303010Submit(commands.ToArray()); 

     } 
     catch (Exception ex) 
     { 
     } 
-2

這裏是我用

public void CreateARPayment() 
{ 
    string paymentType = GetParamValue("lblARPaymentType"); 
    string paymentNbr = GetParamValue("lblARPaymentNbr"); 
    string customerID = GetParamValue("txbCustomerID"); 
    string cardAccountNo = GetParamValue("lblCardAccountNo"); 

    string arInvoiceNbr = GetParamValue("txbARInvoiceNbr"); 
    string soInvoiceNbr = GetParamValue("txbSOInvoiceNbr"); 

    Screen context = new Screen(); 
    context.CookieContainer = new System.Net.CookieContainer(); 
    context.Url = Url; 
    context.Login(Login, Password); 

    AR302000Content paymentSchema = context.AR302000GetSchema(); 

    paymentSchema.PaymentSummary.CardAccountNo.FieldName += "!Descr"; 

    var commands = new Command[] 
    { 
     new Value 
     { 
      Value = customerID, 
      LinkedCommand = paymentSchema.PaymentSummary.Customer 
     }, 
     new Value 
     { 
      Value = "TOKENCC", 
      LinkedCommand = paymentSchema.PaymentSummary.PaymentMethod 
     }, 
     new Value 
     { 
      Value = cardAccountNo, 
      LinkedCommand = paymentSchema.PaymentSummary.CardAccountNo 
     }, 
     new Value 
     { 
      Value = "101000", 
      LinkedCommand = paymentSchema.PaymentSummary.CashAccount 
     }, 
     new Value 
     { 
      Value = "09/2014/AR-00001", 
      LinkedCommand = paymentSchema.PaymentSummary.PaymentRef 
     }, 

     paymentSchema.DocumentsToApply.ServiceCommands.NewRow, 
     new Value 
     { 
      Value = arInvoiceNbr, 
      LinkedCommand = paymentSchema.DocumentsToApply.ReferenceNbr, 
      Commit = true 
     }, 

     paymentSchema.DocumentsToApply.ServiceCommands.NewRow, 
     new Value 
     { 
      Value = soInvoiceNbr, 
      LinkedCommand = paymentSchema.DocumentsToApply.ReferenceNbr, 
      Commit = true 
     }, 

     paymentSchema.PaymentSummary.AppliedToDocuments, 
    }; 
    var payment = context.AR302000Submit(commands)[0]; 

    commands = new Command[] 
    { 
     new Value 
     { 
      Value = payment.PaymentSummary.AppliedToDocuments.Value, 
      LinkedCommand = paymentSchema.PaymentSummary.PaymentAmount 
     }, 

     paymentSchema.Actions.Save, 

     paymentSchema.PaymentSummary.ReferenceNbr, 
     paymentSchema.PaymentSummary.Status, 
     paymentSchema.PaymentSummary.PaymentAmount 
    }; 
    payment = context.AR302000Submit(commands)[0]; 

    UpdateSetting("lblARPaymentNbr", payment.PaymentSummary.ReferenceNbr.Value); 
    UpdateSetting("lblARPaymentStatus", payment.PaymentSummary.Status.Value); 
    UpdateSetting("lblARPaymentAmount", payment.PaymentSummary.PaymentAmount.Value); 
} 
+0

這是創建一個客戶付款。我需要創建一個客戶付款方式(添加一張信用卡)。儘管感謝您的回覆。我們在一年前編寫了一個完整的api同步項目,以便與Acumatica同步另一個應用程序,並且直到上週添加信用卡(上面)的功能剛剛停止工作時,它一直在完美地工作。 – Chris 2014-11-03 14:04:34

相關問題