0.2.6 • Published 16 days ago

@rytass/payments-adapter-ecpay v0.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

Rytass Utils - Payments (ECPay)

Features

  • Built-in callback server
  • Checkout (Credit Card)
  • Checkout (Credit Card Installments)
  • Checkout (WebATM)
  • Checkout (ATM/Virtual Account)
  • Checkout (CVS)
  • Checkout (Barcode)
  • Checkout (Apple Pay)
  • Checkout (Line Pay)
  • Query
  • Refund
  • Refund (Installments)
  • Card Binding

Getting Started

Credit Card Payment

NOTICE Please use NAT tunnel service (like ngrok) to proxy built-in server if you behind a LAN network.

import { Channel, ECPayChannelCreditCard, ECPayPayment } from '@rytass/payments-adapter-ecpay';

// Use bulit-in server
const MERCHANT_ID = 'YOUR_ECPAY_MERCHANT_ID';
const HASH_KEY = 'YOUR_ECPAY_HASH_KEY';
const HASH_IV = 'YOUR_ECPAY_HASH_IV';

function onOrderCommit(order: ECPayOrder<ECPayChannelCreditCard>) {
  // When order committed, you can check amount, transaction code....
}

const payment = new ECPayPayment<ECPayChannelCreditCard>({
  merchantId: MERCHANT_ID,
  hashKey: HASH_KEY,
  hashIv: HASH_IV,
  serverHost: 'http://localhost:3000', // Built in server listen on localhost:3000 or ngrok url
  onCommit: onOrderCommit,
  withServer: true,
});

// Order id can auto assign or provide from `id` argument
const order = payment.prepare({
  channel: Channel.CREDIT_CARD,
  items: [{
    name: 'Book',
    unitPrice: 200,
    quantity: 1,
  }, {
    name: '鉛筆',
    unitPrice: 15,
    quantity: 2,
  }],
});

// You have three ways to pre-commit order

// 1. Get form data to prepare POST form by yourself
const form = order.form;

// 2. Get HTML including form data and automatic submit script
const html = order.formHTML;

// 3. Get built-in server URL to auto submit (only works if `withServer` is set)
const url = order.checkoutURL;
0.2.6

16 days ago

0.2.5

19 days ago

0.2.4

2 months ago

0.2.3

5 months ago

0.2.1

7 months ago

0.1.2

9 months ago

0.2.0

9 months ago

0.2.2

6 months ago

0.1.0

12 months ago

0.1.1

11 months ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago