Initial MCVE extension added (Credit Card Processing)

This commit is contained in:
Brad House 2002-02-27 19:46:59 +00:00
parent 313a3602bb
commit 20219b1e24
10 changed files with 2181 additions and 0 deletions

8
ext/mcve/CREDITS Normal file
View File

@ -0,0 +1,8 @@
Authors:
Brad House <brad@mainstreetsoftworks.com>
Chris Faulhaber <jedgar@fxp.org>
BugFixes:
- Memory leak when mcve_destroyconn() not called:
Steven Schoch <cardhelp@starnet.com>

8
ext/mcve/Makefile.in Normal file
View File

@ -0,0 +1,8 @@
# $Id$
LTLIBRARY_NAME = libmcve.la
LTLIBRARY_SOURCES = mcve.c
LTLIBRARY_SHARED_NAME = mcve.la
LTLIBRARY_SHARED_LIBADD = $(MCVE_SHARED_LIBADD)
include $(top_srcdir)/build/dynlib.mk

25
ext/mcve/config.m4 Normal file
View File

@ -0,0 +1,25 @@
dnl config.m4 for PHP4 MCVE Extension
PHP_ARG_WITH(mcve, for MCVE support,
[ --with-mcve[=DIR] Include MCVE support])
if test "$PHP_MCVE" != "no"; then
if test -r $PHP_MCVE/include/mcve.h; then
MCVE_DIR=$PHP_MCVE
else
for i in /usr /usr/local /usr/local/mcve ; do
if test -r $i/include/mcve.h; then
MCVE_DIR=$i
fi
done
fi
if test -z "$MCVE_DIR"; then
AC_MSG_ERROR(not found. Please check your MCVE installation; mcve.h NOT FOUND)
fi
PHP_ADD_INCLUDE($MCVE_DIR/include)
PHP_ADD_LIBRARY_WITH_PATH(mcve, $MCVE_DIR/lib, MCVE_SHARED_LIBADD)
PHP_EXTENSION(mcve, $ext_shared)
PHP_SUBST(MCVE_SHARED_LIBADD)
fi

1846
ext/mcve/mcve.c Normal file

File diff suppressed because it is too large Load Diff

12
ext/mcve/mcve.php Normal file
View File

@ -0,0 +1,12 @@
<?
$module = 'MCVE';
if(!extension_loaded($module)) {
dl('mcve.so');
}
$functions = get_extension_funcs($module);
echo "Functions available in the $module extension:<br>\n";
foreach($functions as $func) {
echo $func."<br>\n";
}
echo "<br>\n";
?>

89
ext/mcve/php_mcve.h Normal file
View File

