Kako začeti uporabljati Privacy Gate na Node JS

Če nameravate začeti sprejemati plačila s kriptovalutami in še niste seznanjeni s tem, kako deluje PrivacyGate, je vredno porabiti 5 minut vašega časa.

Seznam razpoložljivih kriptovalut: Bitcoin, Bitcoin Cash, Ethereum, Litecoin, USD Coin, Tether (ERC20), Dai, Chainlink.

Oglejte si vzorec projekta na:https://github.com/privacyshore/privacygate-node-sample

alt

Pa začnimo.

Preden karkoli nadaljujete

  1. Registering an PrivacyGate accountalt
  2. Navigating to the “settings” pagealt
  3. Generating an API keyaltalt
  4. Keep track of this API key as it will be needed in this tutorial

Ko to storite, pojdite v svoje razvojno okolje in izvedite naslednje ukaze:In case you have no project to work with as of right now, check out our sample project athttps://github.com/privacyshore/privacygate-node-sample

npm install privacygate

S tem boste namestili knjižnico privacygate nodejs.

var privacygate = require('privacygate');
var Client = privacygate.Client;

var clientObj = Client.init('<API_KEY>');
clientObj.setRequestTimeout(3000);

To bo ustvarilo objekt odjemalca, ki ga lahko uporabimo za interakcijo z API-jem privacygate.

To nam bo omogočilo več stvari. Na primer (v zvezi z blagajnami):

  1. Retrieve
var Checkout = privacygate.resources.Checkout;
Checkout.retrieve(<checkout_id>, function (error, response) {
  console.log(error);
  console.log(response);
});
  1. Create
var checkoutData = {
    'name': 'The Sovereign Individual',
    'description': 'Mastering the Transition to the Information Age',
    'pricing_type': 'fixed_price',
    'local_price': {
        'amount': '100.00',
        'currency': 'USD'
    },
    'requested_info': ['name', 'email']
};
Checkout.create(checkoutData, function (error, response) {
  console.log(error);
  console.log(response);
});

// or

var checkoutObj = new Checkout();

checkoutObj.name = 'The Sovereign Individual';
checkoutObj.description = 'Mastering the Transition to the Information Age';
checkoutObj.pricing_type = 'fixed_price';
checkoutObj.local_price = {
    'amount': '100.00',
    'currency': 'USD'
};
checkoutObj.requested_info = ['name', 'email'];

checkoutObj.save(function (error, response) {
  console.log(error);
  console.log(response);
});
  1. Update
var checkoutObj = new Checkout();

checkoutObj.id = <checkout_id>;
checkoutObj.name = 'new name';

checkoutObj.save(function (error, response) {
  console.log(error);
  console.log(response);
});
// or
var newParams = {
    'name': 'New name'
};

Checkout.updateById(<checkout_id>, newParams, function (error, response) {
  console.log(error);
  console.log(response);
});
  1. Delete
var checkoutObj = new Checkout();

checkoutObj.id = <checkout_id>;
checkoutObj.delete(function (error, response) {
 console.log(error);
 console.log(response);
});

// or

Checkout.deleteById(<checkout_id>, function (error, response) {
 console.log(error);
 console.log(response);  
});

Pogledhttps://github.com/privacyshore/privacygate-node/tree/master/examples/resourcesza več primerov