Today I came to know about 'Stripe' APIs. Stripe is a simple, developer-friendly way to accept payments online. According to Stripe :-
"We believe that enabling transactions on the web is a problem rooted in code, not finance, and we want to help put more websites in business.
Complexity and opacity have traditionally been hallmarks of online payment processing. We want to fix that."
So, as usual, here I came up with the solution of Apex Wrapper for Stripe APIs. I developed this API library with my colleague Sanjay. The library gives basic api methods to call and use as follows:
You can download the code from github here:
https://github.com/aslambari/Stripe-Apex-Toolkit
Or from my website here:
http://www.aslambari.com/stripe_apex_toolkit.html
There are many more methods which are under development like CreateSubscription, ListAllCustomers etc, we are working on them. And will back soon with full set of methods. Till, try this library and let us know if that works fine for you and revert back us for enhancements.
Thanks
Aslam Bari
"We believe that enabling transactions on the web is a problem rooted in code, not finance, and we want to help put more websites in business.
Complexity and opacity have traditionally been hallmarks of online payment processing. We want to fix that."
So, as usual, here I came up with the solution of Apex Wrapper for Stripe APIs. I developed this API library with my colleague Sanjay. The library gives basic api methods to call and use as follows:
//1) CreateCharge
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.createCharge('4242424242424242', '2013', '10', '123', '2000', 'usd', 'testing');
if(!response.isError){
system.debug('Transaction ID :: ' + response.id);
system.debug('Transaction Fee :: ' + response.fee);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//Create charge using customer
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.createCharge('cus_EPTWuvf7EXDb4g', '2000', 'usd', 'testing');
if(!response.isError){
system.debug('Transaction ID :: ' + response.id);
system.debug('Transaction Fee :: ' + response.fee);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//2) CreateCustomer
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.createCustomer('4242424242424242', '10','2013', '123', 'Aslam', '', '', '', '', 'IN', 'aslam.bari@gmail.com', 'test');
if(!response.isError){
system.debug('Customer ID :: ' + response.id);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//3) RetrieveCustomer
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.retrieveCustomer('cus_EPTWuvf7EXDb4g');
if(!response.isError){
system.debug('Customer Country :: ' + response.card.country);
system.debug('Customer Last4 CC :: ' + response.card.last4);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//4) CreateInvoice
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.createInvoice('cus_EPTWuvf7EXDb4g', '2000', 'usd', 'test');
if(!response.isError){
system.debug('Invoice Id :: ' + response.id);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//5) RetrieveInvoice
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.retreiveInvoice('ii_W19Xp6cxrqVABH');
if(!response.isError){
system.debug('Invoice Date :: ' + response.created);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//6) CreatePlan
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.createPlan('AMX_101', '2000', 'usd', 'month' , 'AMX Testing');
if(!response.isError){
system.debug('Plan Id :: ' + response.id);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
//7) RetreivePlan
Stripe request = new Stripe('y001LvDyqiGbNZclaaaxxxxttttOJk8w');
StripeResponseModel response = request.retrievePlan('AMX_101');
if(!response.isError){
system.debug('Plan Label :: ' + response.name);
}else{
system.debug('Error Message :: ' + response.errorResponse.message);
}
You can download the code from github here:
https://github.com/aslambari/Stripe-Apex-Toolkit
Or from my website here:
http://www.aslambari.com/stripe_apex_toolkit.html
There are many more methods which are under development like CreateSubscription, ListAllCustomers etc, we are working on them. And will back soon with full set of methods. Till, try this library and let us know if that works fine for you and revert back us for enhancements.
Thanks
Aslam Bari
9 comments:
Awesome :)
Good work Aslam and Sanjay.Waiting for enhanced library. Yet again you posted something useful and novel:)
Nice work Aslam and Sanjay.Useful stuff once again!!!
gr8 work !!!
Thanks for a great article. Your tips are accurate and they will be of great help to me with my business. I bookmarked your site, will be back !
Hi Aslam, any update on this?
are you planning to release more methods.
Sorry, no upgrades for now. As I am busy these days. Will do as soon as get some time :)
I know that you are busy but thought I would check to see if there were any updates coming in the near future?
Hi Aslam,
Very useful post.
I have to integrate stripe with Salesforce and fetch all details from stripe and create respective object in salesforce,will this code working for this requirement.Please let me know asap.
Thanks
Post a Comment