Skip to content

Instantly share code, notes, and snippets.

View SecurityForUs's full-sized avatar

Eric Hansen SecurityForUs

View GitHub Profile
>>> def u(*args, callback=None):
File "<stdin>", line 1
def u(*args, callback=None):
^
SyntaxError: invalid syntax
// Set the API
Balanced\Settings::$api_key = "<api secret>";
// Load the marketplace
$mp = Balanced\Marketplace::mine();
// Attempt to create a new buyer and initialize it with the card URI
try {
$buyer = $mp->createBuyer($email, $account_uri);
} catch(Balanced\Exceptions\HTTPError $e){
# Method #1: with a hold
hold_ref = buyer.hold(amount_in_cents)
# we then need to capture the hold to get the money
debit = hold_ref.capture()
# Method #2: not placing a hold
debit = buyer.debit(amount_in_cents)
(04:53:37 PM) secforus_ehansen: hey whit537 you there?
(04:53:38 PM) kickme444: ok
(04:53:56 PM) mahmoudimus: kickme444, only if you need it, it makes redundant querying easier
(04:54:40 PM) whit537: I am here.
(04:54:54 PM) whit537: Wassup? :)
(04:54:57 PM) secforus_ehansen: did u use stripe before moving/looking into balanced?
(04:55:04 PM) ***whit537 nods
(04:55:38 PM) secforus_ehansen: mind if i ask why you're moving away? i have a friend who's considering stripe and i mentioned you and you not liking them but forgot why
(04:56:02 PM) joonas: I don't think stripe lets you pay to other accounts
(04:56:03 PM) whit537: I love them, but my business model didn't fit.
client
---------
priv_key = <read data in from private key on machine>
headers = <dict of headers being sent>
x-sign = <sha512(headers+priv_key)>
headers['x-sign'] = x-sign
server
--------
priv_key = <api call to get priv key>
>>> def link_cap(data_size, overage=False):
... cap = 1048576
... if overage:
... cap = 500
... return float(data_size) / float(cap)
...
>>> link_cap(1024)
0.0009765625
>>> link_cap(1024, True)
2.048
/**
* Tests how the given values compare
*
* @param mixed $a The value to compare
* @param string $op The comparison operator: >, <, >=, <=, ==, ===, !=, !==
* @param mixed $b The value to compare against
* @return boolean True if $a validates $op against $b, false otherwise
* @throws Exception Thrown when an unrecognized operator, $op, is given
*/
public static function compares($a, $op, $b) {
def validapi(key,email):
# check if API is valid
@validapi
def get(some_key):
return headers[key]
class APIBase(ClassBase):
# Both SL and SVB require authentication tokens. So we set a field here for them
tokens = {'sl' : "", 'svb' : ""}
# Enable support for proxies
proxy = {"https" : ""}
def __init__(self, class_name = "api.base"):
ClassBase.__init__(self, class_name)
def head(self, options):
try:
if options['method'] is not "":
url = "%s/%s" % (options['url'], options['method'])
else:
url = "%s" % (options['url'])
except:
raise APIException("No API method call provided.")
try: