首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >转换节点包以响应本机

转换节点包以响应本机
EN

Stack Overflow用户
提问于 2022-06-21 14:21:35
回答 1查看 113关注 0票数 0

我正在努力将CinetPay集成到React本地应用程序中。他们正在用Node包或CDN javascript提供解决方案。我已经从https://www.npmjs.com/package/cinetpay-nodejs安装了节点包。现在,我需要将这个节点包转换为使用React本机应用程序。

节点_模块/cinetpay/index.js代码

代码语言:javascript
复制
var cdn = document.createElement('script');  
cdn.setAttribute('src','https://cinetpay.com/cdn/seamless_sdk/latest/cinetpay.prod.min.js');
document.head.appendChild(cdn);
module.exports = require('./lib/cinetpay');

如何将此代码转换为反应本机代码?

EN

回答 1

Stack Overflow用户

发布于 2022-11-20 23:15:40

如果您希望在React本地应用程序中集成cinetpay,则需要使用axios并执行如下请求:

代码语言:javascript
复制
    var axios = require('axios');
    var data = JSON.stringify({
      "apikey": "YOUR_APIKEY",
      "site_id": "YOUR_SITEID",
      "transaction_id":  Math.floor(Math.random() * 100000000).toString(), //
      "amount": 100,
      "currency": "XOF",
      "alternative_currency": "",
      "description": " TEST INTEGRATION ",
      "customer_id": "172",
      "customer_name": "KOUADIO",
      "customer_surname": "Francisse",
      "customer_email": "harrissylver@gmail.com",
      "customer_phone_number": "+225004315545",
      "customer_address": "Antananarivo",
      "customer_city": "Antananarivo",
      "customer_country": "CM",
      "customer_state": "CM",
      "customer_zip_code": "065100",
      "notify_url": "https://webhook.site/d1dbbb89-52c7-49af-a689-b3c412df820d",
      "return_url": "https://webhook.site/d1dbbb89-52c7-49af-a689-b3c412df820d",
      "channels": "ALL",
      "metadata": "user1",
      "lang": "FR",
      "invoice_data": {
        "Donnee1": "",
        "Donnee2": "",
        "Donnee3": ""
      }
    });

    var config = {
      method: 'post',
      url: 'https://api-checkout.cinetpay.com/v2/payment',
      headers: { 
        'Content-Type': 'application/json'
      },
      data : data
    };

    axios(config)
    .then(function (response) {
      console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
      console.log(error);
    });

您可以在此链接文档中显示更多的内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72702476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档