npm install shopier-api
import { Shopier } from 'shopier-api'; //CommonJS
const { Shopier } = require('shopier-api') //ES
const shopier = new Shopier('apiKey', 'apiSecret');
shopier.setBuyer({
buyer_id_nr: '010101',
product_name: 'Balance',
buyer_name: 'Fatih',
buyer_surname: 'Akdoğan',
buyer_email: 'mail@mail.com',
buyer_phone: '05555555555'
});
shopier.setOrderBilling({
billing_address: 'Kennedy Caddesi No:2592',
billing_city: 'Istanbul',
billing_country: 'Türkiye',
billing_postcode: '34000'
});
shopier.setOrderShipping({
shipping_address: 'Kennedy Caddesi No:2592',
shipping_city: 'Istanbul',
shipping_country: 'Türkiye',
shipping_postcode: '34000'
});
const paymentPage = shopier.generatePaymentHTML(15);
This will return the purchase form as html.
app.get('/pay', (req, res) => {
res.end(paymentPage);
});
Now that we have render the html, a callback will be required after checkout.
app.post('/callback', (req, res) => {
const callback = shopier.callback(req.body, 'apiSecret');
});
{ order_id: 10592, payment_id: 413449826, installment: 0 }