P
P
picka2020-12-05 09:47:44
JavaScript
picka, 2020-12-05 09:47:44

How to run index.js on click?

I have a small online store on NUXT.js. Everything is ready and working in it.

There is an interesting library https://github.com/lodosstm/yandex-checkout-node Yandex Checkout for Node.js

Question: How can I link them so that when I click on pay in the cart, the Yandex checkout script is launched and the client is redirected to the payment page ?

The maximum that was enough for my understanding of Node.js was to create a separate index.js file

var YandexCheckout = require('yandex-checkout')('******', '***********');

var idempotenceKey = '02347fc4-a1f0-49db-807e-f0d67c2ed5a5';
YandexCheckout.createPayment({
  'amount': {
    'value': '2.00',
    'currency': 'RUB'
  },
  'payment_method_data': {
    'type': 'bank_card'
  },
  'confirmation': {
    'type': 'redirect',
    'return_url': 'https://www.merchant-website.com/return_url'
  }
}, idempotenceKey)
  .then(function(result) {
    console.log({payment: result});
  })
  .catch(function(err) {
    console.error(err);
  })


Which actually showed that he is alive and the answer comes, given the fact that I launched it separately.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2020-12-05
@picka

You can try to create a component in the store, which will either access a certain service on the backend and receive a payment link

B
bqio, 2020-12-05
@bqio

The maximum that was enough for my understanding in Node.js

This is how you understand Nodejs, then you can aim at Yandex Cashier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question