台灣第三方金流服務智付通API串接小幫手
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SpGatewayHelper
SpGatewayHelperTests 台灣第三方金流服務智富通API串接小幫手 Jun 18, 2017
.gitignore Initial commit Jun 18, 2017
LICENSE Initial commit Jun 18, 2017
README.md 修正錯字 Jun 18, 2017
spgatewayTest.sln 台灣第三方金流服務智富通API串接小幫手 Jun 18, 2017

README.md

SPGateway

台灣第三方金流服務智付通API串接小幫手

此小幫手只處理 智付通 交易所需的 AES 加解密與 雜湊(SHA)字串檢查

public class HomeController : Controller
{
    private readonly string _key;
    private readonly string _Vi;

    public HomeController()
    {
        _key = "xbEznJ0PExvWzd5ct72dLPCMPIBUw8K3";
        _Vi = "kpDI8DxNb2JKgOXK";
    }

    public ActionResult Index()
    {
        var tradeInfo = new TradeInfo()
        {
            MerchantID = "MS12345678",
            RespondType = "JSON",
            TimeStamp = DateTime.Now.ToUnixTimeStamp(),
            Version = "1.4",
            Amt = 100,
            ItemDesc = "TTEESSTT",
            //InstFlag="3,6",
            //CreditRed = 0,
            Email = "demo@demo.demo",
            EmailModify = 0,
            LoginType = 0,
            MerchantOrderNo = DateTime.Now.Ticks.ToString(),
            TradeLimit = 180,
            //CVS=1,
            //ExpireDate=DateTime.Now.ToString("yyyyMMdd"),
            ReturnURL = "http://localhost:51639/home/index",
        };
        var postData = tradeInfo.ToDictionary();
        var cryptoHelper = new CryptoHelper(_key, _Vi);
        var aesString = cryptoHelper.GetAesString(postData);
        ViewData["TradeInfo"] = aesString;
        ViewData["TradeSha"] = cryptoHelper.GetSha256String(aesString);
        return PartialView();
    }

    [HttpPost]
    public ActionResult Index(SpGatewayResponse response)
    {
        response.Key = _key;
        response.Vi = _Vi;
        var success = response.Validate("MS12345678");
        if (success)
        {
            var tradInfoModel=response.GetResponseModel<TradeInfoModel>();
        }
        return View();
    }
}