Coder Social home page Coder Social logo

bytedance-mini-pay's Introduction

bytedance-mini-pay

字节跳动小程序支付SDK

Downloads Version License

使用

const { TTPay } = require('bytedance-mini-pay');

const ttpay = new TTPay({
  appId: '',  // 必须
  appSecret: '',  // 必须
  SALT: '',  // 必须
  TOKEN: '',  // 可选 为了安全性请务必填写!
  mchId: '',  // 可选 商户号
  notifyURL: 'https://example.com/webhook/payments/toutiao/callback',  // 可选 支付回调URL
});

// 下单的回调消息
const orderNotify = {
  msg: '{"appid":"tt84cdf2701bf7f8ed","cp_orderno":"t000004","cp_extra":"","way":"1","channel_no":"","channel_gateway_no":"12106090149746618265","payment_order_no":"4346300973202106091611552039","out_channel_order_no":"","total_amount":1,"status":"SUCCESS","seller_uid":"69664700453838051970"}',
  msg_signature: 'b6fd60b92b9e3502cab6e1e505a91ebaedc8a6d0',
  type: 'payment',
  timestamp: '1623235256',
  nonce: '2281'
};
if (ttpay.checkNotifySign(orderNotify)) {
  console.log('下单验证成功');
}

// 退款的回调消息
const refundNotify = {
  msg: '{"appid":"tt84cdf2701bf7f8ed","cp_refundno":"t343413r","cp_extra":"","status":"SUCCESS","refund_amount":1}',
  msg_signature: '9f7e0f8ac2bd0436ee2ca56f273bebfee4a5a37a',
  type: 'refund',
  timestamp: '1623239959',
  nonce: '2103',
};

if (ttpay.checkNotifySign(refundNotify)) {
  console.log('退款验证成功');
}

完整Web示例可以看 example

Reference

License

采用MIT许可证

bytedance-mini-pay's People

Contributors

flxxyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.