package wxpayapi

import (
	"strings"
	"testing"

	"git.rosy.net.cn/baseapi/utils"
)

func TestPayCallback(t *testing.T) {
	bodyMsg := strings.Replace(`
	<xml><appid><![CDATA[wx4b5930c13f8b1170]]></appid>\n<bank_type><![CDATA[CMB_CREDIT]]></bank_type>\n<cash_fee><![CDATA[1]]></cash_fee>\n<fee_type><![CDATA[CNY]]></fee_type>\n<is_subscribe><![CDATA[N]]></is_subscribe>\n<mch_id><![CDATA[1390686702]]></mch_id>\n<nonce_str><![CDATA[8E0DDB300B7511EA908C186590E02977]]></nonce_str>\n<openid><![CDATA[ojWb10N52xdnLuInkn06bkn9pUhk]]></openid>\n<out_trade_no><![CDATA[8E0DD6260B7511EA908C186590E02977]]></out_trade_no>\n<result_code><![CDATA[SUCCESS]]></result_code>\n<return_code><![CDATA[SUCCESS]]></return_code>\n<sign><![CDATA[5281BDD91AF551FF7CDF1A0F6D702A30]]></sign>\n<time_end><![CDATA[20191120171206]]></time_end>\n<total_fee>1</total_fee>\n<trade_type><![CDATA[NATIVE]]></trade_type>\n<transaction_id><![CDATA[4200000455201911201954456843]]></transaction_id>\n</xml>
	
	
	
	`, "\\n", "\n", -1)
	result, err := api.getCallbackMsg(bodyMsg)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestPayRefundCallback(t *testing.T) {
	bodyMsg := strings.Replace(`
	<xml><return_code>SUCCESS</return_code><appid><![CDATA[wx4b5930c13f8b1170]]></appid><mch_id><![CDATA[1390686702]]></mch_id><nonce_str><![CDATA[092e154ce3baac44dd1c9091b50639ec]]></nonce_str><req_info><![CDATA[5bRx2mV2fwR09J0CxiLBfJkeIFYRgW6m8qKkz853XZEf5nxXLzevP7j2eF+Gno1v/800tU4ZRAW1RsJjNUckKdtHBxvaVMxD+oMzDRf1YqRSfiLS9s6km1aMAXwqlJbX3leMWw9QNmngeNBA2cSiZe02pY8Gbj+R8b2YEU2QStq+1+iZya14fvvc9wxTtXBO3KeZ9beJ0jf/mI7IEBXC1KG5QX42Yuyo8gXFQwF/64wr/2gsg+A8KVwEJF07lVEMPYhRdXz8C5Qr40nVM1Pd8ulHEoO+kCELW5GWjT2hs8Io4e6OLtZ5kG8Zp7E5u7iY5XmpTIsgtypn9AuW2voCBZ0VAeYVmcsR6qVBJFKVVkcDA0Kmb0II3cp9otOztGgfATuqDAfncYEoC8NqUdopwBVesC7fEbOEdfPfi6GvJdXTN4mAjDVtRudvttLn3+wTt5X7BqgeuZrAfcbT/gr3pbUFi2Cgv7ubHWtcOGFyhIw/qnA7burUMZ06WdT6Q0CZKeWPJTgT0UbB47T15Zbu9VFeMS0cZlOxn2L1cU/XgY/XDRmjB7gDayasrHQUaotj7F77KSX5Ijf+YbTmVyiGDwb1vocLlQMZax6GD9ECcytFty1jdW9GYJVz56Xnbmq9K7LUgzNZURlWZPY+aoPv8rG+3LaRAKDLBzQYKN2+lyNziXBP60xRicdMHmdTnYHPb8Bcj5c0Byy9ufw9+hMjAXzC9D9qMeDxvt1qHjGd3b8bA6cgpbQtDg6vI3arruiR+WVfn9/ZN26WrG/iLxST927wXmHRwJSitCBty0X/x+/lealMiyC3Kmf0C5ba+gIFxOe1Wx7OP0RQmkL5WPvttMf7ogU9RZamVfjgs6aPw3l4bxTmMHJkSvePUpdWpOU4ZXVH+aVgcX3KZWrn7ltf2Tvdbfi8IVFjzbvwn+4smC6u4cMQpMMpRLeuIqwwwg4J+rqOkyV3JdiTGInu2NErhFshQl868hoaSe4lJ2aaU/z9miDtBQkS0K3bQIWIUv4+kLyEgzQ6ld3qjEXEVme/DiLygEJLstIXvNMY43MdUYRF1BpOzpVB/ed28bQrshx++ROPrjthlX4bwksi5Qtpvg==]]></req_info></xml>	
	
	
	`, "\\n", "\n", -1)
	result, err := api.getCallbackMsg(bodyMsg)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}
