Last active
December 12, 2015 08:18
-
-
Save mbeale/4742795 to your computer and use it in GitHub Desktop.
Onetime transaction with Recurly.js and PHP
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
<?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'))); | |
?> | |
<html> | |
<head> | |
<link href="recurlyjs/themes/default/recurly.css" rel="stylesheet"> | |
<script src="js/jquery-min.js"></script> | |
<script src="recurlyjs/build/recurly.js"></script> | |
<script> | |
$(function(){ | |
Recurly.config({ | |
subdomain: 'yourdomainname' | |
, currency: 'USD' // GBP | CAD | EUR, etc... | |
, country: 'ES' | |
, VATPercent: 20 | |
}); | |
Recurly.buildTransactionForm({ | |
target: '#recurly-form', | |
successURL: 'http://example.com', | |
account : { | |
firstName: 'John', | |
lastName: 'Riggins' | |
}, | |
billingInfo: { | |
firstName: 'John', | |
lastName: 'Riggins', | |
address1: '1234 Some St', | |
city: 'SomeCity', | |
zip: '84098', | |
cardNumber: '4111111111111111', | |
CVV: '123' | |
}, | |
afterInject: function(){ | |
$('.submit').text('Hit it Playa'); | |
}, | |
signature: '<?php echo $signature;?>' | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Transaction Form</h1> | |
<div id="recurly-form"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment