我正在zoho图书中创建自定义功能,该功能将使用zoho图书中的付款记录信息在zoho创作者中创建记录。我已经能够在zoho creator中成功创建记录,但无法从customer_payment地图中获取invoice_id。
不幸的是,没有错误被抛出。
下面是代码:
paymentMap = Map();
//set order to payment invoice id - this is not working
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));
paymentMap.put("Description",customer_payment.get("card_type"));
paymentMap.put("Payment_ZB_ID",customer_payment.get("payment_id"));
response = zoho.creator.createRecord("XXXXX","XX","Payment",paymentMap);
info response;
下面是可用的地图:
customer_payment
{
"payment_id": "11111111111111111",
"payment_number": "1",
"payment_number_prefix": "",
"payment_number_suffix": "1",
"documents": [],
"customer_id": "11111111111111111",
"customer_name": "John Doe",
"payment_mode": "Stripe",
"card_type": "visa",
"card_type_formatted": "Visa",
"date": "2019-03-04",
"date_formatted": "03/04/2019",
"account_id": "11111111111111111",
"account_name": "Stripe Clearing",
"account_type": "payment_clearing",
"account_type_formatted": "Payment Clearing Account",
"currency_id": "11111111111111111",
"currency_code": "USD",
"exchange_rate": 1,
"exchange_rate_formatted": "$1.00",
"amount": 1,
"amount_formatted": "$1.00",
"unused_amount": 0,
"unused_amount_formatted": "$0.00",
"bank_charges": 0.33,
"bank_charges_formatted": "$0.33",
"tax_account_id": "",
"is_client_review_settings_enabled": false,
"tax_account_name": "",
"tax_amount_withheld": 0,
"tax_amount_withheld_formatted": "$0.00",
"discount_amount": 0,
"discount_amount_formatted": "$0.00",
"description": "Stripe processing fees : $0.33 ",
"reference_number": "12345",
"online_transaction_id": "12345",
"settlement_status": "",
"settlement_status_formatted": "",
"invoices": [
{
"invoice_number": "11111111111111111",
"invoice_payment_id": "11111111111111111",
"invoice_id": "11111111111111111",
"amount_applied": 1,
"amount_applied_formatted": "$1.00",
"tax_amount_withheld": 0,
"tax_amount_withheld_formatted": "$0.00",
"discount_amount": 0,
"discount_amount_formatted": "$0.00",
"total": 1,
"total_formatted": "$1.00",
"balance": 0,
"balance_formatted": "$0.00",
"date": "2019-03-04",
"date_formatted": "03/04/2019",
"due_date": "2019-03-04",
"due_date_formatted": "03/04/2019",
"price_precision": 2,
"apply_date": "",
"apply_date_formatted": ""
}
],
"payment_refunds": [],
"last_four_digits": "1234",
"template_id": "11111111111111111",
"template_name": "Elite Template",
"page_width": "8.27in",
"page_height": "11.69in",
"orientation": "portrait",
"template_type": "elite",
"template_type_formatted": "Elite",
"attachment_name": "",
"can_send_in_mail": true,
"can_send_payment_sms": false,
"is_payment_details_required": true,
"custom_fields": [],
"custom_field_hash": {},
"imported_transactions": []
}
答案 0 :(得分:0)
您可以像这样获取invoice_id:
customer_payment = {"payment_id":"11111111111111111","payment_number":"1","payment_number_prefix":"","payment_number_suffix":"1","documents":{},"customer_id":"11111111111111111","customer_name":"John Doe","payment_mode":"Stripe","card_type":"visa","card_type_formatted":"Visa","date":"2019-03-04","date_formatted":"03/04/2019","account_id":"11111111111111111","account_name":"Stripe Clearing","account_type":"payment_clearing","account_type_formatted":"Payment Clearing Account","currency_id":"11111111111111111","currency_code":"USD","exchange_rate":1,"exchange_rate_formatted":"$1.00","amount":1,"amount_formatted":"$1.00","unused_amount":0,"unused_amount_formatted":"$0.00","bank_charges":0.33,"bank_charges_formatted":"$0.33","tax_account_id":"","is_client_review_settings_enabled":false,"tax_account_name":"","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","description":"Stripe processing fees : $0.33 ","reference_number":"12345","online_transaction_id":"12345","settlement_status":"","settlement_status_formatted":"","invoices":{{"invoice_number":"11111111111111111","invoice_payment_id":"11111111111111111","invoice_id":"11111111111111111","amount_applied":1,"amount_applied_formatted":"$1.00","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","total":1,"total_formatted":"$1.00","balance":0,"balance_formatted":"$0.00","date":"2019-03-04","date_formatted":"03/04/2019","due_date":"2019-03-04","due_date_formatted":"03/04/2019","price_precision":2,"apply_date":"","apply_date_formatted":""}},"payment_refunds":{},"last_four_digits":"1234","template_id":"11111111111111111","template_name":"Elite Template","page_width":"8.27in","page_height":"11.69in","orientation":"portrait","template_type":"elite","template_type_formatted":"Elite","attachment_name":"","can_send_in_mail":true,"can_send_payment_sms":false,"is_payment_details_required":true,"custom_fields":{},"custom_field_hash":{},"imported_transactions":{}};
invoices = customer_payment.getJson("invoices");
//info invoices;
invoiceId = invoices.getJSON("invoice_id");
info invoiceId;
答案 1 :(得分:0)
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));
Deluge在这里不会引发错误。取而代之的是,当获取一个其键不可用的元素时,它会抛出一个 null 。
您的代码段发票[0] .invoice_id 中使用的密钥不是customer_payment映射中的有效密钥。因此,这一直在抛出一个空值,该空值在Zoho Creator中将被填充为空值(或无值)。
如果您清楚地注意到了customer_pay,所有发票都可以在“发票”键下找到。
发票= customer_payment.get(“发票”); //现在发票将在customer_payment地图中具有发票列表
假设付款只有一张发票,则可以按以下方式提取发票ID:
invoiceId = invoices.getJson("invoice_id");
也可以按照您的尝试提取发票ID,如下所示:
info customer_payment.get("invoices").get(0).get("invoice_id");