|
@@ -31,26 +31,26 @@
|
|
|
//==================================
|
|
|
// HOST ID, offset = 0, length = 2 bytes ,
|
|
|
//==================================
|
|
|
-unsigned char HOST_ID_Auto[] = {0x30, 0x30};//信用卡/ 電子票證/ 掃碼支付
|
|
|
-unsigned char HOST_ID_CreditCard[] = {0x31, 0x30};//信用卡
|
|
|
-unsigned char HOST_ID_eTicket_Polling[] = {0x35, 0x30};//電子票證
|
|
|
+unsigned char HOST_ID_Auto[] = {0x30, 0x30};//靽∠鍂��/ �餃�蟡刻�/ ��Ⅳ�臭�
|
|
|
+unsigned char HOST_ID_CreditCard[] = {0x31, 0x30};//靽∠鍂��
|
|
|
+unsigned char HOST_ID_eTicket_Polling[] = {0x35, 0x30};//�餃�蟡刻�
|
|
|
|
|
|
|
|
|
//==================================
|
|
|
// Transaction Type, offset = 2, length = 2 bytes ,
|
|
|
//==================================
|
|
|
-//-------------尋卡---------------
|
|
|
-unsigned char TRANS_TYPE_Search[] = {0x37, 0x32}; //讀取卡片卡號 or 條碼資料
|
|
|
-//--------------信用卡一般消費---------------
|
|
|
-unsigned char TRANS_TYPE_Sale[] = {0x31, 0x31}; //消費交易 : 信用卡,票證,掃碼支付
|
|
|
-unsigned char TRANS_TYPE_Void[] = {0x30, 0x35};//取消交易 : 信用卡,
|
|
|
-unsigned char TRANS_TYPE_Refund[] = {0x31, 0x32};//退貨交易 : 信用卡,票證,掃碼支付
|
|
|
-//--------------信用卡預授權---------------
|
|
|
-unsigned char TRANS_TYPE_Pre_Auth[] = {0x31, 0x33}; //預授權交易 : 信用卡
|
|
|
-unsigned char TRANS_TYPE_Pre_Auth_Complete[] = {0x33, 0x31}; //預授權完成交易 : 信用卡
|
|
|
-unsigned char TRANS_TYPE_Pre_Auth_Cancel[] = {0x33, 0x32}; //取消預授權交易 : 信用卡
|
|
|
-//--------------連動結帳---------------
|
|
|
-unsigned char TRANS_TYPE_UnionSettlement[] = {0x35, 0x41}; //連動結帳請款
|
|
|
+//-------------撠见㨃---------------
|
|
|
+unsigned char TRANS_TYPE_Search[] = {0x37, 0x32}; //霈��硋㨃��㨃�� or 璇萘Ⅳ鞈��
|
|
|
+//--------------靽∠鍂�∩��祆�鞎�---------------
|
|
|
+unsigned char TRANS_TYPE_Sale[] = {0x31, 0x31}; //瘨�祥鈭斗� : 靽∠鍂��,蟡刻�,��Ⅳ�臭�
|
|
|
+unsigned char TRANS_TYPE_Void[] = {0x30, 0x35};//�𡝗�鈭斗� : 靽∠鍂��,
|
|
|
+unsigned char TRANS_TYPE_Refund[] = {0x31, 0x32};//��鞎其漱�� : 靽∠鍂��,蟡刻�,��Ⅳ�臭�
|
|
|
+//--------------靽∠鍂�⊿����---------------
|
|
|
+unsigned char TRANS_TYPE_Pre_Auth[] = {0x31, 0x33}; //�鞉�甈𠹺漱�� : 靽∠鍂��
|
|
|
+unsigned char TRANS_TYPE_Pre_Auth_Complete[] = {0x33, 0x31}; //�鞉�甈𠰴��𣂷漱�� : 靽∠鍂��
|
|
|
+unsigned char TRANS_TYPE_Pre_Auth_Cancel[] = {0x33, 0x32}; //�𡝗��鞉�甈𠹺漱�� : 靽∠鍂��
|
|
|
+//--------------���蝯𣂼董---------------
|
|
|
+unsigned char TRANS_TYPE_UnionSettlement[] = {0x35, 0x41}; //���蝯𣂼董隢𧢲狡
|
|
|
|
|
|
|
|
|
//==================================
|
|
@@ -240,7 +240,7 @@ reRecv:
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((time(NULL)-StartTime)>40)//卡機30 seconds timeout
|
|
|
+ if((time(NULL)-StartTime)>33)//�⊥�30 seconds timeout
|
|
|
{
|
|
|
DEBUG_INFO_1("RecvResponse: read fail (%d / %d)\n", TotalRtn,len);
|
|
|
return -1;
|
|
@@ -311,13 +311,13 @@ int CreditCardSearch(int Fd,unsigned char *EVSEID, struct TransInfo *TransInfoRe
|
|
|
//==========================================
|
|
|
// CreditCardPreAuth
|
|
|
// Input :
|
|
|
-// PreCost : 預扣金額*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
+// PreCost : �鞉緍�煾�*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
// EVSEID: EVSE ID, max length is 18
|
|
|
// Output :
|
|
|
-// ApprovalNo : EDC簽單調閱編號或授權碼[信用卡退貨交易, max length is 12
|
|
|
-// RRN : 信用卡交易序號, max length is 12
|
|
|
-// CardNum: 卡號,max length is 20
|
|
|
-// VemData : 無人自助設備交易資訊 交易別31/32 (預授權完成/預授權取消) 必要欄位 資訊來源為交易別13 (預授權)的回傳, max length is 64
|
|
|
+// ApprovalNo : EDC蝪賢鱓隤輸鰐蝺刻��𡝗�甈羓Ⅳ[靽∠鍂�⊿��鞎其漱��, max length is 12
|
|
|
+// RRN : 靽∠鍂�∩漱�枏���, max length is 12
|
|
|
+// CardNum: �∟�,max length is 20
|
|
|
+// VemData : �∩犖�芸𨭌閮剖�鈭斗�鞈�� 鈭斗���31/32 (�鞉�甈𠰴���/�鞉�甈𠰴�瘨�) 敹��甈�� 鞈��靘���箔漱�枏ê̌13 (�鞉�甈�)�����, max length is 64
|
|
|
//==========================================
|
|
|
int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
|
|
|
{
|
|
@@ -375,10 +375,78 @@ int CreditCardPreAuth(int Fd, int PreCost,unsigned char *EVSEID, struct TransInf
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+//==========================================
|
|
|
+// CreditCardSale
|
|
|
+// Input :
|
|
|
+// Cost : 瘨�祥�煾�*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
+// EVSEID: EVSE ID, max length is 18
|
|
|
+// Output :
|
|
|
+// ApprovalNo : EDC蝪賢鱓隤輸鰐蝺刻��𡝗�甈羓Ⅳ[靽∠鍂�⊿��鞎其漱��, max length is 12
|
|
|
+// RRN : 靽∠鍂�∩漱�枏���, max length is 12
|
|
|
+// CardNum: �∟�,max length is 20
|
|
|
+// VemData : �∩犖�芸𨭌閮剖�鈭斗�鞈�� 鈭斗���31/32 (�鞉�甈𠰴���/�鞉�甈𠰴�瘨�) 敹��甈�� 鞈��靘���箔漱�枏ê̌13 (�鞉�甈�)�����, max length is 64
|
|
|
+//==========================================
|
|
|
+int CreditCardSale(int Fd, int Cost,unsigned char *EVSEID, struct TransInfo *TransInfoReturn)
|
|
|
+{
|
|
|
+ unsigned char Buffer[RequestLength], *ptr, tmpbuf[12];
|
|
|
+
|
|
|
+ memset(Buffer,0x20,RequestLength);
|
|
|
+ ptr=Buffer;
|
|
|
+ strncpy((char *)ptr,(char *)HOST_ID_CreditCard,2);//Host ID
|
|
|
+ ptr+=2;
|
|
|
+ strncpy((char *)ptr,(char *)TRANS_TYPE_Sale,2);//Transaction type
|
|
|
+ ptr+=2;
|
|
|
+ memset(tmpbuf,0,sizeof(tmpbuf));
|
|
|
+ sprintf((char *)tmpbuf,"%d", Cost);
|
|
|
+ if(strlen((char *)tmpbuf)>12)
|
|
|
+ {
|
|
|
+ DEBUG_INFO_1("CreditCardSale: Wrong Cost (Cost=%d)\n", Cost);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ memset(ptr,0x30,12);
|
|
|
+ strncpy((char *)ptr+12-(strlen((char *)tmpbuf)+2),(char *)tmpbuf,strlen((char *)tmpbuf));//Trans Amount
|
|
|
+ ptr+=12;//Trans Amount
|
|
|
+ ptr+=12;//Approval No
|
|
|
+ ptr+=20;//Card No
|
|
|
+ strncpy((char *)ptr,(char *)EVSEID, strlen((char *)EVSEID));
|
|
|
+ ptr+=18;//Store Id
|
|
|
+ //ptr+=2;//Period
|
|
|
+ if(SendRequest(Fd, Buffer, RequestLength)>0)
|
|
|
+ {
|
|
|
+ memset(Buffer,0,RequestLength);
|
|
|
+ if(RecvResponse(Fd,Buffer)>0)
|
|
|
+ {
|
|
|
+ //for(int i=0;i<RequestLength;i++)
|
|
|
+ //printf("%x, ",Buffer[i] );
|
|
|
+ strncpy((char *)TransInfoReturn->TransAmount,(char *)Buffer+44,12);
|
|
|
+ strncpy((char *)TransInfoReturn->TransDate,(char *)Buffer+56,6);
|
|
|
+ strncpy((char *)TransInfoReturn->TransTime,(char *)Buffer+62,6);
|
|
|
+ strncpy((char *)TransInfoReturn->StoreId,(char *)Buffer+97,18);
|
|
|
+ strncpy((char *)TransInfoReturn->ROC,(char *)Buffer+12,12);
|
|
|
+ strncpy((char *)TransInfoReturn->ApprovalNo,(char *)Buffer+115,9);
|
|
|
+ strncpy((char *)TransInfoReturn->RRN,(char *)Buffer+124,12);
|
|
|
+ strncpy((char *)TransInfoReturn->CardNo,(char *)Buffer+24,20);
|
|
|
+ strncpy((char *)TransInfoReturn->VemData,(char *)Buffer+246,64);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO_1("CreditCardSale: RecvResponse failed\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO_1("CreditCardSale: SendRequest failed\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//==========================================
|
|
|
// CreditCardAuthComplete
|
|
|
// Input :
|
|
|
-// PreCost : 扣金額*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
+// PreCost : ���憿�*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
// EVSEID: EVSE ID, max length is 18
|
|
|
// VemData : the VEM data from CreditCardPreAuth, max length is 64
|
|
|
// Output :
|
|
@@ -441,7 +509,7 @@ int CreditCardPreAuthComplete(int Fd, int PreCost,unsigned char *EVSEID, unsigne
|
|
|
//==========================================
|
|
|
// CreditCardPreAuthCancel
|
|
|
// Input :
|
|
|
-// PreCost : 預扣金額*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
+// PreCost : �鞉緍�煾�*100, e.g., $1234 = 123400, $1234.56=123456
|
|
|
// EVSEID: EVSE ID, max length is 18
|
|
|
// ApprovalNo: max length is 12
|
|
|
// CardNum : max length is 20
|