Zoho Книги Пользовательские функции с потопом - PullRequest
0 голосов
/ 05 марта 2019

Я создаю пользовательскую функцию в книгах zoho, которая будет создавать запись в zoho creator, используя информацию о платежных записях из книг zoho.Мне удалось успешно создать запись в zoho creator, но я не могу получить invoice_id с карты customer_payment.

К сожалению, не выдается ошибка.

Ниже приведенкод:

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": []

}

1 Ответ

0 голосов
/ 27 марта 2019

Вы можете получить 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;
...