Skip to content

Instantly share code, notes, and snippets.

@mbeale
mbeale / shippingexport.py
Last active December 31, 2015 13:09
EasyPost - Python export shipments to csv
#
# This will fetch shipments and ouput them into csv
#
# Dependencies
# python requests lib - pip install requests
# python iso8601 lib - pip install iso8601
#
# Setup
# add your API key to the code
#
@mbeale
mbeale / gist:7044836
Created October 18, 2013 17:21
Easypost webhook with sinatra
require 'easypost'
require 'sinatra'
require 'json'
post '/webhook' do
e = EasyPost::Event.new
e.receive(JSON.parse(request.body.string))
e.result.to_s
end
@mbeale
mbeale / gist:6998412
Last active December 25, 2015 15:29
Flask and Easypost handle webhooks
from flask import Flask, request
import easypost
import json
app = Flask(__name__)
@app.route("/webhooks", methods=['POST'])
def webhook():
e = easypost.Event()
e.receive(json.loads(request.form.keys()[0]))
@mbeale
mbeale / gist:6981298
Last active March 27, 2017 08:36
EasyPost Handle Webhook PHP
$inputJSON = file_get_contents('php://input');
$event = \EasyPost\Event::receive($inputJSON);
if($event.description == 'tracker.updated'){
//process event here
}
@mbeale
mbeale / couponsubmit
Created October 4, 2013 16:16
Submit a coupon automatically
Recurly.buildSubscriptionForm({
/* other options */
subscription: {
couponCode: 'testplan'
},
distinguishContactFromBillingInfo: true,
afterInject: function(){
if($('.coupon_code').val()){
$('div.check').click();
}
@mbeale
mbeale / signature.php
Created October 3, 2013 17:33
Recurly js signature for account_code override
$signature = Recurly_js::sign(array(
'account'=>array('account_code'=>'_my_account_code'),
'subscription' => array('plan_code' => 'instant')
)
);
@mbeale
mbeale / success
Created September 27, 2013 20:17
success: function (data) {
//if the error object exits
//then ther submission was
//not sucessful
if(errors in data){
//handle the errors
} else {
// it was successful
}
},
@mbeale
mbeale / submitjs
Last active December 24, 2015 02:59
$('#submit-btn').click(function({
$.ajax({
dataType: 'jsonp',
url: 'https://(your-subdomain).recurly.com/jsonp/(your-subdomain)/subscribe',
data: {
signature: signature,
billing_info: {
first_name: 'Ned',
last_name: 'Stark',
address1: '1234 Winterfell Rd',
@mbeale
mbeale / signature
Last active December 24, 2015 02:59
<script>
var signature = "<?php echo Recurly_js::sign(array(
'account'=>array('account_code'=>'test_gbp_1234'),
'subscription' => array('plan_code' => 'instant')
)); ?>";
</script>
@mbeale
mbeale / recurlyjs
Last active December 24, 2015 02:39
Samples for manipulating renewal dates using Recurly.js
//Samples in PHP
//starts_at
$signature = Recurly_js::sign(array(
'account'=>array('account_code'=>'my_account_code'),
'subscription' => array(
'plan_code' => 'test-plan-340480',
'starts_at'=>'2013-09-30T12:06:36-06:00')
)
);