Created
July 18, 2017 12:37
-
-
Save GregularExpressions/1d299cb0651eb918f633571da38332a5 to your computer and use it in GitHub Desktop.
Paddle User Order History and License Recovery Form Example
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> | |
<head> | |
<title>History API</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> | |
<script src="https://cdn.paddle.com/paddle/paddle.js"></script> | |
<script type="text/javascript"> | |
Paddle.Setup({ | |
vendor: 15839 | |
}); | |
$(document).ready(function() { | |
// Submit the recovery form on click of the submit button. | |
$('.js-recovery-submit').click(function(e) { | |
e.preventDefault(); | |
var email = $('.js-recovery-email').val(); | |
recoverLicenses(email); | |
}); | |
// Allow the return/enter key to be used to submit the form. | |
$('.js-recovery-email').keyup(function(e) { | |
if(e.keyCode == 13) { | |
var email = $('.js-recovery-email').val(); | |
recoverLicenses(email); | |
} | |
}); | |
}); | |
// A function to handle our recovery form submissions. | |
function recoverLicenses(email) { | |
$('.notice').hide(); | |
$('.js-recovery-email, .js-recovery-submit').prop('disabled', true); | |
$('.js-recovery-submit').val('Submitting...'); | |
// The second parameter can be set to the product_id to filter the response. | |
Paddle.User.History(email, null, function(response) { | |
// Grab the response from the Paddle API, and show a message to the user. | |
if(response.success) { | |
$('.notice') | |
.removeClass('error') | |
.addClass('success') | |
.html(response.message) | |
.show(); | |
} else { | |
$('.notice') | |
.removeClass('success') | |
.addClass('error') | |
.html(response.error.message) | |
.show(); | |
} | |
$('.js-recovery-email, .js-recovery-submit').prop('disabled', false); | |
$('.js-recovery-submit').val('Recover'); | |
}); | |
} | |
</script> | |
<style type="text/css"> | |
body { | |
font-family: Helvetica, Arial, sans-serif; | |
font-size: 13px; | |
} | |
.heading { | |
font-size: 16px; | |
} | |
.recover-form { | |
padding: 5px 0px; | |
} | |
.notice { | |
padding: 0px 0px 5px 0px; | |
} | |
.error { | |
color: #BE0505; | |
font-weight: bold; | |
} | |
.success { | |
color: #299F22; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
<strong class="heading">Recover License:</strong> | |
<div class="recover-form"> | |
<div class="notice" style="display: none;"></div> | |
<input type="email" class="js-recovery-email" placeholder="Email Address..." /> <input type="button" class="js-recovery-submit" value="Recover" /> | |
</div> | |
</body> | |
</html> |
Hey @Fabrxdesign, I wrote this while I was working at Paddle and I've since moved on so I'm out of the loop. I suggest their support if you want advice on a specific implementation 👍
Thank you for your reply, will connect with the Paddle team.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Greg, Thank you for the useful form.
Currently the form send an email with the invoice, I was wondering it's possible to also send download links for the products purchased by users. Your help would be much appreciated!