def build_invoice(event, context): log.info('Getting customer config') customers = get_customer_config() for customer in customers: next_due = datetime.strptime(customer['next_payment_date'], '%m/%d/%Y') if not is_payment_due(datetime.now().date(), next_due.date()): log.info('No payment due for {} until {}'.format( customer['customer_email'], next_due.strftime('%m/%d/%Y'))) continue invoice = Invoice({ 'merchant_info': { 'email': '*****@*****.**', 'first_name': 'FIRSTNAME', 'last_name': 'LASTNAME' }, 'billing_info': [{ 'email': customer['customer_email'] }], 'items': [{ 'name': 'Hosting Plan', 'quantity': 1, 'unit_price': { 'currency': 'USD', 'value': float(customer['plan_rate']) } }] }) if invoice.create(): log.info("Invoice[%s] created successfully" % (invoice.id)) else: log.info(invoice.error) if invoice.send(): log.info("Invoice[%s] sent successfully" % (invoice.id)) else: log.info(invoice.error) next_payment = set_next_payment_date(next_due, customer['bill_freq']) customer['next_payment_date'] = next_payment.strftime('%m/%d/%Y') log.info('Writing new customers file to S3') write_new_file(customers)
def create_invoice(email, items = None ): invoice = Invoice({ 'merchant_info': { "email": str(email), }, "billing_info": [{ "email": str(email) }], "items": [{ "name": "Widgets", "quantity": 20, "unit_price": { "currency": "USD", "value": 2 } }] }) response = invoice.create() if response: return invoice
def create_invoice(self, items): invoice = Invoice({ 'merchant_info': { "email": "*****@*****.**", }, "billing_info": [{ "email": "*****@*****.**" }], "items": [{ "name": "Seu Jorge - Stuff", "quantity": 1, "unit_price": { "currency": "USD", "value": 19.99 } },{ "name": "Dr. Dog - Be The Void", "quantity": 1, "unit_price": { "currency": "USD", "value": 14.99 } }], }) if invoice.create(): print("Invoice[%s] created successfully"%(invoice.id)) else: print(invoice.error)
"business_name": "Not applicable", "phone": { "country_code": "001", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } } }) if invoice.create(): print(("Invoice[%s] created successfully" % (invoice.id))) else: print((invoice.error)) if invoice.send(): # return True or False print(("Invoice[%s] send successfully" % (invoice.id))) else: print((invoice.error)) payment_attr = { "method": "CASH", "date": "2014-07-10 03:30:00 PST", "note": "Cash received." }
"note": "Medical Invoice 16 Jul, 2013 PST", "payment_term": { "term_type": "NET_45" }, "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "001", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } } }) if invoice.create(refresh_token): print("Third Party Invoice[%s] created successfully" % (invoice.id)) # Fetch the resource similarly as shown below: result = Invoice.find(invoice.id, refresh_token=refresh_token) print("Invoice Detail: %s" % result) else: print(invoice.error)