mPAY Gateway : API Guide and Reference version 1.0.7.1 mPAY Gateway API Guide and Reference Version 1.0.7.1 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 1 mPAY Gateway : API Guide and Reference version 1.0.7.1 Revision Control Version 1.0.1.0 1.0.2.0 1.0.3.0 Date 11/05/2015 11/08/2015 17/08/2015 Modifier Dejsak T. Tharanart S. Patti U. 1.0.4.0 1.0.5.0 28/08/2015 08/09/2015 Tharanart S. Tharanart S. Description of Content Initial Draft Change Parameter - Remove parameter amount from “RequestOrderTepsApi” - Update parameter orderID to 30 Character - Update sequence diagram of chapter 4 Add New Command: DownloadRptTeps - Modify Command : RequestOrderTepsApi o Add input parameter (smsFlag,smsMobile) - Add output parameter of “Payment result for respUrl” (Table 5.3) 1.0.6.0 1.0.7.0 14/09/2015 01/10/2015 Thongjit Y. Patti U. - Add New Command: ResendSmsUrl - Add Report Templates (chapter7) Add Response Code Description - Update Payment Flow (chapter 4) - Add detail column ref1 – ref6 in payment report @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 2 mPAY Gateway : API Guide and Reference version 1.0.7.1 Index Table of Contents Chapter 0 – ขันตอนการเปิ ้ ดบริการ ....................................................................................................................................... 4 Chapter 1 – Introduction to mPAY Gateway ...................................................................................................................... 5 Chapter 2 - Recommended Minimum Configuration ......................................................................................................... 7 Chapter 3 – Activating Your mPAY Gateway Account ...................................................................................................... 8 Chapter 4 – mPAY Gateway Transaction Flow .................................................................................................................. 9 Chapter 5 – Submitting Transaction to mPAY Gateway .................................................................................................. 13 Chapter 6 – Inquiry Order Status from mPAY Gateway................................................................................................... 18 Chapter 7 – Standard HTTP header................................................................................................................................. 20 Chapter 8 – Download Merchant Reports ....................................................................................................................... 21 Chapter 9 – Resend SMS EndPoint URL ......................................................................................................................... 21 Chapter 10 – Generic Action Response / Response Code Description ......................................................................... 29 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 3 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 0 – ขนตอนการเปิ ั้ ดบริการ 1. ทางร ้านค ้าจะต ้องทาการสมัครบริการ mPAY Gateway ให ้เรียบร ้อยก่อน กรณีนต ิ บ ิ ค ุ คล ติดต่อสมัครบริการได ้ที่ Merchant Contact Center 02-271-9181 กด 2 (เวลา 08:30-21:00 น. ทุกวัน) กรณีบค ุ คลธรรมดา สมัครได ้ด ้วยตัวเอง ผ่าน www.ais.co.th/mpaygateway 2. ร ้านค ้าส่งเอกสารประกอบการสมัครมาที่ บริษัท แอดวานซ์ เอ็มเปย์ จากัด 3. ทางทีมงาน mPAY Gateway จะจัดส่งข ้อมูลสาหรับ Call API เพือ ่ ทดสอบระบบให ้กับร ้านค ้าทาง E-mail ทีร่ ะบุตอน สมัคร (ภายใน 7 วันทาการหลังจากทีท ่ างทีมงานได ้รับเอกสารตามข ้อ 2 ) ข ้อมูลทีจ ่ ะจัดส่งให ้มี 3 ค่า 3.1 Merchant ID 3.2 SID 3.3 Secret Key 4. หลังจากนัน ้ ทางร ้านค ้าสามารถเริม ่ พัฒนาระบบ พร ้อมทาการทดสอบเข ้ามาได ้เลย ่ มต่อระบบกับ mPAY Gateway สามารถติดต่อได ้ที่ กรณีพบปั ญหาหรือมีข ้อสงสัยในการพัฒนาเชือ E-mail : dp-pts@ais.co.th หรือ โทร 02-029-4391 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 4 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 1 – Introduction to mPAY Gateway mPAY Gateway is an easy to plug-in total payment solution for E-Commerce business with capabilities Easily to plug with API Initially support the currency of Thai Baht only Offer both online channel and offline payment channel Allow merchant to choose type of payment fee, it can be absorb by merchant or pass on to customer at agreeable rate. Flexibility to set the validity for the payment for any purchase items. Real-time proceed transaction with result notification to merchant Cash settlement on next working day Figure 1.1 Overview of E-commerce transaction flow 1. 2. 3. 4. 5. 6. At Merchant website, customer clicks “Buy” to purchase merchandise. Merchant’s Server sends transaction request to mPAY Gateway. mPAY Gateway processes payment and return result back to Merchant’ Server. Merchant website displays the result to the customer. Merchant delivers goods to customer. mPAY then, settles the money to merchant on next working day. Payment Method With mPAY Gateway Solution, we allow customers to choose their preferred payment method which allow by the merchant from the following 3 methods: Online Channel 1. mPAY wallet – the e-wallet of mPAY Offline Channel - By choosing to pay via either mPAY STATION or Bank Transfer channel, the system will generate the 10 digits payment code for customers to pay later. However, when they make payment, the transaction will be proceed in real-time and system will sent out the notification to merchant immediately. 2. mPAY STATION – this is our agent with almost 5,000 locations nationwide. It comprises of:- @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 5 mPAY Gateway : API Guide and Reference version 1.0.7.1 AIS Shop Telewiz Big C Family Mart Tops Supermarket mPAY STATION 3. Bank Transfer – just choose to re-charge the money into those 10 digits payment code from 8 leading banks’ ATM with almost 9,000 locations nationwide i.e. Bangkok Bank BBL Kasikorn Bank KBANK Siam Commercial Bank SCB Krung Thai Bank KTB Bank of Ayudhaya BAY Thai Military Bank TMB CIMB Thai Bank CIMB THAI United Overseas Bank UOB Payment Fee Our system allow merchant to choose type of payment fee, it can be absorb by merchant or pass on to customer at agreeable rate. Merchant Fee – Payment fee will be charged to merchant in term of Merchant Discount Rate (MDR) Customer Fee – payment fee will be charged to customer. Merchant passes only the net amount of goods/services (after any discount to mPAY Gateway, then mPAY Gateway will show product amount customer fee separately together with total paid amount. Reconciliation & Settlement Process Payment transactions will be proceed in real-time and system will send payment result to merchant instantly. Settlement report will be summarized in daily basis, the cut off time of daily transactions is mid-night. Merchant can access mPAY Merchant Self Service System download settlement text file for reconciliation. Cash settlement will be transferred to merchant’s bank account on next working day. For instance:- Transaction Date Cash Settlement Date Monday Tuesday Wednesday Thursday Friday Saturday Sunday Tuesday Wednesday Thursday Friday Monday Remark 1. The net settle amount will the amount after deducting the MDR. Merchant can deduct With Holding Tax of MDR amount, and have to issue With Holding Tax document based on Thai Tax Regulation. Detail operation will be provided later. 2. Settlement files for Friday, Saturday and Sunday will be combined into a single cash transfer transaction. 3. During national holiday, the settlement file(s) will be combined into the next cash transfer. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 6 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 2 - Recommended Minimum Configuration Merchant’s Server Minimum Configuration Merchant’s Server connects with mPAY Gateway by using HTML language. mPAY Gateway can support many types of merchant server, for example, UNIX, Windows, Linux, etc. For submit request to mPAY Gateway, merchant must use SSL System, 256 Bits from trusted certification CA. (e.g. Verisign, Entrust). Merchant needs to have the basic knowledge of HTML 1.1 syntax and languages especially: • How to write HTML FORM POST • How to receive HTML FORM POST @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 7 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 3 – Activating Your mPAY Gateway Account 1. 2. 3. 4. 5. 6. 7. 8. Merchant goes to mPAY Gateway Site URL https://xxxxxxxxxxxx to register o Fill in merchant information o Attached all the required documents as stated on WEB mPAY Gateway Merchant downloads the mPAY Gateway - API Guide and Reference for further develop mPAY will verify the documents and approve. Merchant Id (max. 15 digits) will be sent to merchant’s e-mail within 5 working days. Merchant have to go to Merchant setting in mPAY’s payment gateway page to get “sid” and “SecretKet” for use in API integration, and also set the rest of merchant’s parameter. After developed, merchant can do the integrate test and make payment to https://saichon-beauty.ais.co.th:8002/AISMPAYPartnerInterface/InterfaceService? (The tested mobile number will be provided in the WEB mPAY Gateway [Developer corner]) Merchant submits test result to mPAY Admin for Data & Log checking which shown the mPAY Transaction Id to mPAY Gateway Upon checking, mPAY will On Production and inform back the status to Merchant via e-mail Then, Merchant can change the URL to be the On Production one https://partnerservices.mpay.co.th/AISMPAYPartnerInterface/InterfaceService? and go live. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 8 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 4 – mPAY Gateway Transaction Flow Payment transaction will be stared when customer select to make the payment via mPAY Gateway. The transaction will be re-directed to mPAY Gateway, customer can choose his/her preferred payment method which allow by merchant. Upon getting the payment from customer from either online channel or offline channel, mPAY Gateway will send back the result notification to merchant. Figure 4.1 Sequence Diagram of mPAY Wallet transaction flow @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 9 mPAY Gateway : API Guide and Reference version 1.0.7.1 Figure 4.2 Sequence Diagram of Credit Card transaction flow Figure 4.3 Sequence Diagram of Offline transaction flow @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 10 mPAY Gateway : API Guide and Reference version 1.0.7.1 1. Customer make a shopping & finalized shopping cart at Merchant’s Website 2. Merchant generates own unique order id and calls mPAY Gateway to start payment with passing order information such as unique order id, order amount, etc. (see table 5.1) 3. mPAY Gateway verifies all input data, then initialize session and returns unique session id (called saleId) and Payment URL of end-point mPAY Gateway Page back to Merchant's System (see table 5.1) 4. Merchant opens mPAY Gateway Page, re-direct customer to mPAY PaymentURL that returned in step 3. 5. mPAY Gateway displays Order Info page, then customer can confirm to pay. 6. mPAY Gateway displays list of payment methods page, then customer can select their preferred payment method (which allow by merchant) 7. Customer makes the payment with payment method that they had selected. Payment transaction will be proceed instantly if customer selects online payment. If customer selects offline channel merchant will get payment code with expire date/time, then mPAY Gateway will notify payment status with payment transaction ID when customer make payment at mPAY any offline channels. 8. mPAY Gateway returns payment result to Merchant's Specified respURL (HTTP Post). (see table 5.3) 9. mPAY Gateway opens Merchant's Specified RedirectURL Page with passing HTTP Post data. (see table 5.2) 10. (Optional) If Merchant's Server doesn't receive a response from mPAY Gateway, Merchant's Server can query order status by using "SaleId". (see table 6.1) 11. Merchant's Server displays payment result page to customer. 12. Customer inputs mPAY’s mobile number. 13. mPAY notifies pending transaction to customer’s mobile number. 14. Customer clicks notify then login to mPAY app to make a payment. 15. mPAY app displays payment success/fail page. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 11 mPAY Gateway : API Guide and Reference version 1.0.7.1 16. mPAY generates payment REF Code 17. Customer goes to mPAY’s offline channel, such as AIS shop, Telewiz, Big C, FamilyMart, TOP, ETC. 18. Offline channel queries REF Code. 19. mPAY returns order information to offline channel. 20. Offline channel confirms payment. 21. mPAY return payment success to offline channel. 22. Offline channel print receipt to customer. (TAX invoice must issue from merchant) Notice : mPAY Gateway time out is 30 seconds (For request API). @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 12 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 5 – Submitting Transaction to mPAY Gateway Step 1: Customer check out at Merchant’s website Customer goes to merchant’s website for choosing goods or services, then confirm to buy by click button ‘Payment’ or ‘Confirm’ etc. at merchant’s website Step 2: Merchant send request to mPAY Gateway After Customer checked out from the merchant’s website, merchant has to produce the order information such as unique order id, order amount, payment method (option) etc. and pack all into payment request command (detail in Table 5.1) and send it to mPAY Gateway and then waiting for response from mPAY Gateway. There are 2 important fields in the output response data set (i) ‘saleId’ used as reference for further steps (ii) ‘endPointUrl’ parameter used for merchant’s website to redirect to mPAY Gateway. Important !! mPAY Gateway supports only Customer/customer input and API parameter values in regular ASCII (English language) characters. The mPay Gateway does not support extended ASCII characters or any other character sets other than regular ASCII at this time. Table 5.1 : Request Payment to mPAY Gateway parameter Input No Variable Data Type Max Mandator Length y 1 projectCode Character 10 Y Description 2 3 command sid Character Character 50 36 Y Y 4 redirectUrl Character 255 N 5 merchantId Numeric 20 Y 6 orderId Character 30 Y 7 currency Character 3 Y 8 purchaseAmt Numeric 12 Y 10 paymentMethod Character 5 N 11 productDesc Character 50 N Name of project, use default is ‘TEPS’ 'RequestOrderTepsApi' Merchant security control (specific to a merchant) URL, where customer will be re-directed to merchant’s Website and mPAY returns variables to when customer clicks ‘Go Back to Merchant’s Website’ (Success page) or ‘Continue’ (Error page) Merchant No. (Assigned by mPAY) Purchase Order Id. Use unique number within x month. (Generate by merchant) Payment currency e.g. THB, USD Amount of purchased order (Original product amount) and last 2 digits are decimal. Method of payment Values as belows: - '1' = mPAY - '4' = Credit Card - '5' = Offline Product Description 12 13 14 15 ref1 ref2 ref3 ref4 Character Character Character Character 50 50 50 50 N N N N Free Free Free Free form form form form text text text text @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 13 Remark http://www…………… or https://www…………… 12345678 1111111111 Reference : ISO4217 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 If merchant is not specific payment method, mPAY will show all accepted Payment Method. Electric Fan – Toshiba Model XYZ103 mPAY Gateway : API Guide and Reference version 1.0.7.1 16 17 ref5 integrityStr Character Character 50 128 N Y Free form text Application Authentication SHA256 (sid+merchantId+orderId+ amount+SecretKey) 18 smsFlag Character 1 N 19 smsMobile Character 11 N Y= send sms to buyer N= don’t send sms to buyer (default value is “N”) Buyer’s mobile number Or the recipient that the message will be sent to. Format : 66xxxxxxxxx (international format) Output No Variable Data Type 1 status Character Max Length 1 Mandator y Y Description 2 respCode Character 10 Y Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code 3 respDesc respDesc 100 Y Error Description 4 saleId Numeric 27 Y 5 endPointUrl Character 255 Y 6 7 8 detail1 detail2 detail3 Character Character Character 50 50 50 N N N mPAY Payment request reference ID Redirect URL for End Point Page other information (if need) other information (if need) other information (if need) Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost 12345678900000 Step 3: Merchant brings customer to mPAY Gateway payment page Merchant’s site brings their customers to make payment at mPAY Gateway site by redirect or browsing to mPAY Gateway regarding of URL in the field "endPointUrl". Step 4: Customer makes payment at mPAY Gateway There are 3 steps for customer to make payment via mPAY Gateway (i) Select Payment Method, mPAY provides 2 types of payment Online channel @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 14 mPAY Gateway : API Guide and Reference version 1.0.7.1 o Allow payment method by mPAY Wallet o Notify Payment return Success or Fail to Merchant instantly Offline channel o mPAY Gateway allows merchant to self-configure the validity of the payment code (maximum 7 days). If customer selects offline channel mPAY will notify the status ‘Wait for paid’ to merchant instantly. o When customer goes to pay at mPAY STATION’s Counter or Bank’s ATM, mPAY Gateway will online notify to Merchant at Merchant’s respURL with payment result ‘Success’ (In case that customer does not make any payment until the payment code is expired, mPAY will then notify ‘Payment timeout’ to Merchant) (ii) Make payment following by the chosen payment method (iii) Display Payment result page differently between online and offline. Step 4: Go back to Merchant’s website after payment process is end After customer clicks “Back to Merchant” button, mPAY Gateway will Notify by using Silent Post to the specified respUrl, and mPAY Gateway will bring customer back to Merchant’s website by redirect to the specified redirectURL with passing Post Data as Table 5.2 Table 5.2 : Payment result for HTTP post parameter No Variable Data Type Max Mandat Length ory 1 status Character 1 Y 2 respCode Character 10 Y 3 4 5 respDesc tranId saleId respDesc Character Numeric 100 30 27 Y Y Y 6 orderId Character 30 Y 7 currency Character 3 Y 8 exchangeRate Numeric 12 Y 9 purchaseAmt Numeric 12 Y 10 amount Numeric 12 Y 11 incCustomerFee Numeric 12 N Description Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code Error Description mPAY Transaction Id mPAY Payment request reference ID (Generate by mPAY Gateway) Purchase Order Id. Use unique number within x month. (Generate by merchant) Payment currency e.g. THB Rate for convert two currencies is the rate at which one currency will be exchanged for another. This case for convert purchaseAmt to amount. (last 5 digits are decimal) Amount of purchased order (Product amount) and last 2 digits are decimal. Amount of purchased order (Product amount) that convert to ''Thai Baht' and last 2 digits are decimal. Customer Fees are included in ‘amount’ (currency = THB) last 2 digits are decimal. Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost 111222333 12345678900000 1111111111 Reference : ISO4217 For example, 3213830 = 32.13830 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 Do not include comma separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 e.g. amount = 100 THB incCustomerFee = 10 THB excCustomerFee = 0 THB customer pay = 100 THB 12 excCustomerFee Numeric 12 N Customer Fees are not @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 15 Do not include comma mPAY Gateway : API Guide and Reference version 1.0.7.1 included in ‘amount’ (currency = THB) last 2 digits are decimal. e.g. separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 amount = 100 THB incCustomerFee = 0 THB excCustomerFee = 10 THB customer pay = 110 THB 13 paymentStatus Character 20 Y Payment/Order Status 14 paymentCode Character 10 N 15 orderExpireDate Character 20 N Reference for payment via offline payment method Expire date of paymentCode e.g. OPEN, ATTEMPT, PENDING, SUCCESS, FAIL Format : YYYYMMDDHH24MISS Time Zone : (UTC+07:00) Bangkok, Hanoi, Jakarta e.g. 20151012130000 Table 5.3 : Payment result for respUrl (Silent Post) parameter The Silent Post ensures that the transaction data is passed back to your website when a transaction is completed. The Silent Post feature uses the HTML Post method to return data to your server for both approved and declined transactions. This occurs even if a customer closes the browser before returning to your site, or if the mPAYhosted payment confirmation page is disabled. Silent Post data will be sent to your server at the same time as when a payment confirmation page is displayed or as soon as a transaction is declined. No Variable Data Type 1 status Character Max Length 1 Mandat ory Y 2 respCode Character 10 Y 3 4 5 respDesc tranId saleId respDesc Character Numeric 100 30 27 Y Y Y 6 orderId Character 30 Y 7 currency Character 3 Y 8 exchangeRate Numeric 12 Y 9 purchaseAmt Numeric 12 Y 10 amount Numeric 12 Y Description Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code Error Description mPAY Transaction Id mPAY Payment request reference ID Purchase Order Id. Use unique number within x month. (Generate by merchant) Payment currency e.g. THB Rate for convert two currencies is the rate at which one currency will be exchanged for another. This case for convert purchaseAmt to amount. (last 5 digits are decimal) Amount of purchased order (Product amount) and last 2 digits are decimal. Amount of purchased order (Product amount) that convert to ''Thai @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 16 Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost 111222333 12345678900000 1111111111 Reference : ISO4217 For example, 3213830 = 32.13830 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 No decimal (multiple of 100) e.g. key in mPAY Gateway : API Guide and Reference version 1.0.7.1 Baht' and last 2 digits are 11 incCustomerFee Numeric 12 N decimal. Customer Fees are included in ‘amount’ (currency = THB) last 2 digits are decimal. e.g. 178125 = 1781.25 Do not include comma separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 amount = 100 THB incCustomerFee = 10 THB excCustomerFee = 0 THB customer pay = 100 THB 12 excCustomerFee Numeric 12 N Customer Fees are not included in ‘amount’ (currency = THB) last 2 digits are decimal. e.g. Do not include comma separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 amount = 100 THB incCustomerFee = 0 THB excCustomerFee = 10 THB customer pay = 110 THB 13 paymentStatus Character 20 Y Payment/Order Status 14 paymentCode Character 10 N 15 orderExpireDate Character 20 N Reference for payment via offline payment method Expire date of paymentCode e.g. OPEN, ATTEMPT, PENDING, SUCCESS, FAIL Format : YYYYMMDDHH24MISS Time Zone : (UTC+07:00) Bangkok, Hanoi, Jakarta e.g. 20151012130000 16 17 18 19 20 21 custEmail shipName shipAddress shipProvince shipZip shipCountry Character Character Character Character Character Character 50 100 255 20 10 3 N N N N N N 22 23 24 remark1 remark2 integrityStr Character Character Character 255 255 128 N N Y Refer to: http://en.wikipedia.org/wi ki/ISO_3166-1_numeric. Application Authentication SHA256 (saleId+orderId+amount+ SecretKey[response]) 25 customerId Numeric 20 N mPAY customer ID (show when buyer is mPAY’s customer) 12345678900000 Step 5: Merchant’s complete sales transaction with customer (redirect to merchant page) Merchant captures payment result from mPAY Gateway. If payment is success, merchant has to display Success transaction wording to customer and continues with goods or services delivery process. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 17 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 6 – Inquiry Order Status from mPAY Gateway The mPAY Payment Service is capable of sending an order notification when a payment reaches one of the following statuses: OPEN ATTEMPT PENDING SUCCESS FAIL Other payment statuses are not reported through order notifications. To check any possible status for a payment you can consult its payment details in the Merchant Interface or send an information request in the API as below. (Inquiry between created order date and after order expiration date 3 days) Table 6.1 : Inquiry order status parameter Input No Variable 1 2 3 4 projectCode command merchantId orderId Data Type Character Character Numeric Character 5 purchaseAmt Numeric 12 Y Numeric Character Character Character Character Character 27 50 50 50 50 50 Y N N N N N Max Length 1 Mandatory 6 saleId 7 ref1 8 ref2 9 ref3 10 ref4 11 ref5 Output No Variable Max Length 10 50 20 30 Mandatory Y Y Y Y Description Name of project, use default is ‘TEPS’ ‘InquiryApi’ Merchant No. (Assigned by mPAY) Purchase Order Id. Use unique number within x month. (Generate by merchant) Amount of purchased order (Product amount) and last 2 digits are decimal. mPAY Payment request reference ID 1 status Data Type Character 2 respCode Character 10 Y Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code 3 respDesc respDesc 100 Y Error Description 4 5 6 tranId saleId orderId Character Numeric Character 30 27 30 Y Y Y 7 currency Character 3 Y 8 exchangeRate Numeric 12 Y 9 purchaseAmt Numeric 12 Y mPAY Transaction Id mPAY Payment request reference ID Purchase Order Id. Use unique number within x month. (Generate by merchant) Payment currency e.g. THB Rate for convert two currencies is the rate at which one currency will be exchanged for another. This case for convert purchaseAmt to amount. (last 5 digits are decimal) Amount of purchased order (Product amount) and last 2 digits are decimal. Y Description @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 18 Remark 12345678 1111111111 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 12345678900000 Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost 111222333 12345678900000 1111111111 Reference : ISO4217 For example, 3213830 = 32.13830 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 mPAY Gateway : API Guide and Reference version 1.0.7.1 10 amount Numeric 12 Y Amount of purchased order (Product amount) that convert to ''Thai Baht' and last 2 digits are decimal. 11 incCustomerFee Numeric 12 N Customer Fees are included in ‘amount’ (currency = THB) last 2 digits are decimal. e.g. amount = 100 THB incCustomerFee = 10 THB excCustomerFee = 0 THB customer pay = 100 THB 12 excCustomerFee Numeric 12 N Customer Fees are not included in ‘amount’ (currency = THB) last 2 digits are decimal. e.g. amount = 100 THB incCustomerFee = 0 THB excCustomerFee = 10 THB customer pay = 110 THB 13 paymentStatus Character 20 Y Payment/Order Status 14 paymentCode Character 10 N 15 orderExpireDate Character 20 N Reference for payment via offline payment method Expire date of paymentCode Format : YYYYMMDDHH24MISS Time Zone : (UTC+07:00) Bangkok, Hanoi, Jakarta e.g. 20151012130000 16 17 18 19 20 21 custEmail shipName shipAddress shipProvince shipZip shipCountry Character Character Character Character Character Character 50 100 255 20 10 3 N N N N N N 22 23 24 remark1 remark2 integrityStr Character Character Character 255 255 128 N N Y Refer to: http://en.wikipedia.org/wiki/ISO_31661_numeric Application Authentication SHA256 (saleId+orderId+amount+ SecretKey[response]) @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 19 No decimal (multiple of 100) e.g. key in 178125 = 1781.25 Do not include comma separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 Do not include comma separator and decimal (multiple of 100). For example, use 178125 not 1,781.25 e.g. OPEN, ATTEMPT, PENDING, SUCCESS, FAIL mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 7 – Standard HTTP header Header Name Connection Content-Length Content-Type Host Description State of the connection. The server returns the value close to close the connection after the response is sent. (Required)Size of message body. (Required)Provide one of the following values: - text/name value, transaction request body is in name-value pair format. - text/xml (Required) @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 20 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 8 – Download Merchant Reports This API for download all merchant Payment Report Cancel Report Refund Report Settlement Report reports from mPAY Gateway. That contain 4 types of report such as -- > Showing the transactions report. -- > Showing the transactions that has been refunded in the same payment day. -- > Showing the transactions that has been refunded on the next payment day. -- > Showing information about revenue and payments related to refund information on the account. Generally, mPAY Gateway first settles your account 1 day after your payment transaction completes. Your account is settled daily business days. The merchant reports are generated regularly, and you can download them from API only. The Reports are Pipedelimited text files(CSV file). These can be difficult to read in a text editor, such as Notepad or Text Edit, but you can easily open them in most spreadsheet applications (such as Microsoft Excel) or database software, to review and manage the information. Note : The reports are available only for the past 6 months. How to Downloading and Reading the Merchant Reports 1. Request API as the table 7.1 2. Decode only the string output parameter name is "reportFile" to ByteArrayOutputStream 3. Convert ByteArrayOutputStream (from No.2) to CSV file with java.io.ByteArrayOutputStream Table 7.1 : Download Merchant Report parameter Input No Variable 1 2 3 projectCode command sid Data Type Character Character Character Max Length 10 50 36 Mandatory 4 5 merchantId reportType Numeric Numeric 20 2 Y Y 6 reportDate Character 10 N Y Y Y Description Name of project, use default is ‘TEPS’ ‘DownloadRptTeps’ Merchant security control (specific to a merchant) Merchant No. (Assigned by mPAY) ‘1’ = Payment Report ‘2’ = Cancel Report ‘3’ = Refund Report ‘4’ = Settlement Report Format : YYYYMMDD Remark 12345678 1 Note : If you are not sent this parameter, you'll get the report of yesterday Output No Variable 1 status Data Type Character Max Length 1 Mandatory 2 respCode Character 10 Y Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code 3 respDesc respDesc 100 Y Error Description 4 reportFile String (231)-1 Y Binary data Y Description @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 21 Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost VFlQRXxVlNR… mPAY Gateway : API Guide and Reference version 1.0.7.1 For example: Request http://saichonbeauty.ais.co.th:8001/AISMPAYPartnerInterface/InterfaceService?projectCode=TEPS&command=DownloadRptTeps &sid=mGIx4cOZKgE=&integrityStr=7af2beadbcff9c0a3ffd5a594b1a8bc42d6f1c6f37bded5a92627bbba9ee8ce8&mer chantId=6342&reportType=1&reportDate=20150816 Response <?xml version="1.0" encoding="UTF-8"?> -<response> <status>S</status> <respCode>0000</respCode> <respDesc>Success</respDesc> <reportFile>VFlQRXxTRVFVRU5DRXxUUkFOU0FDVElPTl9JRHxQQVlNRU5UX0RBVEVUSU1FfFNFTExFUl9PUk RFUl9JRHxUT1RBTF9BTU9VTlR8UEFZTUVOVF9NRVRIT0R8T1JERVJfREFURQpIfDF8VEVTVFRFUFM2MzQyfD E2LzA4LzIwMTV8MTkvMDgvMjAxNXx8CkR8MnwxMTExMjcyNTU0fDE2LzA4LzIwMTUgMTA6MTk6NTJ8RjQyM DAyfDUyLjF8bVBBWSBXYWxsZXR8MTcvMDgvMjAxNQpUfDN8VGVzdFRlcHM2MzQyfDE2LzA4LzIwMTV8MXw 1Mi4xfHwK</reportFile> </response> Opening the Merchant Reports in Microsoft Excel 1. Download a report as described earlier. 2. Open Microsoft Excel. 3. In Microsoft Excel, click File > Open. 4. Locate and open your report. Because your report is in pipe-delimited(|) text format, you might need to look for all file types and not just Microsoft Excel worksheets. 5. When you find the file, select it, and click Open. Microsoft Excel should start the Text Import Wizard. This tool allows you to specify how Microsoft Excel formats the file data. 6. In the Original Data Type section, select Delimited, and then click Next. 7. In the Delimiters section, make sure that PIPE(|) is the only box selected, and then click Next. This tells Microsoft Excel to begin a new column whenever it comes across a tab in the report file. 8. In the Data Preview section, use the scroll bars to locate the order-item-id column and then click the General heading. 9. In the Column Data Format section, select the Text option. This prevents Microsoft Excel from converting the values to an exponential format. (For example, it prevents Microsoft Excel from converting 66522216496654 to 6.65222E+13.) Apply the same format to any other columns. 10. Click Finish. The report opens in Microsoft Excel. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 22 mPAY Gateway : API Guide and Reference version 1.0.7.1 Report Template Report Type : Payment Report Report Name : YYYYMMDD_PAYM_<MERCHANTNAME>.csv 1. Header No. Colume Name Description 1 Type Header 2 Sequence First Sequence No. 3 Merchant Name Merchant Name (Always show in upper case) 4 Payment Date Format : DD/MM/YYYY (Transaction Date) 5 Process Run Date Format : DD/MM/YYYY (Normally = Payment Date + 1) 2. Detail No. Description Remark 1 Type "D" = Detail 2 Sequence Running Sequence No. 3 Transaction Id mPAY Transaction Id 4 Payment Datetime Format : DD/MM/YYYY HH24:MI:SS (Transaction Date,Time) 5 Order Id Order Id From Merchant 6 Total Amount Total Payment Amount (Include fee, Show 2 decimals) 7 Payment Method Payment Method Description 8 Order Date Format : DD/MM/YYYY 9 ref1 Merchant’s ref1 10 ref2 Merchant’s ref2 11 ref3 Merchant’s ref3 12 ref4 Merchant’s ref4 13 ref5 Merchant’s ref5 3. Total No. Description Remark 1 Type “T” = Total 2 Sequence Last Sequence No. (Row id) 3 Merchant Name Merchant Name (Always show in upper case) 4 Payment Date Format : DD/MM/YYYY (Transaction Date) 5 Total Transaction Count Transaction of Details 6 Total Payment Amount Sum Amount of Details (Show 2 decimals) Examples “H” "1" KANOM PINKLAO 17/07/2015 18/07/2015 Remark "D" 2 11123123404 17/07/2015 08:01:10 1111111 1,000.00 mPAY Wallet 16/07/2015 Remark “T” Last Sequence No. KANOM PINKLAO 17/07/2015 1 1,000.00 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 23 mPAY Gateway : API Guide and Reference version 1.0.7.1 Report Type : Cancel Report Report Name : YYYYMMDD_CANC_<MERCHANTNAME>.csv 1. Header No. Colume Name Description 1 Type Header 2 Sequence First Sequence No. 3 Merchant Name Merchant Name (Always show in upper case) 4 Cancel Date Format : DD/MM/YYYY (Refund Date) 5 Process Run Date Format : DD/MM/YYYY (Normally = Cancel Date + 1) 6 7 8 2. Detail No. Description Remark 1 Type "D" = Detail 2 Sequence Running Sequence No. 3 Transaction Id mPAY Transaction Id 4 Cancel Datetime Format : DD/MM/YYYY HH24:MI:SS (Refund Date,Time) 5 Order Id Order Id From Merchant 6 Total Amount Total Payment Amount (Include fee, Show 2 decimals) 7 Payment Method Payment Method Description 8 Payment Datetime Format : DD/MM/YYYY HH24:MI:SS (Transaction Date,Time) 3. Total No. Description Remark 1 Type “T” = Total 2 Sequence Last Sequence No. (Row id) 3 Merchant Name Merchant Name (Always show in upper case) 4 Cancel Date Format : DD/MM/YYYY (Refund Date) 5 Total Cancel Transaction Count Cancel Transaction of Details 6 Total Cancel Amount Sum Cancel Amount of Details (Show 2 decimals) 7 8 Examples “H” "1" KANOM PINKLAO 17/07/2015 18/07/2015 Remark "D" 2 11123123404 17/07/2015 08:01:10 1111111 1,000.00 mPAY Wallet 17/07/2015 18:01:10 Remark “T” Last Sequence No. KANOM PINKLAO 17/07/2015 1 1,000.00 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 24 mPAY Gateway : API Guide and Reference version 1.0.7.1 Report Type : Refund Report Report Name : YYYYMMDD_REFN_<MERCHANTNAME>.csv 1. Header No. Colume Name Description 1 Type Header 2 Sequence First Sequence No. 3 Merchant Name Merchant Name (Always show in upper case) 4 Refund Date Format : DD/MM/YYYY (Refund Date) 5 Process Run Date Format : DD/MM/YYYY (Normally = Refund Date + 1) 6 7 8 9 2. Detail No. Description Remark 1 Type "D" = Detail 2 Sequence Running Sequence No. 3 Transaction Id mPAY Transaction Id 4 Refund Datetime Format : DD/MM/YYYY HH24:MI:SS (Refund Date,Time) 5 Order Id Order Id From Merchant 6 Total Amount Total Payment Amount (Include fee, Show 2 decimals) 7 Payment Method Payment Method Description 8 Payment Datetime Format : DD/MM/YYYY HH24:MI:SS (Transaction Date,Time) 9 Settlement Batch Date Format : DD/MM/YYYY (Normally = Payment Date + 1) 3. Total No. Description Remark 1 Type “T” = Total 2 Sequence Last Sequence No. (Row id) 3 Merchant Name Merchant Name (Always show in upper case) 4 Refund Date Format : DD/MM/YYYY (Refund Date) 5 Total Refund Transaction Count Refund Transaction of Details 6 Total Refund Amount Sum Refund Amount of Details (Show 2 decimals) 7 8 9 Examples “H” "1" KANOM PINKLAO 18/07/2015 19/07/2015 Remark "D" 2 11123123404 18/07/2015 08:01:10 1111111 1,000.00 mPAY Wallet 17/07/2015 18:01:10 18/07/2015 Remark “T” Last Sequence No. KANOM PINKLAO 18/07/2015 1 1,000.00 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 25 mPAY Gateway : API Guide and Reference version 1.0.7.1 Report Type : Settlement Report Report Name : YYYYMMDD_SETM_<MERCHANTNAME>.csv 1. Header No. Colume Name Description 1 Type Header 2 Sequence First Sequence No. 3 Merchant Name Merchant Name (Always show in upper case) 4 Settlement Date Format : DD/MM/YYYY (Settle Date) 5 Process Run Date Format : DD/MM/YYYY (Normally = Transaction date + 1) 8 2. Detail No. Description Remark 1 Type "D" = Detail 2 Sequence Running Sequence No. 3 Batch Id Settle Batch Id 4 Batch Date Format : DD/MM/YYYY (Batch Date) 5 Payment Date Format : DD/MM/YYYY (Payment Date) 6 Sales Transaction Number of Sales & Dispute Clear Transaction 7 Sales Amount Amount of Sales & Dispute Clear Transaction 8 Fee Payment Fee 9 VAT VAT of Fee 10 Refund Transaction Number of Refund/Adjust Transaction 11 Refund Amount Amount of Refund/Adjust Transaction 12 Net Amount Net Amount that will transfer to merchant 3. Total No. Description Remark 1 Type “T” = Total 2 Sequence Last Sequence No. (Row id) 3 Merchant Name Merchant Name (Always show in upper case) 4 Settlement Date Format : DD/MM/YYYY (settle Date) 5 Total Settlement Batch Number of Settle Batch 6 Total Settlement Amount Sum of Net Amount (Show 2 decimals) 7 8 Examples “H” "1" KANOM PINKLAO 17/07/2015 18/07/2015 Remark "D" 2 11123123404 17/07/2015 16/07/2015 20 1,000.00 100.00 10.0 1 50.00 850.00 Remark “T” Last Sequence No. KANOM PINKLAO 17/07/2015 1 850.00 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 26 mPAY Gateway : API Guide and Reference version 1.0.7.1 Examples of data file (Delimeter = '|') FILE_NAME = 20150818_PAYM_TESTTEPS6342.csv TYPE|SEQUENCE|TRANSACTION_ID|PAYMENT_DATETIME|SELLER_ORDER_ID|TOTAL_AMOUNT|PAYMENT_METHOD|ORDER_DATE H|1|TESTTEPS6342|18/08/2015|19/08/2015|| D|2|1111272821|18/08/2015 16:00:53|1000010|1052.1|mPAY Wallet|18/08/2015 D|3|1111272769|18/08/2015 11:52:59|100001|1044.1|mPAY Wallet|18/08/2015 D|4|1111272767|18/08/2015 11:51:06|100000|1043.1|mPAY Wallet|18/08/2015 D|5|REC000003|18/08/2015 12:36:49|A39005|101.1|mPAY Wallet|18/08/2015 T|6|TestTeps6342|18/08/2015|4|3240.4|| @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 27 mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 9 – Resend SMS EndPoint URL This command can be used to resend text messages to the buyer’s mobile number as requested from Command “RequestOrderTepsApi” in the first time only. It uses a same message which links to the original endpoint URL, and that order has not yet been paid and expired. SMS will be sent out immediately and delivered within a few seconds. Table 8.1 : Resend SMS EndPoint URL parameter Input No Variable 1 2 3 3 projectCode command merchantId sid Data Type Character Character Numeric Character Max Length 10 50 20 36 Mandatory 4 orderId Character 30 Y 5 saleId Numeric 27 Y Y Y Y Y Description Name of project, use default is ‘TEPS’ ‘ResendSmsEndpoint’ Merchant No. (Assigned by mPAY) Merchant security control (specific to a merchant) Purchase Order Id. Use unique number within x month. (Generate by merchant) mPAY Payment request reference ID Remark 12345678 1111111111 1234 (Receive from Command: 'RequestOrderTepsApi') Output No Variable 1 status Data Type Character Max Length 1 Mandatory 2 respCode Character 10 Y Processing Status S = success , F = fail Detail of processing status 0000 = success code Other = error code 3 respDesc respDesc 100 Y Error Description Y Description @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 28 Remark S or F If status = ‘S’ and respCode = 0000 means API execution successfully CHKPI – Session Lost mPAY Gateway : API Guide and Reference version 1.0.7.1 Chapter 10 – Generic Action Response / Response Code Description Error Code Message to Customer 0000 Action successfully, completed 1767 standard Success format Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Your mPAY Wallet balance is not sufficient, please cash-in before proccessing transaction. Sorry, Service is temporary unavailable. Please try again later. Your transaction has timed out, please retry again. Sorry, Service is temporary unavailable. Please try again later. Invalid amount , please recheck and try again. Your balance is not sufficient, please cash-in before proccessing transaction. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please contact [Merchant call center] PIN code is temporary locked, please contact AIS CALL CENTER 1175 PIN code is incorrect, please try again. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please try again later. Invalid amount , please recheck and try again. Invalid amount , please recheck and try again. Sorry, Service is temporary unavailable. Please contact [Merchant call center] Your balance is not sufficient, please cash-in before proccessing transaction. Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please contact [Merchant call center] This order has already paid. 1771 This order has already expired. This order id already expired. 0001 0002 0003 0004 1007 1037 1038 1044 1112 1125 1141 1142 1143 1217 1278 1309 1427 1552 1581 1582 1619 1706 1713 1766 Error Cause Database Error Data not found Bu error other Update not Success CustomerId is null You have no money to pay ,please contact AIS CALL CENTER 1175 Transaction Not Found Session Lost Get mCash Balance Error Your amount is incorrect, please try again. Your mCASH is not sufficient, please refill your mCASH before making transaction. No Selected PI Duplicate Transactioin No Posting Text Pin code or Password is temporary locked, please contact AIS CALL CENTER 1175 Pin code is incorrect, please try again The service in temporary unavailable , please try again later. Voucher not found Amount Under Service Mininum Amount Over Service Maxinum Check Sum Incorrect Your balance is not sufficient, please check available balance or deposit to Beat S/A before making transaction. Sorry, Service is unavailable. Please try again later. There are incomplete required fields. This order id has already been paid. @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 29 mPAY Gateway : API Guide and Reference version 1.0.7.1 1772 1773 1774 1775 1790 6001 6008 6009 6036 6201 6204 6234 Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] Sorry, Service is temporary unavailable. Please contact [Merchant call center] You are not mPAY member, please register to mPAY before processing transaction (register via mPAY App; free download at google play or App store) Sorry, Service is temporary unavailable. Please try again later. Sorry, Service is temporary unavailable. Please contact [Merchant call center] This order id is not expired, can't create a new one. Missing or incorrect sid Incorrect purchaseAmt or Amount Incorrect Currency Merchant url response does not exists Please correct the mobile number. Please Input TranId Please Input Amount Please Input ProductAmt Please make a registration before using mPAY. The service is temporary unavailble,please try again later PostingTxt is null @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 30 mPAY Gateway : API Guide and Reference version 1.0.7.1 @2015 Advance mPAY Co., Ltd. ALL RIGHTS RESERVED Page 31