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)
Esempio n. 2
0
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
Esempio n. 3
0
from paypalrestsdk import Invoice
import logging

logging.basicConfig(level=logging.INFO)

# status should pass array with below enum values
# Allowed values: DRAFT, SENT, PAID, MARKED_AS_PAID, CANCELLED, REFUNDED, PARTIALLY_REFUNDED, MARKED_AS_REFUNDED.

options = {
    "start_invoice_date": "2016-01-01 PST",
    "end_invoice_date": "2017-03-26 PST",
    "status": ["SENT", "DRAFT", "PAID", "CANCELLED"],
}
invoices = Invoice.search(options)

if invoices.success():  # return True or False
    print("Search Invoice[%s] successfully" % (invoices, ))
else:
    print(invoices.error)
Esempio n. 4
0
            "client_secret": self.client_secret })

    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:
Esempio n. 5
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

history = Invoice.all({"page_size": 2})

print("List Invoice:")
for invoice in history.invoices:
  print("  -> Invoice[%s]"%(invoice.id))
invoice = Invoice({
    "merchant_info": {
        "email": "*****@*****.**",
        "first_name": "Dennis",
        "last_name": "Doctor",
        "business_name": "Medical Professionals, LLC",
        "phone": {
            "country_code": "001",
            "national_number": "5032141716"
        },
        "address": {
            "line1": "1234 Main St.",
            "city": "Portland",
            "state": "OR",
            "postal_code": "97217",
            "country_code": "US"
        }
    },
    "billing_info": [{"email": "*****@*****.**"}],
    "items": [
        {
            "name": "Sutures",
            "quantity": 100,
            "unit_price": {
                "currency": "USD",
                "value": 5
            }
        }
    ],
    "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"
        }
    }
})
Esempio n. 7
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("INV2-9DRB-YTHU-2V9Q-7Q24")

if invoice.send():  # return True or False
    print("Invoice[%s] send successfully" % (invoice.id))
else:
    print(invoice.error)
Esempio n. 8
0
invoice = Invoice({
    "merchant_info": {
        "email":
        "*****@*****.**",  # You must change this to your sandbox email account
        "first_name": "Dennis",
        "last_name": "Doctor",
        "business_name": "Medical Professionals, LLC",
        "phone": {
            "country_code": "001",
            "national_number": "5032141716"
        },
        "address": {
            "line1": "1234 Main St.",
            "city": "Portland",
            "state": "OR",
            "postal_code": "97217",
            "country_code": "US"
        }
    },
    "billing_info": [{
        "email": "*****@*****.**"
    }],
    "items": [{
        "name": "Sutures",
        "quantity": 100,
        "unit_price": {
            "currency": "USD",
            "value": 5
        }
    }],
    "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"
        }
    },
    "shipping_cost": {
        "amount": {
            "currency": "USD",
            "value": 10
        }
    }
})
Esempio n. 9
0
from paypalrestsdk import Invoice, ResourceNotFound
import logging
logging.basicConfig(level=logging.INFO)

try:
    number = Invoice.next_invoice_number();
    print(("Got next invoice number[%s]" % (number)))

except ResourceNotFound as error:
    print("Something went wrong")
Esempio n. 10
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("<INVOICE_ID>")
refund_attr = {
    "date": "2014-07-06 03:30:00 PST",
    "note": "Refund provided by cash."
}

if invoice.record_refund(refund_attr):  # return True or False
    print(("Payment record on Invoice[%s] successfully" % (invoice.id)))
else:
    print((invoice.error))
Esempio n. 11
0
 def get_invoice(self):
     from . import sandbox
     inv = Invoice.find(self.invoice_id)
     return inv
Esempio n. 12
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

history = Invoice.all({"page_size": 2})

print("List Invoice:")
for invoice in history.invoices:
    print("  -> Invoice[%s]" % (invoice.id))
from paypalrestsdk import Invoice, ResourceNotFound
import logging
logging.basicConfig(level=logging.INFO)

try:
    number = Invoice.next_invoice_number();
    print("Got next invoice number[%s]" % (number))

except ResourceNotFound as error:
    print("Something went wrong")
Esempio n. 14
0
from paypalrestsdk import Invoice
import logging

