WeChat Pay Developer Documentation - minglepay/paystory_global GitHub Wiki

βœ… WeChat Pay is a simple payment method using QR code and digital wallet serviced by the WeChat.


Sample Files


  




1. Overview

  • ⚠ Notice

    • βœ” Merchants must develop in an environment where a web browser is available,
           because WeChat Pay requires that buyer to scan the QR Code using the WeChat Pay app.
    • βœ” Users must have WeChat app installed in advance for payment.
    • βœ” Users proceed with payment by scanning QR code created by Pay-Story with URL information.

QR Code example

  • Payment Flows

    • 1️⃣ Merchant to create payment data including forgery prevention.
      • User enters payment information to a web page configured by the merchant.
    • 2️⃣ Authentication and Authorization
      • Merchant processes the payment information and merchant information received from the user and sends authentication request to Paystory.
      • Pay-Story creates a QR code and displays it on the payment window.
      • Users scan QR code with WeChat APP then proceed with authorization
      • When authentication is completed, Pay-Story sends authorization result data to the merchant(returnUrl).

  • HashData configuration

    πŸ”’ When requesting authentication, payment, or cancellation, the integrity of the request data is verified using
    encrypted hashdata.

Parameter Algorithm Plain text
encData Hex(Sha256) mid + ediDate + goodsAmt + merchant key(merchantKey)



2. Installation

  • Requirement

    • Merchant Key Setting

      • The Merchant Key is a value that functions as a password for payment use and is allocated for each MID (Merchant ID).
      • "How to find the merchant key" : After accessing Paystory Merchant Admin (https://mms.minglepay.co.kr),
        merchant key information is found on the menu β€œ[Account Management]β–Ά[Payment Configuration]β–Ά[KEY Information]”
      • ❗ $\textcolor{red}{\textsf{Please be careful not to disclose the key information to the outside.}}$
    • Form Data setting for Payment request

      • Please set the name attribute in the input tag (used when executing payment request script).
      • Please set the field names with accurate case sensitivity.
      • Please set all fields to "hidden" except for cases where the user needs to change them.
      • Set the action attribute of the form tag to redirect to the Authorization request page after authentication is completed.
    • Include JavaScript for calling payment window

      • Include the JS File(https://pg.minglepay.co.kr/js/pgAsistant.js) provided by Pay-Story.
        ⚠ If you download and use the JS file, payment may not be processed.
      • To call the payment window and submit after authentication, you must use two functions(SendPay() & pay_result_submit()) defined in the JS file.
<script type="text/javascript">
// function for calling payment window 
	function doPaySubmit(){
		SendPay(document.formID);  
	}
//  Function for payment Result (❌Do not modify function name )
	function pay_result_submit(){
		payResultSubmit()
	}

</script> 

2.1 Payment Request and Response Configuration


2.1.1 Payment Request Parameters

  • πŸ“Œ Use the sendPay() function defined in the Pay-Story JS file (https://pg.minglepay.co.kr/js/pgAsistant.js) to send the payment request data (FormData) and call the payment window.
Parameter Description Required Size(Byte)
payMethod ${{\color{Red}\huge{\textsf{*}}}}$ Payment method GLOBAL: Global Pay O 10
cpCd ${{\color{Red}\huge{\textsf{*}}}}$ Issuer Code (WCHT: Fixed) O 4
tradeType ${{\color{Red}\huge{\textsf{*}}}}$ WeChat Transaction Type
0: NATIVE(PC), 4: H5(Mobile)
O 1
mid ${{\color{Red}\huge{\textsf{*}}}}$ Merchant ID O 10 Fixed
subMchId ${{\color{Red}\huge{\textsf{*}}}}$ WeChat Sub merchant ID O 32
trxCd ${{\color{Red}\huge{\textsf{*}}}}$ β€œ0” (fixed) Used in Escrow service (0: No 1: Yes) O 1
goodsNm ${{\color{Red}\huge{\textsf{*}}}}$ Goods name O 100
ordNo ${{\color{Red}\huge{\textsf{*}}}}$ Merchant order ID
βœ… ${{\color{BurntOrange}{\textsf{Unique value required}}}}$
O 40
goodsAmt ${{\color{Red}\huge{\textsf{*}}}}$ Payment amount (βœ… ${{\color{BurntOrange}{\textsf{numbers only}}}}$)
βœ… Please include 2 digits of cent E.g. β€œ1050”: 10 dollars and 50 cents
O 12
ordNm ${{\color{Red}\huge{\textsf{*}}}}$ Buyer name O 30
ordTel ${{\color{Red}\huge{\textsf{*}}}}$ Phone number(βœ… ${{\color{BurntOrange}{\textsf{numbers only}}}}$) O 20
ediDate ${{\color{Red}\huge{\textsf{*}}}}$ Request date (yyyymmddhhmmss) O 14
encData ${{\color{Red}\huge{\textsf{*}}}}$ Hash256 encrypted value O 256
returnUrl ${{\color{Red}\huge{\textsf{*}}}}$ Return page URL to receive payment result
βœ… ${{\color{BurntOrange}{\textsf{PC Not use, Mobile Only}}}}$
O N/A
ordEmail Buyer email 60
skipTerm Use of displaying terms on window 0: Display, 1: Skip Optional -
language Displaying language
(KOR: Korean, ENG:English, CHN: Chinese)
currencyType β€œKRW”: Won, β€œUSD”: Dollar
default β€œKRW”
mbsUsrId User id 20
mbsReserved Reserved field for merchant 255
notiUrl DB processing page URL to receive payment result In Back-End (server side) Optional N/A

2.1.2 Payment Response Parameters

  • πŸ“Œ When Payment is complete, pay_result_submit() is called by the included JS file.
    • πŸ‘‰ pay_result_submit() send the payment result data to the URL set in returnUrl parameter.
Parameter Description Size(Byte)
resultCd Payment result code 0000: success, Other failures 10
resultMsg Result Message 100
payMethod Payement method (β€œGLOBAL”) 20
cpCd Issuer Code (β€œWCHT”) 4
tid Transaction ID 30
mid Merchant ID 10
subMchId WeChat Sub merchant ID 32
ediDate Response D (yyyymmddhhmmss) 14
appDtm Payment date (yyyymmddhhmmss) 14
appNo Authorization number 30
ordNo Merchant order ID 40
goodsName Goods name 100
amt Payment amount 9
ordNm Buyer name 30
cancelYN Transaction type N : authorization, Y : Cancellation 1
fnNm Issuer Name (β€œμœ„μ±—νŽ˜μ΄β€) 20
mbsUsrId User ID 20
mbsReserved Reserved field for merchant 255
⚠️ **GitHub.com Fallback** ⚠️