@ -0,0 +1,89 @@
/*
* basic mcve php module
*
* $Id$
*/
#ifndef _PHP_MCVE_H
#define _PHP_MCVE_H
extern zend_module_entry php_mcve_module_entry;
#define mcve_module_ptr &php_mcve_module_entry
#define phpext_mcve_ptr mcve_module_ptr
//#if COMPILE_DL
// DLEXPORT zend_module_entry *get_module(void) { return
//&php_mcve_module_entry; }
//#endif
#define PHP_MCVE_VERSION "1.0"
#define MCVE_CONST (CONST_CS | CONST_PERSISTENT)
PHP_MINIT_FUNCTION(mcve);
PHP_MINFO_FUNCTION(mcve);
PHP_FUNCTION(mcve_initengine);
PHP_FUNCTION(mcve_initconn);
PHP_FUNCTION(mcve_deleteresponse);
PHP_FUNCTION(mcve_destroyconn);
PHP_FUNCTION(mcve_setdropfile);
PHP_FUNCTION(mcve_setip);
PHP_FUNCTION(mcve_setssl);
PHP_FUNCTION(mcve_settimeout);
PHP_FUNCTION(mcve_connect);
PHP_FUNCTION(mcve_returnstatus);
PHP_FUNCTION(mcve_returncode);
PHP_FUNCTION(mcve_transactionssent);
PHP_FUNCTION(mcve_transactionitem);
PHP_FUNCTION(mcve_transactionbatch);
PHP_FUNCTION(mcve_transactionid);
PHP_FUNCTION(mcve_transactionauth);
PHP_FUNCTION(mcve_transactionavs);
PHP_FUNCTION(mcve_transactioncv);
PHP_FUNCTION(mcve_transactiontext);
PHP_FUNCTION(mcve_monitor);
PHP_FUNCTION(mcve_transinqueue);
PHP_FUNCTION(mcve_checkstatus);
PHP_FUNCTION(mcve_completeauthorizations);
PHP_FUNCTION(mcve_sale);
PHP_FUNCTION(mcve_preauth);
PHP_FUNCTION(mcve_override);
PHP_FUNCTION(mcve_void);
PHP_FUNCTION(mcve_preauthcompletion);
PHP_FUNCTION(mcve_force);
PHP_FUNCTION(mcve_return);
PHP_FUNCTION(mcve_iscommadelimited);
PHP_FUNCTION(mcve_parsecommadelimited);
PHP_FUNCTION(mcve_getcommadelimited);
PHP_FUNCTION(mcve_getcell);
PHP_FUNCTION(mcve_getcellbynum);
PHP_FUNCTION(mcve_numcolumns);
PHP_FUNCTION(mcve_numrows);
PHP_FUNCTION(mcve_getheader);
PHP_FUNCTION(mcve_destroyengine);
PHP_FUNCTION(mcve_settle);
PHP_FUNCTION(mcve_qc);
PHP_FUNCTION(mcve_gut);
PHP_FUNCTION(mcve_gft);
PHP_FUNCTION(mcve_ub);
PHP_FUNCTION(mcve_gl);
PHP_FUNCTION(mcve_chkpwd);
PHP_FUNCTION(mcve_bt);
PHP_FUNCTION(mcve_chngpwd);
PHP_FUNCTION(mcve_listusers);
PHP_FUNCTION(mcve_adduser);
PHP_FUNCTION(mcve_enableuser);
PHP_FUNCTION(mcve_disableuser);
PHP_FUNCTION(mcve_getuserarg);
PHP_FUNCTION(mcve_adduserarg);
PHP_FUNCTION(mcve_deleteusersetup);
PHP_FUNCTION(mcve_initusersetup);
PHP_FUNCTION(mcve_deluser);
PHP_FUNCTION(mcve_edituser);
PHP_FUNCTION(mcve_liststats);
#endif /* _PHP_MCVE_H */

23
ext/mcve/tests/001.phpt Normal file
View File

@ -0,0 +1,23 @@
--TEST--
Check for mcve presence
--SKIPIF--
<?php if (!extension_loaded("MCVE")) print "skip"; ?>
--POST--
--GET--
--FILE--
<?php
echo "mcve extension is available";
/*
you can add regression tests for your extension here
the output of your test code has to be equal to the
text in the --EXPECT-- section below for the tests
to pass, differences between the output and the
expected text are interpreted as failure
see php4/tests/README for further information on
writing regression tests
*/
?>
--EXPECT--
mcve extension is available

View File

@ -0,0 +1,19 @@
<?php
MCVE_InitEngine(NULL);
$conn=MCVE_InitConn();
if (MCVE_SetIP($conn, "testbox.mcve.com", 8333)) {
echo "Set connection Properly";
} else {
echo "Failed Setting method";
exit();
}
if (!MCVE_Connect($conn)) {
echo "<BR>Could not connect<BR>";
} else {
echo "<BR>Connection Established<BR>";
}
MCVE_DestroyConn($conn);
MCVE_DestroyEngine();
?>

View File

