Reference

SDKs and plugins

Node SDK, WooCommerce plugin and the OpenAPI spec.

Node

A zero-dependency client and webhook verifier for Node.js 18 and later. It works in Express, Next.js route handlers, Shopify apps and any other server-side JavaScript.

bash
npm install https://smartcontractsescrow.net/downloads/smart-contracts-escrow-node.tgz
js
const { EscrowClient, constructEvent } = require('@smart-contracts-escrow/node');

const escrow = new EscrowClient({ apiKey: process.env.SCE_API_KEY });

const session = await escrow.checkoutSessions.create(
  { title: 'Order #1001', amount: '149.99', external_reference: '1001', success_url: 'https://shop.example.com/thanks' },
  { idempotencyKey: 'order-1001' }, // optional; a UUID is generated otherwise
);
// Redirect the customer to session.url

// Later, when the order ships:
await escrow.escrows.submitMilestone(escrowId, milestoneId, 'DHL 1234567890');

Verify webhooks with the raw request body:

js
app.post('/escrow/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const event = constructEvent(req.body, req.get('X-Escrow-Signature'), process.env.SCE_WEBHOOK_SECRET);
  // Dedupe on event.id, then handle event.type
  res.sendStatus(200);
});
  • Errors throw EscrowApiError with status, type, code and details.
  • Network failures are retried once for GETs and idempotent POSTs.

WooCommerce

A payment gateway plugin that adds Pay with Escrow to your checkout and keeps orders in sync from webhooks. Download the plugin and follow the WooCommerce guide.

Other languages

The API is plain HTTPS and JSON, so any language works. Import the OpenAPI spec into Postman or Insomnia, or generate a client with OpenAPI Generator. Signature verification examples for Python and PHP are in Webhooks.