Skip to content

Instantly share code, notes, and snippets.

@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: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: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: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 / 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')
)
);
@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 / 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 / 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 / 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 / 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();
}