https://github.com/skyquakers/payshift
聚合支付,支持彩虹易支付。Unified Payment API for Multiple Payment Processors
https://github.com/skyquakers/payshift
alipay ccbill epay ngenius nodejs payment payment-integration paypal stripe wechat-pay weixin-pay
Last synced: 11 months ago
JSON representation
聚合支付,支持彩虹易支付。Unified Payment API for Multiple Payment Processors
- Host: GitHub
- URL: https://github.com/skyquakers/payshift
- Owner: Skyquakers
- Created: 2023-03-10T15:23:52.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2025-07-11T03:34:40.000Z (11 months ago)
- Last Synced: 2025-07-18T11:47:37.710Z (11 months ago)
- Topics: alipay, ccbill, epay, ngenius, nodejs, payment, payment-integration, paypal, stripe, wechat-pay, weixin-pay
- Language: TypeScript
- Homepage:
- Size: 984 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Payshift
unified payment api for multiple payment processors
## Installation
```bash
npm install payshift
```
## Supported Payment Processors
- Alipay
- Wechat Pay
- Stripe
- Paypal
- EPay
- Multiple EPay instances with round robin algorithm to split your cashflow and risk
- CCBill
- N-Genius Payments
- Peropay
## Usage
```javascript
import {
Payshift,
AlipayProvider,
StripeProvider,
WechatPayProvider,
EPayProvider,
EPayClusterProvider
} from "payshift"
import { privateKeyPath, alipayPublicKeyPath, appId } from "your alipay config"
import { testKey, endpointSecret } from "your stripe config"
import { apiKey, mcid, publicKeyPath } from "your wechatpay config"
import { pid, key, endpoint } from "your epay config"
const alipay = new AlipayProvider({
appId,
privateKey: fs.readFileSync(path.join(__filename, privateKeyPath))
alipayPublicKey: fs.readFileSync(path.join(__filename, alipayPublicKeyPath))
})
const stripe = new StripeProvider(testKey)
const wechat = new WechatPayProvider(appId, mcid, publicKeyPath, privateKeyPath, apiKey)
const epay = new EPayProvider(endpoint, pid, key)
const anotherEPay = new EPayProvider(anotherEndpoint, anotherPid, anotherKey)
const epayCluster = new EPayClusterProvder([epay, anotherEPay])
const payshift = new Payshift([alipay, stripe, wechat, epay, epayCluster], {
stripeEndpointSecret: endpointSecret
})
// webhooks server, used for notify_url for some payments
payshift.startWebServer('http://localhost:3000', 3000)
// optionally, you can use mongodb to save your txns in "payshift" database
payshit.usedb()
// handle webhooks using the internal webhook server
payshift.on('charge.succeeded', async event => {
// handle event, eg. update the status of your order
// throwing any error will fail the webhook to the payment processor as well
})
```
Where `event` is a `PayshiftEvent`
```typescript
type PayshiftEvent = {
amount?: number // in cents
title?: string
outTradeNo?: string
tradeNo?: string
provider: PayshiftProviderName
name: PayshiftEventName
currency?: CurrencyCode
accountId?: string
}
```
Then
```javascript
// depending on your channel, res varys
const res = await payshift.createCharge({
outTradeNo: '123123123',
title: 'item',
amount: 1,
channel: 'alipay_mobile_web',
currency: CurrencyCode.CNY,
returnUrl: 'http://taobao.com',
clientIp: '127.0.0.1',
})
// in this case for alipay_mobile_web, res.data is a string of url
return res.data
```
## Supported Payment Channels
```typescript
type PayshiftChannel =
| 'stripe_web'
| 'alipay_web'
| 'wechat_qrcode'
| 'wechat_mobile_web'
| 'alipay_mobile_web'
| 'epay_alipay'
| 'epay_wechat_pay'
| 'epay_cluster_alipay'
| 'epay_cluster_wechat_pay'
| 'order2faka'
| 'paypal'
| 'ccbill_web'
```
## Using Provider Alone
Of course you can use provider independently
```javascript
const provider = new StripeProvider(testKey)
const accountId = await provider.createAccount({
country: 'JP',
type: 'express',
business_type: 'individual',
capabilities: { transfers: { requested: true } },
tos_acceptance: { service_agreement: 'recipient' },
})
const url = await provider.createAccountLink(
accountId,
'http://taobao.com',
'http://taobao.com'
)
console.log(url)
```