Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C+ to VFP 5.0
Message
From
06/05/2002 18:12:00
 
 
To
06/05/2002 16:34:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00653255
Message ID:
00653292
Views:
19
>I have a example source code for a call to a .dll to process credit cards. But I cannot figure out how to do the same thing in VFP.
>#include
>#include "cnclient.h"
>
>void main()
>{
> cnclient_init();
> int sessionId = cnclient_start_session("90655454", "1");
> cnclient_set_retries(3);
> cnclient_set_timeout(2000);
>
> char resultBuf[200];
> int result = cnclient_auth(sessionId,
> SALE_REQUEST,
> "5544044490909090",
> "0505",
> NULL,
> 100,
> 1,
> resultBuf,
> 200);
> printf("Authorization Result: %s\n", resultBuf);
>
> cnclient_set_field(sessionId, "customerNum", "123");
> result = cnclient_auth(sessionId,
> SALE_REQUEST,
> "5544044490909090",
> "0505",
> NULL,
> 200,
> 1,
> resultBuf,
> 200);
> cnclient_clear_fields(sessionId);
> printf("Authorization Result: %s\n", resultBuf);
>
> cnclient_set_batchnum(sessionId, 99);
> cnclient_add_batch_rec(sessionId,
> 1, // trans id
> "5544044490909090", // card num
> "0505", // exp date
> 100, // amount (in pennies)
> "123456"); // approval code
> cnclient_add_batch_rec(sessionId,
> 2, // trans id
> "5544044490909090", // card num
> "0505", // exp date
> 1000, // amount (in pennies)
> "123456"); // approval code
>
> cnclient_send_batch(sessionId);
> printf("Settlement complete\n");
>
> cnclient_end_session(sessionId);
> cnclient_cleanup();
>}
>
>Help Please

Hi Christopher,

Here is the same program in VFP code (replace DLLName with real name of DLL):
#define SALE_REQUEST	????  && check cnclient.h file for the value

Declare Integer cnclient_init In DLLName
Declare Integer cnclient_start_session In DLLName String, String
Declare Integer cnclient_set_retries In DLLName Integer
Declare Integer cnclient_set_timeout In DLLName Integer
Declare Integer cnclient_auth In DLLName Integer, Integer, String, String, Integer, Integer, Integer, String @, Integer
Declare Integer cnclient_set_field In DLLName Integer, String, String
Declare Integer cnclient_clear_fields In DLLName Integer
Declare Integer cnclient_set_batchnum In DLLName Integer, Integer
Declare Integer cnclient_add_batch_rec In DLLName Integer, Integer, String, String, Integer, String
Declare Integer cnclient_send_batch In DLLName Integer
Declare Integer cnclient_end_session In DLLName Integer
Declare Integer cnclient_cleanup In DLLName Integer

Local sessionId, resultBuf, result

cnclient_init()
sessionId = cnclient_start_session("90655454", "1")
cnclient_set_retries(3)
cnclient_set_timeout(2000)

resultBuf = Replicate( Chr(0), 200)

result = cnclient_auth(sessionId, ;
	SALE_REQUEST, ;
	"5544044490909090", ;
	"0505", ;
	0, ;
	100, ;
	1, ;
	@resultBuf, ;
	200)

? "Authorization Result: " + Left( resultBuf, At( Chr(0), resultBuf) - 1)

cnclient_set_field( sessionId, "customerNum", "123")
result = cnclient_auth( sessionId, ;
	SALE_REQUEST, ;
	"5544044490909090", ;
	"0505", ;
	0, ;
	200, ;
	1, ;
	@resultBuf, ;
	200)

cnclient_clear_fields(sessionId)

? "Authorization Result: " + Left( resultBuf, At( Chr(0), resultBuf) - 1)

cnclient_set_batchnum(sessionId, 99)
cnclient_add_batch_rec(sessionId, ;
	1, ;			&& trans id
	"5544044490909090", ;	&& card num
	"0505", ;		&& exp date
	100, ;			&& amount (in pennies)
	"123456")		&& approval code

cnclient_add_batch_rec(sessionId, ;
	2, ;			&& trans id
	"5544044490909090", ;	&& card num
	"0505", ;		&& exp date
	1000, ;			&& amount (in pennies)
	"123456")		&& approval code

cnclient_send_batch(sessionId)
?"Settlement complete"

cnclient_end_session(sessionId)
cnclient_cleanup()
HTH
Alex
Previous
Reply
Map
View

Click here to load this message in the networking platform