Skip to content

Instantly share code, notes, and snippets.

@mbeale
mbeale / gist:6081609
Created July 25, 2013 16:47
Hide subscription renewal period
Recurly.buildSubscriptionForm({
/* other options */
subscription: {
couponCode: 'testplan'
},
distinguishContactFromBillingInfo: true,
afterInject: function(){
$('.interval').hide();
},
});
@mbeale
mbeale / gist:5584898
Created May 15, 2013 15:37
Recurly Sample Signatures in PHP
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'test_gbp_1234'),'subscription' => array('plan_code' => 'instant')));
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'test_1234')));
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'test_382re6'),'subscription' => array('plan_code' => 'test-plan-333806','starts_at'=>'Wednesday, August 22, 2012 12:00:00 PM GMT-6')));
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'tsakdfjl225'),'subscription' => array('plan_code' => 'test-plan-340480','quantity'=>'2','trial_ends_at'=>'Sunday, June 3, 2012 4:35:00 PM GMT-6','unit_amount_in_cents'=>20000)));
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'tsakdfjl330'),'subscription' => array('plan_code' => 'setup_fee','currency'=>'USD', 'unit_amount_in_cents' => '22_00')));
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'aaa1234588'),'subscription' => array('plan_code' => 'plan_trial','currency'=>'USD',
@mbeale
mbeale / gist:5320711
Created April 5, 2013 16:37
Recurly Stream PDF invoice with PHP
try {
$pdf = Recurly_Invoice::getInvoicePdf('2149', 'en-US');
} catch (Recurly_NotFoundError $e) {
print "Invoice not found.\n";
}
header('Content-type: application/pdf');
header('Accept-Language: en-US');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
@mbeale
mbeale / gist:5239985
Created March 25, 2013 19:40
Add Basic logging to Recurly python client library
#add this after adding your api key, before you make any calls to the API
log = logging.getLogger('recurly.http.response')
log.setLevel(logging.DEBUG)
#create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
#create formatter
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
#add formatter to ch
ch.setFormatter(formatter)
@mbeale
mbeale / gist:5207507
Created March 20, 2013 19:08
Alter expiration fields Recurly.js
Recurly.buildSubscriptionForm({
/* other options */
afterInject: function(){
$('.month select').val(2); //month
$('.year select').val(2016); //year
},
});
@mbeale
mbeale / gist:5187700
Created March 18, 2013 14:52
Recurly.js submit coupon automatically
Recurly.buildSubscriptionForm({
/* other options */
subscription: {
couponCode: 'testplan'
},
distinguishContactFromBillingInfo: true,
afterInject: function(){
$('.submit').text('Join Playa');
$('div.check').click();
},
@mbeale
mbeale / gist:4742795
Last active December 12, 2015 08:18
Onetime transaction with Recurly.js and PHP
<?php
require_once('recurlyphp/lib/recurly.php');
// Required for the API
//greenlantern
Recurly_Client::$apiKey = 'yourapikey';
Recurly_js::$privateKey = 'yourprivatekey';
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'1'),'transaction' => array('description' => "test trans \n for you",'amount_in_cents'=>'999')));
?>
@mbeale
mbeale / gist:4741709
Last active December 12, 2015 08:08
Complete example for PHP Recurly.js BuildSubscriptionForm
<?php
require_once('recurlyphp/lib/recurly.php');
// Required for the API
Recurly_Client::$subdomain = 'yoursubdomain'
Recurly_Client::$apiKey = 'apikey';
Recurly_js::$privateKey = 'privatekey';
$signature = Recurly_js::sign(array('account'=>array('account_code'=>'aaa1234588'),'subscription' => array(
'plan_code' => 'plan_trial',
&#xA3; == £
@mbeale
mbeale / gist:4262206
Created December 11, 2012 21:18
Sample code change
Turns this:
accounts = Account.all()
while accounts:
for account in accounts:
print 'Account: %s' % account
try:
accounts = accounts.next_page()
except PageError:
accounts = ()