How to use the midtrans-client.CoreApi function in midtrans-client

To help you get started, we’ve selected a few midtrans-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Midtrans / midtrans-nodejs-client / examples / expressApp / app.js View on Github external
// pass transaction token to frontend
        res.render('simple_checkout',{
          token: transactionToken, 
          clientKey: snap.apiConfig.clientKey
        })
    })
})

/**
 * ===============
 * Using Core API - Credit Card
 * ===============
 */

// [0] Setup API client and config
let core = new midtransClient.CoreApi({
  isProduction : false,
  serverKey : 'SB-Mid-server-GwUP_WGbJPXsDzsNEBRs8IYA',
  clientKey : 'SB-Mid-client-61XuGAwQ8Bj8LxSS'
});

// [1] Render HTML+JS web page to get card token_id and [3] 3DS authentication
app.get('/simple_core_api_checkout', function (req, res) {
  res.render('simple_core_api_checkout',{ clientKey: core.apiConfig.clientKey })
})

// [2] Handle Core API credit card token_id charge
app.post('/charge_core_api_ajax', function (req, res) {
  console.log(`- Received charge request:`,req.body);
  core.charge({
    "payment_type": "credit_card",
    "transaction_details": {

midtrans-client

Official Midtrans Payment API Client for Node JS

MIT
Latest version published 6 days ago

Package Health Score

70 / 100
Full package analysis

Popular midtrans-client functions