Skip to content

Instantly share code, notes, and snippets.

View matthewarkin's full-sized avatar

Matthew Arkin matthewarkin

View GitHub Profile
Stripe.api_key = 'Application's Owner Secret Key'
@token = Stripe::Token.create(
{:customer => CUSTOMER_ID, :card => CARD_ID},
ACCESS_TOKEN # user's access token from the Stripe Connect flow
)
@charge = Stripe::Charge.create(
{
:amount => 2000,
:currency => "usd",
@matthewarkin
matthewarkin / gist:506734db650440963450
Created December 6, 2014 23:28
Sails lift from app.js
/**
* app.js
*
* Use `app.js` to run your app without `sails lift`.
* To start the server, run: `node app.js`.
*
* This is handy in situations where the sails CLI is not relevant or useful.
*
* For example:
* => `node app.js`
@matthewarkin
matthewarkin / gist:6f90126af6303155ed5f
Created December 6, 2014 23:52
Stripe shipping address node
var stripe = require("stripe")(
"sk_test_aA2H5efT5Hp5KBttZpvuTASs"
);
stripe.charges.create({
amount: 400,
currency: "usd",
card: "tok_4cg1u29SFJm9VD", // obtained with Stripe.js
description: "Charge for [email protected]",
shipping: {name:"Matt", address:{line1:"125 Main St", city:"Miami"}}
@matthewarkin
matthewarkin / request.js
Created December 27, 2014 22:54
stripe with request
var request = require('request');
var customer = {
description: 'Customer for [email protected]',
}
request.post("https://api.stripe.com/v1/customers",
function(err, res, body){
console.log(body); //body is the customer object
})
//you see i console the all allParams in the create action. if i submit the form with empty value
//the comsole will be {username: '',email:'' .......}.i think if the value == '',this will directly return the badRequest to
//client. the problem is very strange.i did not write anything to stop the create.if the next() run, i should be run the User.create//(),right?because the form is empty, the User.create will throw the some error,like the username should not be empty.
//policy
module.exports = function(req, res, next) {
for(var value in req.allParams()){
if(value == ""){
console.log(value);
return res.badRequest('some input value is empty');
@matthewarkin
matthewarkin / commence.html
Last active April 11, 2016 23:50
commence.html
<script src="https://www.commencepayments.com/v2/commence.js"
data-amount="2000"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-currency="USD"
data-description="2 Widgets ($20)"
data-name="Commence"
data-zip-code="true"
data-key="pk_test_OZwJfcF4YXzwNdYj8isCwTmx"
></script>
@matthewarkin
matthewarkin / docs.md
Last active April 12, 2016 18:08
Commence Docs

#Welcome to Commence

Commence makes adding payments to your website as easy as copy and paste, no server-side code needed.

To use commence you simply need to add a script tag to your website:

	<script src="https://commencepayments.com/js/commence.js"></script>
var newArray = [];
_(sites).forEach(function(site) {newArray.push({url:site });
$token = $_POST['stripeToken'];
$cu = \Stripe\Customer::retrieve($customer['s_id']);
$card = $cu->sources->create(array( "card"=> $token ));
#Create Charge
\Stripe\Charge::create(array( "amount"=>77766, "currency"=> "usd", "csutomer"=> $cu->id, "source"=> $card->id, description"=>"Test 1"));
@matthewarkin
matthewarkin / gist:aec305313b4d81cd98a1
Created March 22, 2015 06:48
Revoke connected account over api
curl https://connect.stripe.com/oauth/deauthorize \
-H "Authorization: Bearer sk_test_*****************" \
-d client_id=ca_********************* \
-d stripe_user_id=acct_*****************