invoice_id = "INV2-EM7V-GTSP-7UTG-Y2MK"

try:
    invoice = Invoice.find(invoice_id)
    height = "400"
    width = "400"

    rv = invoice.get_qr_code(height, width)
    print(rv)

except ResourceNotFound as error:
    print("Invoice Not Found")
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("<INVOICE_ID>")
refund_attr = {
    "date": "2014-07-06 03:30:00 PST",
    "note": "Refund provided by cash."
}

if invoice.record_refund(refund_attr):  # return True or False
    print("Payment record on Invoice[%s] successfully" % (invoice.id))
else:
    print(invoice.error)
Esempio n. 16
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("INV2-CJL7-PF4G-BLQF-5FWG")
options = {
  "subject": "Past due",
  "note": "Canceling invoice",
  "send_to_merchant": True,
  "send_to_payer": True
}

if invoice.cancel(options):  # return True or False
  print("Invoice[%s] cancel successfully"%(invoice.id))
else:
  print(invoice.error)

Esempio n. 17
0
invoice = Invoice({
    "merchant_info": {
        # The email address used here would be of a third party.
        "email": user_info.email,
        "first_name": "Dennis",
        "last_name": "Doctor",
        "business_name": "Medical Professionals, LLC",
        "phone": {
            "country_code": "001",
            "national_number": "5032141716"
        },
        "address": {
            "line1": "1234 Main St.",
            "city": "Portland",
            "state": "OR",
            "postal_code": "97217",
            "country_code": "US"
        }
    },
    "billing_info": [{"email": "*****@*****.**"}],
    "items": [
        {
            "name": "Sutures",
            "quantity": 50,
            "unit_price": {
                "currency": "USD",
                "value": 5
            }
        }
    ],
    "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"
        }
    }
})
Esempio n. 18
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("INV2-9CAH-K5G7-2JPL-G4B4")
options = {
    "subject": "Past due",
    "note": "Please pay soon",
    "send_to_merchant": True
}

if invoice.remind(options):  # return True or False
    print("Invoice[%s] remind successfully" % (invoice.id))
else:
    print(invoice.error)
Esempio n. 19
0
from paypalrestsdk import Invoice, ResourceNotFound
import logging
import json
logging.basicConfig(level=logging.INFO)

try:
    invoice = Invoice.find("INV2-9DRB-YTHU-2V9Q-7Q24")
    print(json.dumps(invoice.to_dict(), sort_keys=False, indent=4))

except ResourceNotFound as error:
    print("Invoice Not Found")
Esempio n. 20
0
invoice = Invoice({
  "merchant_info": {
    "email": "*****@*****.**",
    "first_name": "Dennis",
    "last_name": "Doctor",
    "business_name": "Medical Professionals, LLC",
    "phone": {
      "country_code": "001",
      "national_number": "5032141716"
    },
      "address": {
      "line1": "1234 Main St.",
      "city": "Portland",
      "state": "OR",
      "postal_code": "97217",
      "country_code": "US"
    }
  },
  "billing_info": [ { "email": "*****@*****.**" } ],
  "items": [
    {
      "name": "Sutures",
      "quantity": 100,
      "unit_price": {
        "currency": "USD",
        "value": 5
      }
    }
  ],
  "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"
    }
  }
})
Esempio n. 21
0
from paypalrestsdk import Invoice
import logging
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("INV2-CJL7-PF4G-BLQF-5FWG")
options = {
    "subject": "Past due",
    "note": "Canceling invoice",
    "send_to_merchant": True,
    "send_to_payer": True
}

if invoice.cancel(options):  # return True or False
    print("Invoice[%s] cancel successfully" % (invoice.id))
else:
    print(invoice.error)
Esempio n. 22
0
from paypalrestsdk import Invoice
import logging
import json
logging.basicConfig(level=logging.INFO)

invoice = Invoice.find("INV2-V2QW-LCUV-RNRL-AQUE")
options = {
    "subject": "Past due",
    "note": "Canceling invoice",
    "send_to_merchant": True,
    "send_to_payer": True
}

if invoice.cancel(options):  # return True or False
    print(json.dumps(invoice.to_dict(), sort_keys=False, indent=4))
else:
    print(invoice.error)