Created
September 27, 2012 22:27
-
-
Save em/3796836 to your computer and use it in GitHub Desktop.
Recurly.js example using multiple signatures with a single form, so it doesn't lose the user-input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>RecurlyJS Subscribe Example</title> | |
<link rel="stylesheet" href="examples.css" type="text/css" /> | |
<link rel="stylesheet" href="../themes/default/recurly.css" type="text/css" /> | |
<script src="../lib/jquery-1.7.1.js"></script> | |
<script src="../build/recurly.js"></script> | |
<script> | |
var signatures = { | |
a: 'sig A', | |
b: 'sig B', | |
c: 'sig C' | |
}; | |
Recurly.config({ | |
subdomain: 'recurlyjsdemo-test', | |
currency: 'USD', | |
signature: signatures.c | |
}); | |
$(function() { | |
$('input[type=radio]').change(function() { | |
var planCode = $(this).val(); | |
Recurly.settings.signature = signatures[planCode]; | |
console.log(planCode); | |
}); | |
}); | |
Recurly.buildSubscriptionForm({ | |
target: '#recurly-subscribe', | |
successURL: 'confirmation.html', | |
planCode: 'simpleplan', | |
distinguishContactFromBillingInfo: true, | |
collectCompany: true, | |
termsOfServiceURL: 'http://example.com/tos', | |
account: { | |
firstName: 'Joe', | |
lastName: 'User', | |
email: '[email protected]', | |
phone: '555-555-5555', | |
companyName: 'Acme' | |
}, | |
billingInfo: { | |
firstName: 'Joe', | |
lastName: 'User', | |
address1: '123 somestreet', | |
address2: '45', | |
city: 'San Francisco', | |
zip: '94107', | |
state: 'CA', | |
country: 'US', | |
cardNumber: '4111-1111-1111-1111', | |
CVV: '123' | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Subscribe to Plan</h1> | |
<input type="radio" name="group2" value="a"> A<br> | |
<input type="radio" name="group2" value="b"> B<br> | |
<input type="radio" name="group2" value="c" checked>C | |
<div id="recurly-subscribe"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is important that buildSubscriptionForm() does not have a signature. We control the signature by overwriting Recurly.settings.signature. If there is no signature passed to buildSubscriptionForm, it delegates over to the global.