bwdk-sdk
v1.0.4
Published
A simple integration tool for Buy-with-Digikala (BWDK) express-checkout in node.js projects
Downloads
270
Maintainers
Readme
BuyWithDK Checkout:
Buy-with-Digikala implementation in Node.JS
⬇️ Installation
Install the package from npm and require it in your Node project:
npm install bwdk-sdkconst BuyWithDigikala = require("bwdk-sdk");
// or
import BuyWithDigikala from "bwdk-sdk";💻 Usage
const bwdk = new BuyWithDigikala("your-api-key");🚀 Methods
BuyWithDigikala includes only 4 methods:
1: Create New Order
There are 2 required fields for creating a new Order: 1: A unique merchant id for every order, later will be used in order verification. 2: Order body like this:
{
merchant_order_id: 1234,
main_amount: 20000,
Discount_amount: 4000,
loyalty_amount: 0,
tax_amount: 0,
final_amount: 16000,
callback_url: "https://yourdomain.com",
reservation_expired_at: 1802266032,
preparation_time: 4,
weight: 300,
items: [
{
id: 1,
name: "Product name",
primary_amount: 20000,
amount: 16000,
count: 1,
discount_amount: 4000,
tax_amount: 0,
image_link:
"https://yourdomain.com/product_image.jpg",
preparation_time: 2,
weight: 200,
has_tax: true,
tax_percent: 10,
options: [
{
type_name: "color",
name: "قرمز",
value: "#FF0000",
is_color: true,
},
{
type_name: "size",
name: "سایز",
value: "XL",
is_color: false,
},
],
},
],
}await bwdk.createOrder(orderData, merchantID);2: Get Order Details
await bwdk.getOrderDetails("your-order-uuid");in the response, if order.status was 7, or order.status_display was "paid by user", it means that the customer has successfully paid and now you should verify the payment.
3: Verify Order
In order to verify the payment, you should pass both order-uuid and the merchant_unique_id you passed when creating the order.
await bwdk.verifyOrder(orderId, merchantId);4: Refund Order (not for gateway_type: 1)
reason = "Why you refunded? eg: lack of inventory";
await bwdk.refundOrder(orderId, reason);