Stripe
Stripe#
Stripe is a popular global payment processing platform for credit cards. They have an invoice API that allows hourly to issue invoices on your behalf in a single command:
hourly-report invoice=stripe stripe.customer.email=my.client@momandpop.com
Stripe Setup#
Step 1 - install the stripe python api:#
pip install --upgrade stripe
Step 2 - Create a stripe account#
You will need an account at Stripe. Be sure to follow the steps for a developer looking to handle one-time payments. You should also set up your invoice template settings.
Step 3 - Set environment variables#
From the Stripe dashboard:
- copy the
Secret key
and set it as an environment variableSTRIPE_API_SECRET_KEY
You can also paste in the Secret key
later as a command-line argument argument to hourly: stripe.secret_key=<your stripe secret key>
Warning
You will probably want to use your test_
API keys first!
Hourly Configuration#
Hourly provides the following default configuration for stripe invoices:
invoice: # see https://stripe.com/docs/billing/invoices/create-invoice#python stripe: secret_key: ${env:STRIPE_API_SECRET_KEY} customer: name: null email: null description: null customer_id: null # skips customer creation if set invoice_item: customer: # overridden by customer_id amount: # overrides earnings currency: # overrides compensation currency description: # overrides <hours worked> from repo.start_date to repo.end_date invoice: customer: # overridden by customer_id collection_method: send_invoice days_until_due: 30 auto_advance: True # auto-finalize this draft after ~1 hour. footer: Time sheet generated by hourly send_invoice: true # sends invoice to customer.email immediately return_status: false logging: 40 # https://docs.python.org/3/library/logging.html#logging-level
The following fields are subsets of stripe's own API, which has additional fields you can use:
Any of the defaults can be overridden, either at command line or by your project's configuration override.
However, stripe.customer.email
is a required field.
Generating Stripe invoices#
To generate a stripe invoice for your repo, you will need to specify an email address. Hourly will prepare an invoice and ask for confirmation. Here is an example of what that looks like when I run hourly on the hourly repo:
hourly-report invoice=stripe repo.start_date="Jan 1, 2020" stripe.customer.email=apembroke+hourly@gmail.com"
1 days 04:02:14, 28.04 hours worked 2803.72 USD Generating stripe invoice for Asher Pembroke creating new customer new customer_id: cus_GVy3BWS792lu4D customer: description: null email: apembroke+hourly@gmail.com name: null customer_id: cus_GVy3BWS792lu4D invoice: auto_advance: false collection_method: send_invoice customer: cus_GVy3BWS792lu4D days_until_due: 30 footer: Time sheet generated by hourly invoice_item: amount: 280373 currency: usd customer: cus_GVy3BWS792lu4D description: 28.04 hours worked from 2020-01-03T18:44:04-05:00 to 2020-01-09T02:04:18-05:00 logging: 40 return_status: false secret_key: ${env:STRIPE_API_SECRET_KEY} send_invoice: true Is this correct? (yes/n): yes Success! Invoice will be sent to apembroke+hourly@gmail.com Invoice may be paid at https://pay.stripe.com/invoice/<---- redacted -----> View your invoice at https://dashboard.stripe.com
Note
I have redacted actual payment URL
The recipient should get an email from stripe to pay by credit card. You can test credit card payment using one of their testing cards. Meanwhile, visiting the url should show you a page like this: