Skip to content

Instantly share code, notes, and snippets.

Alex Birch billforward-alex

  • BillForward
Block or report user

Report or block billforward-alex

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@billforward-alex
billforward-alex / subscribing your webhook to additional audit events.md
Created Aug 3, 2017
Subscribing your webhook to additional audit events
View subscribing your webhook to additional audit events.md
#!/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
View bf_ruby2 tidy configuration.md

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 Oct 24, 2016
Receipt, Payment, InvoicePayment, Refund conventions
View gist:fea62902192348c16c09a3fceaaeba4d
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 Aug 12, 2016
BillForward concepts: Users, Organizations, login, privilege
View BillForward concepts: Users, Organizations, login, privilege.md

Regarding SaaS BillForward environments…

Regarding Organizations:

  • Organizations essentially are a partition on the environment's dataset
View Branching complexity.php
<?php
public function eatIfHungry() {
// states we need to think about:
// - isHungry
// - !isHungry
if (!$this->isHungry()) {
// states we need to think about:
// - !isHungry
return;
View Installing Ruby.md

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

View Local Glassfish tricks.md

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

View getDefaultPaymentMethod.js
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 Mar 2, 2015
Apply credit to account in BillForward Node SDK
View AccountCredit.js
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 Mar 2, 2015
Elect a payment method on account to be the 'default' payment method recruited by that account's subscriptions
View DefaultPaymentMethodElection.js
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);
You can’t perform that action at this time.