@ -0,0 +1,83 @@
<HTML>
<BODY>
<?php
// MCVE Config stuff
$username="vitale";
$password="test";
// 1:IP or 2:SSL
$method=2;
$host="testbox.mcve.com";
$port=8444; //8444 is typically SSL and 8333 is standard
// End config stuff
if (!$account)
$account="4012888888881";
if (!$exp)
$exp="0512";
if (!$amount)
$amount=12.00;
function flush_buffer()
{
for ($i=0; $i<2048; $i++) {
echo " ";
}
flush();
}
dl("./php_mcve.so");
echo "Initializing MCVE<BR>";
flush_buffer();
mcve_initengine("./CAfile.pem");
$conn=mcve_initconn();
if ($method == 1)
$ret=mcve_setip($conn, $host, $port);
else if ($method == 2)
$ret=mcve_setssl($conn, $host, $port);
if (!$ret) {
echo "Could not set method<BR>";
exit(1);
}
echo "Connection method and location set<BR>";
flush_buffer();
if (!mcve_connect($conn)) {
echo "Connection Failed<BR>";
exit(1);
}
echo "Connection Established<BR>";
flush_buffer();
$identifier=mcve_sale($conn, $username, $password, NULL, $account, $exp,
$amount, NULL, NULL, NULL, NULL, NULL, NULL, 001);
echo "Transaction Sent: CC: $account EXP: $exp AMOUNT: $amount<BR>";
flush_buffer();
while (mcve_checkstatus($conn, $identifier) != MCVE_DONE) {
mcve_monitor($conn);
}
echo "Transaction Complete<BR>";
flush_buffer();
$status=mcve_returnstatus($conn, $identifier);
if ($status == MCVE_SUCCESS) {
$text=mcve_transactiontext($conn, $identifier);
$auth=mcve_transactionauth($conn, $identifier);
echo "Transaction Authorized<BR>";
echo "Auth: $auth<BR>";
echo "Text: $text<BR>";
} else if ($status == MCVE_FAIL) {
$text=mcve_transactiontext($conn, $identifier);
echo "Transaction Denied<BR>";
echo "Text: $text<BR>";
} else
echo "Transaction error<BR>";
flush_buffer();
mcve_destroyconn($conn);
mcve_destroyengine();
?>
</BODY>
</HTML>

View File

@ -0,0 +1,68 @@
<?
#
# $Id$
#
$connect_type = "IP";
dl("php_mcve.so");
$conn = MCVE_InitConn();
print "MCVE_InitConn() returned $conn<br>\n";
if ($connect_type == "IP") {
MCVE_SetIP($conn, "localhost", 8333) or
die("MCVE_SetIP() failed");
print "MCVE_SetIP() successful<br>\n";
} else {
MCVE_SetDropFile($conn, "/var/mcve/trans") or
die("MCVE_SetDropFile() failed");
print "MCVE_SetDropFile() successful<br>\n";
}
MCVE_Connect($conn) or
die("MCVE_Connect() failed");
print "MCVE_Connect() successful<br>\n";
# send a request
$ident = MCVE_Sale($conn, "test", "test", NULL, "5454545454545454",
"1205", 11.00, NULL, NULL, NULL, NULL, "me", NULL, 54321);
if ($ident == -1)
die("MCVE_Sale() failed");
else
print "Identifier: $ident<br>\n";
$ident = MCVE_Sale($conn, "test", "test", NULL, "5454545454545454",
"1205", 12.00, NULL, NULL, NULL, NULL, "me", NULL, 54321);
if ($ident == -1)
die("MCVE_Sale() failed");
else
print "Identifier: $ident<br>\n";
$pending = 0;
$complete = -1;
while ($pending != $complete) {
sleep(2);
MCVE_Monitor($conn);
$pending = MCVE_TransInQueue($conn);
print "Transactions pending: $pending<br>\n";
$complete = MCVE_CompleteAuthorizations($conn, &$list);
print "Authorizations complete: $complete<br>\n";
flush();
}
for ($i = 0; $i < $complete; $i++) {
$status = MCVE_CheckStatus($conn, $i);
print "Transaction #" . $list[$i] . " complete: $status<br>\n";
}
MCVE_DestroyConn($conn);
print "MCVE_DestroyConn() completed<br>\n";
#phpinfo();
?>