Forum Discussion

ChuckSA's avatar
ChuckSA
Occasional Visitor
5 years ago

API - From the beginning

Hi guys,

I am not only new to this community, but new to coding an API. I need to create an API for a project and there are too many variables with regards to API types, Languages etc for me to know where to start. Perhaps if I may present some details about the project, you will be able to offer some advice. Please!.

 

I have built a woocommerce site (for free) for a prisons in Thailand where users can send letters and some money online to their loved ones in prison. The user registers, buys a voucher (linked to a prisoner), gets an order number, goes to any 7 Eleven - Counter Service - to pay. CS (Counter Service) sends an XML request from 7 Eleven to an API with a unique Tx ID and the user's order number. The content of the XML request makes a MySQL database queries (generated from the woocommerce order) to check transaction details using the order number as reference. The API returns an XML response with the amount payable. CS sends another XML message (that references the original XML request via an ID value) that confirms the transaction and the payment received, and the database needs to be updated for the order to reflect that it has been paid.

Below is some specs as well as sample XML request response.

 

- XML Format to request and response data
- TX_ID is the key to transmit data between Counter Service System and Provider.
- Name of Method or Function to be called into web service and Publish shall be having a signature is “public String service(String xmlInput)”
- Method named as "service", the input and return parameter is a String. In the case of .NET, name of the String data type can be declared differently.

 

Example Request: DataExchange

<?xml version="1.0" encoding="iso-8859-1"?>
<REQUEST>
<TX_ID>277137345</TX_ID>
<LOG_ID>238262786</LOG_ID>
<VENDOR_ID>3011734780</VENDOR_ID>
<SERVICE_ID>02</SERVICE_ID>

<METHOD>DataExchange</METHOD>
<COUNTER_NO>13089</COUNTER_NO>
<TERM_NO>2</TERM_NO>
<POS_TAX_ID>E03026000200569</POS_TAX_ID>
<SERVICE_RUN_NO></SERVICE_RUN_NO>
<RECORD_STATUS>A</RECORD_STATUS>
<CLIENT_SERVICE_RUNNO></CLIENT_SERVICE_RUNNO>
<AMOUNT_RECEIVED>8040.43</AMOUNT_RECEIVED>
<VAT_AMOUNT>0</VAT_AMOUNT>
<BILL_TYPE>H</BILL_TYPE>
<REFERENCE_1>1003010</REFERENCE_1>
<REFERENCE_2>0000016536</REFERENCE_2>
<REFERENCE_3></REFERENCE_3>
<REFERENCE_4></REFERENCE_4>
<CUSTOMER_NAME></CUSTOMER_NAME>
<CUSTOMER_ADDR_1></CUSTOMER_ADDR_1>
<CUSTOMER_ADDR_2></CUSTOMER_ADDR_2>
<CUSTOMER_ADDR_3></CUSTOMER_ADDR_3>
<CUSTOMER_TEL_NO></CUSTOMER_TEL_NO>
<ZONE>2</ZONE>
<R_SERVICE_RUNNO></R_SERVICE_RUNNO>
<CANCEL_OPERATING></CANCEL_OPERATING>

<OPERATE_BY_STAFF>1550527</OPERATE_BY_STAFF>
<SYSTEM_DATE_TIME>2012/08/23
13:12:11</SYSTEM_DATE_TIME>
<USERID></USERID>
<PASSWORD></PASSWORD>
</REQUEST>

 

Example Response: DataExchange
<?xml version="1.0" encoding="iso-8859-1"?>
<RESPONSE>
<TX_ID>277137345</TX_ID>
<VENDOR_ID>3011734780</VENDOR_ID>
<SERVICE_ID>02</SERVICE_ID>
<METHOD>DataExchange</METHOD>
<SUCCESS>TRUE</SUCCESS>
<CODE>100</CODE>
<DESC>SUCCESS</DESC>
<REFERENCE_1>1003010</REFERENCE_1>
<REFERENCE_2>0000016536</REFERENCE_2>
<REFERENCE_3></REFERENCE_3>
<REFERENCE_4></REFERENCE_4>
<CUSTOMER_NAME> JOHN</CUSTOMER_NAME>

<CUSTOMER_ADDR_1></CUSTOMER_ADDR_1>
<CUSTOMER_ADDR_2></CUSTOMER_ADDR_2>
<CUSTOMER_ADDR_3></CUSTOMER_ADDR_3>
<CUSTOMER_TEL_NO></CUSTOMER_TEL_NO>
<RETURN1></RETURN1>
<RETURN2></RETURN2>
<RETURN3></RETURN3>
<AMOUNT_RECEIVED>8040.43</AMOUNT_RECEIVED>
<VAT_AMOUNT></VAT_AMOUNT>
<PRINT_SLIP>@@detail@@Message@@detail@@</PRINT_SLIP>
</RESPONSE>

 

I will truly appreciate any help and advice I can get here,

ChuckSA

 

No RepliesBe the first to reply