const Invoice = require('../common/Invoice'); const Store = require('../common/Store'); const Util = require('../common/Util'); const createInvoice = async function (z, bundle) { return Invoice.create( z, bundle.authData.server_url, bundle.inputData.store_id, bundle.inputData.amount, bundle.inputData.currency_code, bundle.inputData.order_id, bundle.inputData.order_url, bundle.inputData.redirect_url, bundle.inputData.buyer_name, bundle.inputData.buyer_email, bundle.inputData.buyer_country, bundle.inputData.buyer_zip, bundle.inputData.buyer_state, bundle.inputData.buyer_city, bundle.inputData.buyer_address1, bundle.inputData.buyer_address2, bundle.inputData.buyer_phone ); } module.exports = { operation: { perform: createInvoice, inputFields: [ Store.inputFields.store_id, Util.inputFields.amount, Util.inputFields.currency_code, { key: 'order_id', label: 'Order ID', type: 'string', helpText: 'The Order ID you want to see in BTCPay Server', required: false, list: false, altersDynamicFields: false, }, { key: 'order_url', label: 'Order URL', type: 'string', helpText: 'The URL where you can see the order in an external system.', required: false, list: false, altersDynamicFields: false, }, { key: 'redirect_url', label: 'Redirect URL', type: 'string', helpText: 'When the customer has paid the invoice, the URL where the customer will be sent to when clicking on the "Return to store" button. You can use the placeholders `{InvoiceId}` and `{OrderId}` in the URL. BTCPay Server will replace those with this invoice `id` or the `metadata.orderId` values respectively.', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_name', label: 'Buyer Name', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_email', label: 'Buyer Email', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_country', label: 'Buyer Country', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_zip', label: 'Buyer Zip', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_state', label: 'Buyer State', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_city', label: 'Buyer City', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_address1', label: 'Buyer Address Line 1', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_address2', label: 'Buyer Address Line 2', type: 'string', required: false, list: false, altersDynamicFields: false, }, { key: 'buyer_phone', label: 'Buyer Phone', type: 'string', required: false, list: false, altersDynamicFields: false, }, ], sample: { id: 'VDdmfYJzJm9VtqW8hqhypF', checkoutLink: 'https://mybtcpayserver.com/i/VDdmfYJzJm9VtqW8hqhypF', status: 'New', additionalStatus: 'None', createdTime: "2021-07-08T12:17:24.000Z", expirationTime: "2021-07-08T12:32:24.000Z", monitoringExpiration: "2021-07-08T13:17:24.000Z", amount: 7.0, currency: 'EUR', metadata: {}, checkout: { speedPolicy: 'MediumSpeed', paymentMethods: ['BTC', 'BTC-LightningNetwork'], expirationMinutes: 15, monitoringMinutes: 60, paymentTolerance: 0, redirectURL: null, redirectAutomatically: false, defaultLanguage: null, }, }, outputFields: Invoice.outputFields, }, key: 'CreateInvoice', noun: Invoice.noun, display: { label: 'Create Invoice', description: 'Creates an Invoice', hidden: false, important: true, }, };