include '../scat.php'; include '../lib/txn.php'; include '../lib/eps-express.php'; $id = (int) $_REQUEST['id']; $amount = $_REQUEST['amount']; if (!$id || !$amount) { die_jsonp("Either transaction or amount was not specified."); } $person_id = (int) $_REQUEST['person']; $person = $person_id ? person_load($db, $person_id) : false; $account = $person['payment_account_id']; if (!$person_id || !$person || !$account) { die_jsonp("No person specified or no card stored for person."); } $eps = new EPS_Express(); $response = $eps->CreditCardSalePaymentAccount($id, $amount, $account); $xml = new SimpleXMLElement($response); if ($xml->Response->ExpressResponseCode != 0) { die_jsonp((string) $xml->Response->ExpressResponseMessage); } $method = 'credit'; $cc = array(); $cc['cc_txn'] = $xml->Response->Transaction->TransactionID; $cc['cc_approval'] = $xml->Response->Transaction->ApprovalNumber; $cc['cc_type'] = $xml->Response->Card->CardLogo; $txn = new Transaction($db, $id); try { $payment = $txn->addPayment($method, $amount, $cc); } catch (Exception $e) { die_jsonp($e->getMessage());
<?php include '../scat.php'; include '../lib/eps-express.php'; $person = (int) $_REQUEST['person']; $payment_account_id = $_REQUEST['payment_account_id']; if (!$person) { die_jsonp("Person was not specified."); } $ReturnURL = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/cc-attach-finish.php'; $eps = new EPS_Express(); if ($payment_account_id) { $response = $eps->PaymentAccountUpdateHosted($person, $payment_account_id, $ReturnURL); } else { $response = $eps->PaymentAccountCreateHosted($person, $ReturnURL); } $payment = $db->escape($response->Transaction->TransactionSetupID); $valid = $db->escape($response->TransactionSetup->ValidationCode); $q = "INSERT INTO hostedpayment_txn\n SET txn = {$person},\n hostedpayment = '{$payment}',\n validationcode = '{$valid}',\n created = NOW()"; $db->query($q) or die_query($db, $q); $url = "https://certtransaction.hostedpayments.com/?TransactionSetupID=" . $response->Transaction->TransactionSetupID; echo jsonp(array('url' => $url, 'response' => $response));
<?php include '../scat.php'; include '../lib/txn.php'; include '../lib/eps-express.php'; $id = (int) $_REQUEST['txn']; $payment = (int) $_REQUEST['payment']; if (!$id) { die_jsonp("Transaction not specified."); } if (!$payment) { die_jsonp("Payment to reverse from not specified."); } $q = "SELECT cc_txn, amount FROM payment WHERE id = {$payment}"; list($cc_txn, $cc_amount) = $db->get_one_row($q) or die_jsonp("Unable to find transaction information."); $eps = new EPS_Express(); $response = $eps->CreditCardVoid($id, $cc_txn); $xml = new SimpleXMLElement($response); if ($xml->Response->ExpressResponseCode != 0) { die_jsonp((string) $xml->Response->ExpressResponseMessage); } $method = 'credit'; $cc = array(); $cc['cc_txn'] = $xml->Response->Transaction->TransactionID; $cc['cc_approval'] = $xml->Response->Transaction->ApprovalNumber; $cc['cc_type'] = $xml->Response->Card->CardLogo; $txn = new Transaction($db, $id); try { $payment = $txn->addPayment($method, bcmul($cc_amount, -1), $cc); } catch (Exception $e) { die_jsonp($e->getMessage());
include '../scat.php'; include '../lib/txn.php'; include '../lib/eps-express.php'; $id = (int) $_REQUEST['id']; $amount = $_REQUEST['amount']; $from = (int) $_REQUEST['from']; if (!$id || !$amount) { die_jsonp("Either transaction or amount was not specified."); } if (!$from) { die_jsonp("Payment to return from not specified."); } $q = "SELECT cc_txn FROM payment WHERE id = {$from}"; $cc_txn = $db->get_one($q) or die_jsonp("Unable to find transaction information."); $cc_amount = bcmul($amount < 0 ? -1 : 1, $amount); $eps = new EPS_Express(); $response = $eps->CreditCardReturn($id, $cc_txn, $cc_amount); $xml = new SimpleXMLElement($response); if ($xml->Response->ExpressResponseCode != 0) { die_jsonp((string) $xml->Response->ExpressResponseMessage); } $method = 'credit'; $cc = array(); $cc['cc_txn'] = $xml->Response->Transaction->TransactionID; $cc['cc_approval'] = $xml->Response->Transaction->ApprovalNumber; $cc['cc_type'] = $xml->Response->Card->CardLogo; $txn = new Transaction($db, $id); try { $payment = $txn->addPayment($method, $amount, $cc); } catch (Exception $e) { die_jsonp($e->getMessage());
<?php include '../scat.php'; include '../lib/txn.php'; include '../lib/eps-express.php'; $id = (int) $_REQUEST['id']; $amount = $_REQUEST['amount']; $partial = (int) $_REQUEST['partial']; if (!$id || !$amount) { die_jsonp("Either transaction or amount was not specified."); } $txn = new Transaction($db, $id); if (!$txn->canPay('credit', $amount)) { die_jsonp("Amount is too much."); } $ReturnURL = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/cc-paid.php'; $eps = new EPS_Express(); $response = $eps->CreditCardSaleHosted($id, $amount, $partial, $ReturnURL); $xml = new SimpleXMLElement($response); $payment = $db->escape($xml->Response->Transaction->TransactionSetupID); $valid = $db->escape($xml->Response->TransactionSetup->ValidationCode); $q = "INSERT INTO hostedpayment_txn\n SET txn = {$id},\n hostedpayment = '{$payment}',\n validationcode = '{$valid}',\n created = NOW()"; $db->query($q) or die_query($db, $q); $url = "https://certtransaction.hostedpayments.com/?TransactionSetupID=" . $xml->Response->Transaction->TransactionSetupID; $dom = dom_import_simplexml($xml); $dom->ownerDocument->preserveWhiteSpace = false; $dom->ownerDocument->formatOutput = true; echo jsonp(array('url' => $url, 'xml' => $dom->ownerDocument->saveXML()));
include '../lib/txn.php'; include '../lib/eps-express.php'; $id = (int) $_REQUEST['txn']; $payment = (int) $_REQUEST['payment']; if (!$id) { die_jsonp("Transaction not specified."); } if (!$payment) { die_jsonp("Payment to reverse from not specified."); } $q = "SELECT cc_txn, amount FROM payment WHERE id = {$payment}"; list($cc_txn, $cc_amount) = $db->get_one_row($q) or die_jsonp("Unable to find transaction information."); if ($cc_amount < 0) { die_jsonp('Unable to reverse a reversal.'); } $eps = new EPS_Express(); $response = $eps->CreditCardReversal($id, $cc_txn, bcmul($cc_amount, 1)); $xml = new SimpleXMLElement($response); if ($xml->Response->ExpressResponseCode != 0) { die_jsonp((string) $xml->Response->ExpressResponseMessage); } $method = 'credit'; $cc = array(); $cc['cc_txn'] = $xml->Response->Transaction->TransactionID; $cc['cc_approval'] = $xml->Response->Transaction->ApprovalNumber; $cc['cc_type'] = $xml->Response->Card->CardLogo; $txn = new Transaction($db, $id); try { $payment = $txn->addPayment($method, bcmul($cc_amount, -1), $cc); } catch (Exception $e) { die_jsonp($e->getMessage());
<?php include '../scat.php'; include '../lib/person.php'; include '../lib/eps-express.php'; $person_id = (int) $_REQUEST['person']; $person = $person_id ? person_load($db, $person_id) : false; if (!$person_id || !$person || !$person['payment_account_id']) { die_jsonp("No person specified or no card stored for person."); } $eps = new EPS_Express(); $response = $eps->PaymentAccountDelete($person['payment_account_id']); if ($response->ExpressResponseCode != 0) { die_jsonp((string) $response->ExpressResponseMessage); } // remove payment account info from person $q = "UPDATE person\n SET payment_account_id = NULL\n WHERE id = {$person_id}"; $r = $db->query($q) or die_query($db, $q); echo jsonp(array('person' => person_load($db, $person_id), 'response' => $response));