Skip to content

Instantly share code, notes, and snippets.

View craigchristenson's full-sized avatar

Craig Christenson craigchristenson

  • 2Checkout.com
  • Grove City, Ohio
View GitHub Profile
@craigchristenson
craigchristenson / gist:2869509
Created June 4, 2012 16:51
Example PHP script to check fraud status on a sale.
<?php
if ($_POST['message_type'] == 'FRAUD_STATUS_CHANGED') {
$insMessage = array();
foreach ($_POST as $k => $v) {
$insMessage[$k] = $v;
}
$hashSecretWord = "tango"; # Input your secret word
@craigchristenson
craigchristenson / TwocheckoutApi.java
Created August 1, 2012 13:11
2Checkout Api Class Example
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
@craigchristenson
craigchristenson / ins.sql
Created August 11, 2012 13:24
2Checkout INS Table SQL Example
CREATE TABLE 2checkout_ins (
id bigint(20) NOT NULL auto_increment,
timestamp varchar(18) NOT NULL default '0',
message_type varchar(32) NOT NULL default '0',
message_description varchar(64) NOT NULL default '0',
md5_hash varchar(32) NOT NULL default '0',
message_id bigint(20) NOT NULL default '0',
key_count smallint(6) NOT NULL default '0',
vendor_id int(8) NOT NULL default '0',
sale_id bigint(10) NOT NULL default '0',
@craigchristenson
craigchristenson / detail_sale_json
Created September 28, 2012 17:30
Example Detail Sale Response
{
"response_code": "OK",
"response_message": "Sale detail retrieved",
"sale": {
"comments": [
{
"changed_by_ip": "76.181.170.90",
"comment": "Refund Issued On Invoice: test",
"timestamp": "2012-08-26 22:27:20",
"username": "APIuser1817037"
@craigchristenson
craigchristenson / gist:3840173
Created October 5, 2012 14:39
2Checkout Checkout Example
<form action='https://www.2checkout.com/checkout/spurchase' method='post'>
<input type='hidden' name='sid' value='1303908' >
<input type='hidden' name='mode' value='2CO' >
<input type='hidden' name='li_0_type' value='product' >
<input type='hidden' name='li_0_name' value='Monthly Subscription' >
<input type='hidden' name='li_0_price' value='1.00' >
<input type='hidden' name='li_0_recurrence' value='1 Month' >
<input name='submit' type='submit' value='Checkout' >
</form>
@craigchristenson
craigchristenson / gist:3840873
Created October 5, 2012 16:35
2Checkout API PHP
<?php
$ch = curl_init("https://www.2checkout.com/api/sales/detail_sale?sale_id=1234567890");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "2Checkout PHP/0.1.0");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "apiusername:apipassowrd");
$json_resp = curl_exec($ch);
curl_close($ch);
@craigchristenson
craigchristenson / gist:3841142
Last active December 30, 2015 08:06
2Checkout Return
<?php
$hashSecretWord = 'tango'; //2Checkout Secret Word
$hashSid = 1303908; //2Checkout account number
$hashTotal = '1.00'; //Sale total to validate against
$hashOrder = $_REQUEST['order_number']; //2Checkout Order Number
$StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
if ($StringToHash != $_REQUEST['key']) {
$result = "Fail - Hash Mismatch";
} else {