Skip to content

Instantly share code, notes, and snippets.

View jcleblanc's full-sized avatar

Jonathan LeBlanc jcleblanc

View GitHub Profile
@jcleblanc
jcleblanc / node_sdk_request.js
Created April 20, 2013 05:55
request code from the Node.js PayPal SDK
var card_data = {
"type": "visa",
"number": "4417119669820331",
"expire_month": "11",
"expire_year": "2018",
"cvv2": "123",
"first_name": "Joe",
"last_name": "Shopper"
};
@jcleblanc
jcleblanc / node_sdk_config.js
Created April 20, 2013 05:47
PayPal Node.js REST SDK configuration object
var paypal_sdk = require('paypal-rest-sdk');
var config_options = {
'host': 'api.sandbox.paypal.com',
'port': '',
'client_id': 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
'client_secret': 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
};
@jcleblanc
jcleblanc / pp_oauth2_token.php
Created April 2, 2013 16:13
Fetching an OAuth 2 bearer token from PayPal
<?php
class paypal{
private $access_token;
private $token_type;
/**
* Constructor
*
* Handles oauth 2 bearer token fetch
* @link https://developer.paypal.com/webapps/developer/docs/api/#authentication--headers
@jcleblanc
jcleblanc / pp_oauth2_payment.php
Created April 2, 2013 16:12
Processing a payment using the PayPal RESTful APIs
<?php
/**
* Process Payment
*
* Processes a PayPal or credit card payment
* @link https://developer.paypal.com/webapps/developer/docs/api/#create-a-payment
*/
public function process_payment($request){
$postvals = $request;
$uri = URI_SANDBOX . "payments/payment";
@jcleblanc
jcleblanc / pp_oauth2_define.php
Last active December 15, 2015 16:59
Defining your key, secret and URIs for the PayPal RESTful APIs
<?php
define("CLIENT_ID", "YOUR CLIENT ID");
define("CLIENT_SECRET", "YOUR CLIENT SECRET");
define("URI_SANDBOX", "https://api.sandbox.paypal.com/v1/");
define("URI_LIVE", "https://api.paypal.com/v1/");
?>
@jcleblanc
jcleblanc / shopping.php
Created August 30, 2012 20:37
eBay Shopping API Samples
<?php
class eBayShopping{
//variable instantiation
private $uri_shopping = 'http://open.api.ebay.com/shopping'; //Production Shopping API endpoint
private $appid = 'YOUR APPLICATION ID'; //Production application ID
private $version = '787'; //API version
private $format = 'JSON'; //API response format
private $siteid = '0'; //Site to search (Currently U.S.) - full site list at http://developer.ebay.com/devzone/shopping/docs/callref/types/SiteCodeType.html
private $standard_qstring = ''; //Standard query string parameters to be applied to all requests
@jcleblanc
jcleblanc / example.php
Created August 23, 2012 20:36
eBay Finding API Samples
<?php
require_once("finding.php");
$ebay = new ebay();
//search by keyword - keywords can be space separated list of searches
print_r($ebay->findProduct('findItemsByKeywords', 'Dresses Pants', 2));
//search by category - dresses = 63861, pants = 63863
print_r($ebay->findProduct('findItemsByCategory', '63861', 2));
@jcleblanc
jcleblanc / ql.io_node_application.js
Created June 4, 2012 16:51
ql.io and Node.js Sample Code from Live Coding Session at UtahJS
var Engine = require('ql.io-engine');
var engine = new Engine({
connection: 'close'
});
var script = "create table geocoder " +
" on select get from 'http://maps.googleapis.com/maps/api/geocode/json?address={address}&sensor=true' " +
" resultset 'results.geometry.location'" +
"select lat as lattitude, lng as longitude from geocoder where address='Mt. Everest'";
@jcleblanc
jcleblanc / user_tracking_cookies.js
Created May 21, 2012 19:46
Anonymous User Data Tracking via Local Storage & Cookies
var storeName = "visited";
if (typeof(localStorage) == "undefined" ) {
var cookieVal = readCookie(storeName);
var value = ((cookieVal === null) ? window.location : cookieVal
+ window.location);
var days = 1;
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
@jcleblanc
jcleblanc / json.py
Created April 2, 2012 15:49
PayPal Access OAuth 2 Python Sample: JSON Include
import string
import types
## json.py implements a JSON (http://json.org) reader and writer.
## Copyright (C) 2005 Patrick D. Logan
## Contact mailto:patrickdlogan@stardecisions.com
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either