Skip to content

Instantly share code, notes, and snippets.

View billforward-alex's full-sized avatar

Alex Birch billforward-alex

View GitHub Profile
@billforward-alex
billforward-alex / subscribing your webhook to additional audit events.md
Created August 3, 2017 15:19
Subscribing your webhook to additional audit events
#!/bin/bash

# https://sipb.mit.edu/doc/safe-shell/
set -euf -o pipefail

command -v jq >/dev/null 2>&1 || { echo >&2 "I require 'jq' but it's not installed. Try 'brew install jq'. Aborting."; exit 1; }

trap "echo 'Command syntax: BF_add_webhook_sub.sh private_token bf_subdomain webhook_subscriptions [specific_webhook_id]
Example invocation: ./BF_add_webhook_sub.sh MY_PRIVATE_TOKEN api-sandbox \"Account.Created,Subscription.Paid\"'" EXIT SIGHUP SIGINT SIGTERM
@billforward-alex
billforward-alex / bf_ruby2 tidy configuration.md
Created June 22, 2017 22:53
Tidying a bf_ruby2 configuration

Here's how to tidy away the configuration for the bf_ruby2 SDK.

Store your config in config.yml:

config:
  host: "api-sandbox.billforward.net:433"
  scheme: "https"
  base_path: "v1"
  debugging: false
@billforward-alex
billforward-alex / gist:fea62902192348c16c09a3fceaaeba4d
Created October 24, 2016 17:24
Receipt, Payment, InvoicePayment, Refund conventions
InvoicePayments are mutable. When you perform a refund: we update the InvoicePayment in-place.
If you refund a Payment, I think it goes something like this:
- definitely persist a Refund
- definitely persist a Receipt (unless it breaks before we begin our chat with the payment gateway)
- persist an "credit" Payment — but only if Refund succeeds
- mutate the InvoicePayment — but only if Refund succeeds
@billforward-alex
billforward-alex / BillForward concepts: Users, Organizations, login, privilege.md
Created August 12, 2016 17:39
BillForward concepts: Users, Organizations, login, privilege

Regarding SaaS BillForward environments…

Regarding Organizations:

  • Organizations essentially are a partition on the environment's dataset
<?php
public function eatIfHungry() {
// states we need to think about:
// - isHungry
// - !isHungry
if (!$this->isHungry()) {
// states we need to think about:
// - !isHungry
return;
@billforward-alex
billforward-alex / Installing Ruby.md
Last active March 30, 2016 11:43
Installing Ruby

Install Rvm (lets you switch between Ruby versions)

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable

Check what Ruby versions are available

@billforward-alex
billforward-alex / Local Glassfish tricks.md
Created January 28, 2016 12:52
Local Glassfish tricks

Run Glassfish locally

Module fixing

Unzip glassfish_setup.zip (this is a snapshot of the jars we use in Prod or something).

You will need to rename those jars first..

Renaming

@billforward-alex
billforward-alex / getDefaultPaymentMethod.js
Created March 4, 2015 16:39
Get Default Payment Method
BillForward.Account.getByID('ACC-81674A80-3B2D-4327-8C24-994720BA')
.then(function(account) {
// you might want to take a peek at the account
// console.log(account.toString());
// get relevant payment method:
var paymentMethod =_.findWhere(account.paymentMethods, {'defaultPaymentMethod': true});
if (paymentMethod === undefined) throw new Error("No default payment method found for this account. Of course it is still possible that this account can pay via credit or 'offline payments'.");
@billforward-alex
billforward-alex / AccountCredit.js
Created March 2, 2015 15:42
Apply credit to account in BillForward Node SDK
BillForward.Account.getByID('ACC-81674A80-3B2D-4327-8C24-994720BA')
.then(function(account) {
models.creditNote = new BillForward.CreditNote({
'accountID': account.id, // predicated on account's first being created
'value': 100,
'currency': 'USD'
});
return BillForward.CreditNote.create(models.creditNote);
})
.done();
@billforward-alex
billforward-alex / DefaultPaymentMethodElection.js
Created March 2, 2015 15:33
Elect a payment method on account to be the 'default' payment method recruited by that account's subscriptions
BillForward.Account.getByID('ACC-81674A80-3B2D-4327-8C24-994720BA')
.then(function(account) {
// you might want to take a peek at the account
// console.log(account.toString());
// get relevant payment method:
var paymentMethod =_.findWhere(account.paymentMethods, {'gateway': 'stripe'});
// the SDK seems to have an unserialization problem; we need to manually tell JavaScript that this JSON is a BillForward.PaymentMethod:
_paymentMethod = new BillForward.PaymentMethod(paymentMethod);