forked from tylerhall/Shine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
fastspring.php
50 lines (42 loc) · 1.91 KB
/
fastspring.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?PHP
require 'includes/master.inc.php';
$app = new Application();
$app->select($_POST['item_number']); // custom
if(!$app->ok())
{
error_log("Application {$_POST['item_name']} {$_POST['item_number']} not found!");
exit;
}
// FastSpring security check...
if(md5($_REQUEST['security_data'] . $app->fs_security_key) != $_REQUEST['security_hash'])
die('Security check failed.');
$o = new Order();
$o->payer_email = $_POST['CustomerEmail'];
$o->first_name = $_POST['CustomerFirstName'];
$o->last_name = $_POST['CustomerLastName'];
$o->txn_id = $_POST['OrderReference'];
$o->item_name = $_POST['item_name']; // custom
$o->residence_country = $_POST['AddressCountry'];
$o->quantity = $_POST['quantity']; // custom
$o->mc_currency = $_POST['mc_currency']; // custom
$o->payment_gross = preg_replace('/[^0-9.]/', '', $_POST['payment_gross']); // custom
$o->mc_gross = $o->payment_gross;
$o->license = $_POST['license']; // custom - used for cocoafob
$o->app_id = $app->id;
$o->dt = dater();
$o->type = 'FastSpring';
$o->insert();
// $o->generateLicense();
// $o->emailLicense();
// These are the fields and values you'll need to setup in FastSpring's
// remote notification fulfillment option.
// AddressCountry #{order.address.country}
// CustomerEmail #{order.customer.email}
// CustomerFirstName #{order.customer.firstName}
// CustomerLastName #{order.customer.lastName}
// OrderReference #{order.reference}
// item_name #{orderItem.productName}
// item_number 3 <-- this is the Shine ID number of your product
// mc_currency #{order.currency}
// payment_gross #{orderItem.priceTotalUSD.value}
// quantity #{orderItem.quantity}