Skip to content

Instantly share code, notes, and snippets.

View amasses's full-sized avatar

Matthew Lewis amasses

View GitHub Profile
@amasses
amasses / lib_gateway_money_monkey.rb
Created June 7, 2011 23:07
Spree Payments Issue
# lib/gateway/money_monkey.rb
class Gateway::MoneyMonkey < Gateway
preference :login, :string
preference :token, :string
def provider_class
ActiveMerchant::Billing::MoneyMonkeyGateway
end
end
@amasses
amasses / benchmark_names.rb
Created March 16, 2012 05:40
Benchmark of different way to make a name string from first_name and last_name
# Note: I realize this is trivial, but this is a pattern I use a lot (name from first/last) so I was
# curious as to which method was quicker, and if perhaps I've been doing it wrong...? Run on 1.9.3
require 'benchmark'
first_name = "john"
last_name = "smith"
i = 1000000
# Reopen string to add the blank? method
@amasses
amasses / standard-payment.php
Created July 26, 2012 00:10
PHP Standard Payments example
<?php
include_once("FatZebra.class.php");
define("FATZEBRA_USERNAME", "TEST");
define("FATZEBRA_TOKEN", "TEST");
define("FATZEBRA_GATEWAY", "gateway.sandbox.fatzebra.com.au"); // Live: gateway.fatzebra.com.au
define("FATZEBRA_TEST_MODE", true);
$gateway = new FatZebra\Gateway(FATZEBRA_USERNAME, FATZEBRA_TOKEN, FATZEBRA_TEST_MODE, FATZEBRA_GATEWAY); // The last option can be omitted to use the live gateway
@amasses
amasses / create-token.php
Created July 26, 2012 00:17
PHP token payments example
<?php
include_once("FatZebra.class.php");
define("FATZEBRA_USERNAME", "TEST");
define("FATZEBRA_TOKEN", "TEST");
define("FATZEBRA_GATEWAY", "gateway.sandbox.fatzebra.com.au"); // Live: gateway.fatzebra.com.au
define("FATZEBRA_TEST_MODE", true);
$gateway = new FatZebra\Gateway(FATZEBRA_USERNAME, FATZEBRA_TOKEN, FATZEBRA_TEST_MODE, FATZEBRA_GATEWAY); // The last option can be omitted to use the live gateway
@amasses
amasses / fatzebra-ruby.rb
Created August 15, 2012 08:17
Ruby Library Example
# Gemfile
gem "fat_zebra"
# In your code
require 'fat_zebra'
gw = FatZebra::Gateway.new("TEST", "TEST")
card = {
:number => "5123456789012346",
:expiry => "05/2013",
:cvv => "123",
@amasses
amasses / fatzebra-example.cs
Created August 15, 2012 08:19
Fat Zebra.NET Library Example
// ensure you have added reference to the FatZebra DLL
FatZebra.Gateway.Username = "TEST";
FatZebra.Gateway.Token = "TEST";
FatZebra.Gateway.TestMode = true;
FatZebra.Gateway.SandboxMode = true;
var response = FatZebra.Purchase.Create(12000, "Mark Smith", "5123456789012346", DateTime.new(2013, 5, 30), "123", "INV-123009", "203.123.99.8");
if (response.Successful && response.Result.Successful)
@amasses
amasses / direct_post.html
Created September 25, 2012 01:08
Direct Post (purchase) example form
<form action="https://gateway.sandbox.fatzebra.com.au/v1.0/purchases/direct/TEST" id="direct-form" method="POST" novalidate="novalidate">
<input id="reference" name="reference" type="hidden" value="INV-90386">
<input id="currency" name="currency" type="hidden" value="AUD">
<input id="verification" name="verification" type="hidden" value="a36d46f0ac1af213b304a95c5d0354ee">
<input id="amount" name="amount" type="hidden" value="100000">
<input id="return_path" name="return_path" type="hidden" value="http://yourwebsite.com/purchase/complete">
<div class="control-group">
<label class="control-label" for="card_holder">Card Holder</label>
<div class="controls">
@amasses
amasses / direct_post_token_purchase.html
Created September 25, 2012 01:11
Direct Post (token purchase) example form
<form action="https://gateway.sandbox.fatzebra.com.au/v1.0/purchases/direct/TEST" id="direct-form" method="POST" novalidate="novalidate">
<input id="reference" name="reference" type="hidden" value="INV-90386">
<input id="currency" name="currency" type="hidden" value="AUD">
<input id="verification" name="verification" type="hidden" value="a36d46f0ac1af213b304a95c5d0354ee">
<input id="amount" name="amount" type="hidden" value="100000">
<input id="return_path" name="return_path" type="hidden" value="http://yourwebsite.com/purchase/complete">
<p>Your Credit Card (5123XXXXXXXX2346) will be charged the amount of $1000.00. Please enter your card security code to confirm.</p>
<input type="hidden" name="card_token" value="xj8lk08a">
<div class="control-group">
@amasses
amasses / direct_post_tokenize_card_example.html
Created September 25, 2012 04:27
Direct Post (tokenize) example form
<form action="https://gateway.sandbox.fatzebra.com.au/v1.0/credit_cards/direct/TEST" id="direct-form" method="POST" novalidate="novalidate">
<input id="verification" name="verification" type="hidden" value="a36d46f0ac1af213b304a95c5d0354ee">
<input id="return_path" name="return_path" type="hidden" value="http://yourwebsite.com/purchase/complete">
<div class="control-group">
<label class="control-label" for="card_holder">Card Holder</label>
<div class="controls">
<input class="required" id="card_holder" minlength="2" name="card_holder" type="text">
</div>
</div>
@amasses
amasses / payment.js
Created October 2, 2012 06:29
Node.js payment example
https = require('https');
var payload = {
amount: 1000,
card_holder: "Mark Smith",
card_number: "5123456789012346",
card_expiry: "05/2013",
cvv: "123",
customer_ip: "123.4.5.6",
reference: "NODE" + Math.random()