payment-gateway-integration by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill payment-gateway-integration集成安全的支付处理,具备适当的错误处理和合规性。
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
class PaymentService {
async createPaymentIntent(amount, currency, customerId) {
return stripe.paymentIntents.create({
amount: Math.round(amount * 100), // 转换为分
currency,
customer: customerId,
automatic_payment_methods: { enabled: true }
});
}
async createSubscription(customerId, priceId) {
return stripe.subscriptions.create({
customer: customerId,
items: [{ price: priceId }],
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent']
});
}
async refund(paymentIntentId, amount = null) {
const params = { payment_intent: paymentIntentId };
if (amount) params.amount = Math.round(amount * 100);
return stripe.refunds.create(params);
}
}
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
switch (event.type) {
case 'payment_intent.succeeded':
await handlePaymentSuccess(event.data.object);
break;
case 'invoice.payment_failed':
await handlePaymentFailed(event.data.object);
break;
}
res.json({ received: true });
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
完整的 PayPal 实现请参阅 references/paypal-integration.md,内容包括:
应该做:
不应该做:
每周安装次数
74
代码仓库
GitHub 星标数
93
首次出现
2026年1月25日
安全审计
安装于
claude-code66
cursor61
gemini-cli59
codex58
opencode58
github-copilot55
Integrate secure payment processing with proper error handling and compliance.
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
class PaymentService {
async createPaymentIntent(amount, currency, customerId) {
return stripe.paymentIntents.create({
amount: Math.round(amount * 100), // Convert to cents
currency,
customer: customerId,
automatic_payment_methods: { enabled: true }
});
}
async createSubscription(customerId, priceId) {
return stripe.subscriptions.create({
customer: customerId,
items: [{ price: priceId }],
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent']
});
}
async refund(paymentIntentId, amount = null) {
const params = { payment_intent: paymentIntentId };
if (amount) params.amount = Math.round(amount * 100);
return stripe.refunds.create(params);
}
}
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
switch (event.type) {
case 'payment_intent.succeeded':
await handlePaymentSuccess(event.data.object);
break;
case 'invoice.payment_failed':
await handlePaymentFailed(event.data.object);
break;
}
res.json({ received: true });
});
See references/paypal-integration.md for complete PayPal implementation with:
Do:
Don't:
Weekly Installs
74
Repository
GitHub Stars
93
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code66
cursor61
gemini-cli59
codex58
opencode58
github-copilot55
lark-cli 共享规则:飞书资源操作指南与权限配置详解
39,000 周安装