All Projects → yozian → spgateway

yozian / spgateway

Licence: other
智付通API串接

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to spgateway

Openwrt Node Packages
OpenWrt Project Node.js packages. v10.x LTS and v12.x LTS and v14.x LTS
Stars: ✭ 176 (+780%)
Mutual labels:  node-module
Puppeteer
Headless Chrome Node.js API
Stars: ✭ 75,197 (+375885%)
Mutual labels:  node-module
database-js
Common Database Interface for Node
Stars: ✭ 58 (+190%)
Mutual labels:  node-module
Obs Studio Node
libOBS (OBS Studio) for Node.Js, Electron and similar tools
Stars: ✭ 193 (+865%)
Mutual labels:  node-module
Sequelize Auto Migrations
Migration generator && runner for sequelize
Stars: ✭ 233 (+1065%)
Mutual labels:  node-module
ifto
A simple debugging module for AWS Lambda (λ) timeout
Stars: ✭ 72 (+260%)
Mutual labels:  node-module
Flexsearch Server
High-performance FlexSearch Server for Node.js (Cluster)
Stars: ✭ 172 (+760%)
Mutual labels:  node-module
whatsapp-clone-react
Build a WhatsApp Clone with React JS and FireBase.
Stars: ✭ 38 (+90%)
Mutual labels:  node-module
Singlespotify
🎵 Create Spotify playlists based on one artist through the command line
Stars: ✭ 254 (+1170%)
Mutual labels:  node-module
bulksearch
Lightweight and read-write optimized full text search library.
Stars: ✭ 108 (+440%)
Mutual labels:  node-module
Flake Idgen
Flake ID generator yields k-ordered, conflict-free ids in a distributed environment in Node.js
Stars: ✭ 196 (+880%)
Mutual labels:  node-module
Json 2 Csv
Convert JSON to CSV *or* CSV to JSON!
Stars: ✭ 210 (+950%)
Mutual labels:  node-module
microbundle-ts-pkg
A TypeScript npm package skeleton/starter project with microbundle, node:test and prettier
Stars: ✭ 20 (+0%)
Mutual labels:  node-module
Ng Tailwindcss
A CLI tool for integrating Tailwind CSS into Angular-CLI projects
Stars: ✭ 194 (+870%)
Mutual labels:  node-module
cul
nodejs module to interact with busware cul / culfw
Stars: ✭ 26 (+30%)
Mutual labels:  node-module
Dockercon19
DockerCon "Docker for Node.js" examples
Stars: ✭ 176 (+780%)
Mutual labels:  node-module
ecoledirecte.js
Good-looking client for EcoleDirecte's private API.
Stars: ✭ 32 (+60%)
Mutual labels:  node-module
binrpc
HomeMatic xmlrpc_bin:// protocol server and client
Stars: ✭ 15 (-25%)
Mutual labels:  node-module
teaching-nodejs-expressjs-framework-spring-2019-2020
Complete Node-Express Application
Stars: ✭ 16 (-20%)
Mutual labels:  node-module
ioBroker.tankerkoenig
Spritpreis Adapter für ioBroker
Stars: ✭ 29 (+45%)
Mutual labels:  node-module

智付通API

簡化實作智付通付款流程與相關功能串接


已實作功能

範例

MPG Service

  • 付款(建立付款表單)
const SpGateway = require("spgateway-api");

const spgateway = new SpGateway(
    true, //(true for a dry run)
    your MerchantID,
    your HashKey,
    your HashIV,
    true // if you want to print info in console to debug. default is false
);

const mpgService = spgateway.createMpgService();

// crate payModel
let payModel = mpgService.createMpgPayModel();
// set properties
payModel.MerchantOrderNo = "myordernohere";
payModel.NotifyURL = "http://mysite.com/api/spgateway/notify";
payModel.ReturnURL = "http://mysite.com/api/spgateway/return";
payModel.ClientBackURL = "http://mysite.com/shop";
payModel.Amt = 928;
payModel.ItemDesc = "ProductX";

// create payform
let payFormHtml = mpgService.getAutoPayForm(payModel);
  • 接收通知(notify & return)
// take express request as example
let JSONData = request.body.JSONData;

mpgService
  .parseNotification(JSONData)
  .then((notify) => {
      // update your order here
  })
  .catch((err) => {
      // exception or checkCode validation fails
  })

Period Service (定期定額)

  • 付款(建立付款表單)
let periodService = spgateway.createPeriodicalService();
let payModel = periodService.createPeriodicalPayModel();

// set properties
payModel.PeriodAmt = 829;

// create pay form html
let payFormHtml = periodService.getAutoPayForm(payModel);
  • 接收通知(notify & return)
// take express request as example
let body = request.body; // it would be { "Period": "xxxxx..." }

periodService
  .parseNotification(body)
  .then((notify) => {
      // update your order here
  })
  .catch((err) => {
      // exception or checkCode validation fails
  })

交易查詢

let tradeInfoService = spgateway.createTradeInfoService();

tradeInfoService.queryOrder("yourOrderNoHere", 200)
  .then((model) => {
    // success

  })
  .catch((err) => {
    // if check value validation fails or exception
  })
  

信用卡取消授權

let cardCancelService = spgateway.createCreditCardCancelService();

cardCancelService
  .CancelTransaction("yourOrderNoHere", 200)
  .then((model) => {
      // success
      
  })
  .catch((err) => {
     // if status !== success or exception
  })
  

信用卡請/退款

let cardloseService = spgateway.createCreditCardCloseService();

// 請款
cardloseService
  .requestPayment("yourOrderNoHere", 200)
  .then((model) => {
    
  })
  .catch((err) => {
    
  })
  
// 退款
cardloseService
  .refund("yourOrderNoHere", 200)
  .then((model) => {
    
  })
  .catch((err) => {
    
  })
  

Debug Logger

const spgateway = new SpGateway(
        true, //(true for a dry run)
        your MerchantID,
        your HashKey,
        your HashIV,
        true // if you want to print info to debug, default is false
    );
        

關於

歡迎 fork & pull request

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].