Pay For Service
Automate and integrate Pay For Service workflows with ease
Category: productivity Source: coinbase/agentic-wallet-skillsPay For Service is a community skill for implementing service payment flows in applications, covering one-time payments, invoicing, escrow patterns, payment confirmation, and receipt generation for service-based transactions.
What Is This?
Overview
Pay For Service provides patterns for processing payments for services rendered in applications. It covers one-time payment processing with amount calculation, tax handling, and payment method selection, invoice generation with line items, due dates, and payment status tracking, escrow patterns where funds are held until service completion is confirmed, payment confirmation with receipts, email notifications, and transaction records, and refund handling for service disputes or cancellations. The skill enables developers to build transactional payment flows where services are exchanged for payment.
Who Should Use This
This skill serves developers building service marketplace platforms with provider-client payment flows, teams implementing invoicing and payment collection for professional services, and engineers adding payment processing to freelance or gig platforms.
Why Use It?
Problems It Solves
Service payments require tracking payment state across multiple stages from invoice to completion. Escrow logic where funds are released on service delivery needs careful state management. Tax calculation varies by jurisdiction and service type, adding complexity to invoicing. Dispute resolution requires refund capabilities tied to specific service transactions.
Core Highlights
Invoice engine generates itemized bills with tax calculation and due dates. Payment processor handles charge creation with multiple payment methods. Escrow manager holds funds and releases on delivery confirmation. Receipt generator creates transaction records for both parties.
How to Use It?
Basic Usage
// Service payment flow
interface ServiceInvoice {
id: string;
clientId: string;
providerId: string;
items: {
description: string;
amount: number;
}[];
tax: number;
total: number;
status: 'pending' | 'paid'
| 'refunded';
}
async function createInvoice(
clientId: string,
providerId: string,
items: {
description: string;
amount: number;
}[]
): Promise<ServiceInvoice> {
const subtotal = items.reduce(
(sum, i) => sum + i.amount, 0);
const tax =
Math.round(subtotal * 0.1);
const total = subtotal + tax;
return db.invoices.create({
data: {
clientId, providerId,
items, tax, total,
status: 'pending',
},
});
}
async function payInvoice(
invoiceId: string,
paymentMethodId: string
) {
const invoice =
await db.invoices
.findUnique({
where: { id: invoiceId },
});
await stripe.paymentIntents
.create({
amount: invoice!.total,
currency: 'usd',
payment_method:
paymentMethodId,
confirm: true,
});
await db.invoices.update({
where: { id: invoiceId },
data: { status: 'paid' },
});
}
Real-World Examples
// Escrow payment pattern
class EscrowService {
async holdFunds(
invoiceId: string
) {
const invoice =
await db.invoices
.findUnique({
where: {
id: invoiceId },
});
const intent =
await stripe.paymentIntents
.create({
amount: invoice!.total,
currency: 'usd',
capture_method:
'manual',
confirm: true,
payment_method:
invoice!.paymentMethod,
});
await db.escrow.create({
data: {
invoiceId,
intentId: intent.id,
status: 'held',
},
});
}
async releaseFunds(
invoiceId: string
) {
const escrow =
await db.escrow
.findUnique({
where: { invoiceId },
});
await stripe.paymentIntents
.capture(
escrow!.intentId);
await db.escrow.update({
where: { invoiceId },
data: {
status: 'released' },
});
}
async refundFunds(
invoiceId: string
) {
const escrow =
await db.escrow
.findUnique({
where: { invoiceId },
});
await stripe.paymentIntents
.cancel(
escrow!.intentId);
await db.escrow.update({
where: { invoiceId },
data: {
status: 'refunded' },
});
}
}
Advanced Tips
Use Stripe manual capture for escrow patterns where funds are authorized but not captured until service delivery is confirmed. Implement webhook listeners for payment status changes to keep invoice records synchronized. Add automatic invoice reminders for overdue payments using scheduled jobs.
When to Use It?
Use Cases
Build a freelance marketplace where clients pay into escrow and funds release on project approval. Create an invoicing system for professional services with tax calculation and receipt generation. Implement a service booking platform with upfront payment and refund on cancellation.
Related Topics
Payment processing, escrow patterns, invoicing, Stripe integration, and service marketplaces.
Important Notes
Requirements
A payment provider supporting manual capture for escrow flows. Database for storing invoice and escrow records. Email service for sending invoices and receipts.
Usage Recommendations
Do: use manual capture payment intents for escrow to avoid holding funds without authorization. Track all payment state transitions in the database for audit trails. Send receipts automatically after successful payment.
Don't: capture escrow funds without explicit delivery confirmation from the client. Store payment method details directly instead of using tokenized references. Skip refund logging which makes dispute resolution difficult.
Limitations
Manual capture authorizations expire after a provider-specific window requiring re-authorization for long service periods. Cross-border service payments involve currency conversion and compliance requirements. Escrow patterns add complexity to the payment flow compared to direct charges.