Skip to content

Instantly share code, notes, and snippets.

@rootedsoftware
rootedsoftware / gist:e7ad49f80fdf9dc3905f
Last active August 29, 2015 14:06
Balanced function
debit_order: function (data, order, paymentObject) {
logger.info("Inside debit_order.");
var debit;
debit = extractFromPromise(balanced.get(order).debit_from(paymentObject, ({ "amount": data.paymentInformation[0].total_amount * 100,
"appears_on_statement_as": "Trash Mountain"})));
var bank_account = extractFromPromise(balanced.get(Meteor.settings.devBankAccount));
var credit;
credit = extractFromPromise(balanced.get(order).credit_to(bank_account, 103));
@rootedsoftware
rootedsoftware / gist:82006e98c2f62866ab70
Last active August 29, 2015 14:07
Mongo Backup script
#! /bin/bash
mkdir -p /var/backups/mongodb; mongodump --db [Collection1] --out /var/backups/mongodb/$(date +'%Y-%m-%d')
mkdir -p /var/backups/mongodb; mongodump --db [Collection2] --out /var/backups/mongodb/$(date +'%Y-%m-%d')
mkdir -p /var/backups/mongodb; mongodump --db [Collection3] --out /var/backups/mongodb/$(date +'%Y-%m-%d')
/home/[USERNAME]/dropbox_uploader.sh upload /var/backups/mongodb /
@rootedsoftware
rootedsoftware / gist:20d82003e61aefd3623e
Created October 18, 2014 19:59
Meteor problem collection document
{
"_id" : "1234",
"created_at" : "09/24/2014, 12:28",
"customer" : {
"address_line1" : "Address Line 1",
"address_line2" : "Address Line 2",
"city" : "Topeka",
"country" : "US",
"created_at" : "09/24/2014, 12:28",
"email_address" : "email@email.com",
@rootedsoftware
rootedsoftware / gist:bb5b496c322bdf256bbf
Created October 28, 2014 21:08
Transaction Document
{
"TX45s73APnaLpkgPJvGMFHSr" : {
"amount" : 102,
"appears_on_statement_as" : "Trash Mountain",
"created_at" : "2014-09-29T17:43:18.414627+00:00",
"failure_count" : 0,
"failures" : [],
"guid" : "TX45s73APnaLpkgPJvGMFHSr",
"status" : "pending",
"submit_status" : "done",
location /give {
proxy_pass http://trashmountainGive/give;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
# Upstreams
# Note: if you want to run multiple meteor apps on the same server,
# make sure you define a separate port for each.
#setup meteor upstream servers
upstream trashmountainGive {
server 127.0.0.1:58080;
}
upstream trashmountainGiveDev {
{ _api:
I20141209-15:18:16.384(-6)? { base_url: 'https://api.balancedpayments.com/',
I20141209-15:18:16.385(-6)? request_args: { headers: [Object], auth: [Object] },
I20141209-15:18:16.385(-6)? routes:
I20141209-15:18:16.385(-6)? { marketplaces: [Object],
I20141209-15:18:16.385(-6)? customers: [Object],
I20141209-15:18:16.385(-6)? bank_accounts: [Object],
I20141209-15:18:16.385(-6)? orders: [Object] },
I20141209-15:18:16.385(-6)? cache:
I20141209-15:18:16.385(-6)? { '/marketplaces/TEST-MP14BPoPFdKRdPSEx6V15MIl': [Object],
[
{
"_id" : "Philippines Infrastructure",
"total" : 3400,
"count" : 1
},
{
"_id" : "Philippines Urgent",
"total" : 1100,
"count" : 1
// Import the official balanced nodejs package
var balanced = require('balanced-official');
// Create a new API Key and configure the client with it
// The client automatically creates a new test marketplace for us
// if a marketplace does not exist for the api key
balanced.configure(apikey);
// Create a customer with some dummmy data
balanced.get('https://api.balancedpayments.com/debits/WD5rJ4kojAowU1YW4pz86Tb').then(function(debit) {
@rootedsoftware
rootedsoftware / gist:1abfffd4544a8d438cf0
Created March 26, 2015 22:05
Stripe update customer
Trying this
Stripe.customers.update(customer_id, {
"metadata.city": form['address.city'],
"metadata.state": form['address.state'],
"metadata.address_line1": form['address.address_line1'],
"metadata.address_line2": form['address.address_line2'],
"metadata.postal_code": form['address.postal_code'],
"metadata.phone": form.phone
}, function (error, customer) {