Skip to content

Payment to Invoice Workflow

Automatically generate and email invoices when customers make payments through Stripe


Overview

This intermediate workflow demonstrates how to capture Stripe payment webhooks, create customer records, generate PDF invoices, and email them automatically - creating a complete payment-to-invoice pipeline.

What You'll Build: - Receive Stripe payment notifications - Create/match customer in CRM - Generate invoice in BaseCloud Accounting - Create PDF of invoice - Email invoice PDF to customer - Log payment in CRM

Real-World Applications: - E-commerce order invoicing - Service payment receipts - Subscription billing documentation - Professional services invoicing - Membership payment tracking


Workflow Diagram

graph LR
    A[Stripe Payment<br/>TRIGGER] --> B[Match to Client<br/>Find Existing]
    B --> C[BaseCloud Accounting<br/>Create Invoice]
    C --> D[PDF<br/>Generate Invoice PDF]
    D --> E[Email<br/>Send Invoice]
    E --> F[Workflow Note<br/>Log Payment]
    F --> G[End]

Tasks Used

Order Task Type Purpose Difficulty
1 Webhook In Receive Stripe payment webhook ⭐⭐ Intermediate
2 Match to Client Find existing customer record ⭐ Beginner
3 BaseCloud Accounting Create invoice in accounting system ⭐⭐ Intermediate
4 PDF Generate invoice PDF ⭐⭐ Intermediate
5 Email Send invoice to customer ⭐ Beginner
6 Workflow Note Log payment activity ⭐ Beginner

Total Setup Time: 30-40 minutes
Skill Level: Intermediate
Prerequisites: Stripe account with webhook access, BaseCloud Accounting configured


Step-by-Step Setup

Step 1: Create Workflow

  1. Go to Settings → Automation
  2. Click Add Workflow
  3. Enter:
  4. Name: Payment to Invoice - Stripe
  5. Description: Auto-generate and email invoices for Stripe payments
  6. Click Create Workflow

Step 2: Configure Stripe Webhook Trigger

2.1: Create Webhook in BaseCloud

  1. Click Add Task on canvas
  2. Select Webhook In trigger
  3. Configure:
  4. Task Name: Stripe Payment Received
  5. Click Save
  6. Copy webhook URL (e.g., https://yourapp.basecloudglobal.com/webhook/abc123)

2.2: Add Webhook to Stripe Dashboard

  1. Go to Stripe Dashboard → Developers → Webhooks
  2. Click Add Endpoint
  3. Endpoint URL: Paste BaseCloud webhook URL
  4. Events to send:
  5. payment_intent.succeeded
  6. charge.succeeded
  7. Click Add Endpoint
  8. Copy Signing Secret (starts with whsec_)

2.3: Test Stripe Webhook

  1. In Stripe Dashboard, click Send test webhook
  2. Select payment_intent.succeeded
  3. Click Send test webhook
  4. Return to BaseCloud workflow
  5. Click on webhook trigger task
  6. Verify test data appears in LEFT panel

Stripe Payment Data Available:

{{task_1001_data.amount}}                    // Amount in cents (1500 = $15.00)
{{task_1001_data.currency}}                  // Currency code (usd, eur, zar)
{{task_1001_data.customer}}                  // Stripe customer ID
{{task_1001_data.payment_intent}}            // Payment intent ID
{{task_1001_data.receipt_email}}             // Customer email
{{task_1001_data.billing_details.name}}      // Customer name
{{task_1001_data.billing_details.phone}}     // Customer phone
{{task_1001_data.description}}               // Payment description

Webhook Configuration


Step 3: Match/Create Customer

  1. Click Add Task below webhook
  2. Select Match to Client
  3. Configure:
  4. Parent Task: Stripe Payment Received
  5. Match by: Email
  6. Email: {{task_1001_data.receipt_email}}
  7. Name: {{task_1001_data.billing_details.name}}
  8. Phone: {{task_1001_data.billing_details.phone}}
  9. Create if not found: ✅ Yes
  10. Custom Fields:
    • stripe_customer_id = {{task_1001_data.customer}}
  11. Task Name: Find or Create Customer

What This Does: - Searches for existing customer by email - Creates new customer if not found - Stores Stripe customer ID for future reference - Prevents duplicate customer records

Output:

{{task_1002_client_id}}              // BaseCloud customer ID
{{task_1002_is_new_client}}          // true/false
{{task_1002_client_name}}            // Customer name
{{task_1002_client_email}}           // Customer email


Step 4: Create Invoice in Accounting

  1. Click Add Task after Match to Client
  2. Select BaseCloud Accounting
  3. Configure:
  4. Parent Task: Find or Create Customer
  5. Action: Create Invoice
  6. Client ID: {{task_1002_client_id}}
  7. Invoice Date: {{current_date}}
  8. Due Date: {{current_date}} (already paid)
  9. Status: Paid
  10. Line Items:
    [
      {
        "description": "{{task_1001_data.description}}",
        "quantity": 1,
        "unit_price": "{{task_1001_data.amount / 100}}",
        "tax_rate": 0
      }
    ]
    
  11. Payment Method: Stripe
  12. Payment Reference: {{task_1001_data.payment_intent}}
  13. Notes: Paid via Stripe on {{current_date}}
  14. Task Name: Create Invoice

Amount Calculation: - Stripe returns amounts in cents (1500 = $15.00) - Divide by 100: {{task_1001_data.amount / 100}} - Use Variable task if complex calculation needed

Output:

{{task_1003_invoice_id}}             // Invoice ID
{{task_1003_invoice_number}}         // Invoice #INV-001234
{{task_1003_total_amount}}           // Total with tax
{{task_1003_invoice_url}}            // View invoice URL

Accounting Task Configuration


Step 5: Generate Invoice PDF

  1. Click Add Task after Create Invoice
  2. Select PDF
  3. Configure:
  4. Parent Task: Create Invoice
  5. PDF Type: Invoice
  6. Invoice ID: {{task_1003_invoice_id}}
  7. Template: Default Invoice Template
  8. Include: Logo, Payment Details, Tax Breakdown
  9. Task Name: Generate Invoice PDF

What This Does: - Converts invoice to professional PDF - Uses your company branding - Includes all invoice line items - Adds payment status stamp - Generates secure download URL

Output:

{{task_1004_pdf_url}}                // Direct PDF download link
{{task_1004_pdf_filename}}           // invoice_INV-001234.pdf
{{task_1004_file_size}}              // File size in KB

PDF Generation Config


Step 6: Email Invoice to Customer

  1. Click Add Task after Generate PDF
  2. Select Email
  3. Configure:
  4. Parent Task: Generate Invoice PDF
  5. To: {{task_1002_client_email}}
  6. From Name: Your Company
  7. From Email: billing@yourcompany.com
  8. Subject: Invoice {{task_1003_invoice_number}} - Payment Received
  9. Body:
    Hi {{task_1002_client_name}},
    
    Thank you for your payment of ${{task_1001_data.amount / 100}}!
    
    Your invoice is attached for your records.
    
    Invoice Details:
    - Invoice Number: {{task_1003_invoice_number}}
    - Amount: ${{task_1003_total_amount}}
    - Payment Method: Stripe
    - Payment Date: {{current_date}}
    - Payment Reference: {{task_1001_data.payment_intent}}
    
    If you have any questions, please don't hesitate to contact us.
    
    Best regards,
    The [Your Company] Team
    
    ---
    This is an automated message. Please do not reply to this email.
    
  10. Attachments: {{task_1004_pdf_url}}
  11. Task Name: Email Invoice

Personalization Tips: - Include invoice number in subject for easy searching - Attach PDF using {{task_1004_pdf_url}} - Add payment reference for customer records - Include support contact information

Email Task with Attachment


Step 7: Log Payment in CRM

  1. Click Add Task after Email Invoice
  2. Select Workflow Note
  3. Configure:
  4. Parent Task: Email Invoice
  5. Client ID: {{task_1002_client_id}}
  6. Note Type: Payment
  7. Note:
    Stripe payment received: ${{task_1001_data.amount / 100}}
    Invoice: {{task_1003_invoice_number}}
    Payment Intent: {{task_1001_data.payment_intent}}
    Invoice emailed to customer.
    
  8. Task Name: Log Payment Activity

What This Does: - Creates timeline entry in customer record - Links payment to customer history - Provides audit trail - Visible in CRM contact view


Step 8: Test Workflow

Test with Stripe Test Mode

  1. In Stripe Dashboard, ensure Test Mode is enabled
  2. Use test card: 4242 4242 4242 4242
  3. Create test payment:
    Amount: $25.00
    Description: Test Product Purchase
    Email: test@example.com
    
  4. Submit payment
  5. Webhook triggers BaseCloud workflow
  6. Monitor each task execution

Verify Results

  1. ✅ Customer created/matched in CRM
  2. ✅ Invoice created with correct amount
  3. ✅ PDF generated and accessible
  4. ✅ Email sent with PDF attachment
  5. ✅ Payment logged in timeline

Workflow Execution


Step 9: Handle Multiple Products

For orders with multiple items, use Variable task before Create Invoice:

Add Variable Task:

// Parse Stripe metadata for line items
const items = JSON.parse('{{task_1001_data.metadata.line_items}}');

// Build line items array
const lineItems = items.map(item => ({
  description: item.name,
  quantity: item.quantity,
  unit_price: item.price,
  tax_rate: 0
}));

return { line_items: lineItems };

Then use {{task_1002_line_items}} in accounting task.


Expected Output

Successful Payment Processing:

  1. Stripe webhook received (< 1 second)
  2. Customer created/matched (< 1 second)
  3. Invoice created with payment status "Paid"
  4. PDF generated (< 3 seconds)
  5. Email sent with invoice attachment (< 5 seconds)
  6. Payment logged in CRM timeline

Total Processing Time: 5-10 seconds from payment to email delivery


Common Issues & Solutions

Issue: Webhook not triggering

Cause: Stripe webhook not configured correctly

Solution: 1. Verify webhook URL is correct in Stripe Dashboard 2. Check "Events to send" includes payment_intent.succeeded 3. Test with "Send test webhook" button 4. Check webhook signing secret matches 5. Verify workflow is enabled


Issue: Invoice amount showing as 1500 instead of $15.00

Cause: Stripe returns amounts in cents

Solution: - Divide by 100: {{task_1001_data.amount / 100}} - Or use Variable task with calculation:

const dollars = {{task_1001_data.amount}} / 100;
return { amount_dollars: dollars.toFixed(2) };


Issue: PDF attachment not in email

Cause: PDF task not completing before email sends

Solution: 1. Verify Email task parent is PDF task (not Create Invoice) 2. Check PDF generation completed successfully 3. Ensure {{task_1004_pdf_url}} is in Attachments field 4. Test PDF URL manually to confirm accessibility


Issue: Duplicate customers being created

Cause: Match to Client not finding existing customers

Solution: 1. Verify "Match by Email" selected 2. Ensure email variable correct: {{task_1001_data.receipt_email}} 3. Check customer emails in CRM are properly formatted 4. Test with known existing customer email


Issue: Invoice line items showing [object Object]

Cause: Line items not properly formatted as JSON

Solution: - Ensure line items is valid JSON array:

[
  {
    "description": "Product Name",
    "quantity": 1,
    "unit_price": 25.00,
    "tax_rate": 0
  }
]
- Don't use quotes around JSON structure - Use Variable task for complex item parsing


Workflow Enhancements

Add SMS Receipt

After email, add SMS task:

To: {{task_1001_data.billing_details.phone}}
Message: Hi {{task_1002_client_name}}! Your payment of 
${{task_1001_data.amount / 100}} was received. 
Invoice {{task_1003_invoice_number}} sent to email.

Add Slack Notification

Notify finance team of payments:

Webhook URL: https://hooks.slack.com/your-webhook
Body:
{
  "text": "💳 Payment received: ${{task_1001_data.amount / 100}} from {{task_1002_client_name}}",
  "attachments": [{
    "fields": [
      {"title": "Invoice", "value": "{{task_1003_invoice_number}}"},
      {"title": "Customer", "value": "{{task_1002_client_name}}"}
    ]
  }]
}

Add to Google Sheets

Log all payments to spreadsheet:

Spreadsheet: Payment Log
Sheet: 2024 Payments
Action: Append Row
Values: 
{{current_date}}, {{task_1002_client_name}}, 
{{task_1001_data.amount / 100}}, {{task_1003_invoice_number}}

Add Subscription Tracking

For recurring payments, add Edit Client:

Custom Field: subscription_status = active
Custom Field: last_payment_date = {{current_date}}
Custom Field: next_billing_date = {{current_date + 30 days}}




Next Steps

You've built a complete payment pipeline!

Try these enhancements: 1. Add refund handling webhook (charge.refunded) 2. Create different invoice templates for product types 3. Set up payment failure notifications 4. Add subscription renewal reminders with Delay task 5. Create monthly revenue reports with Google Sheets

Need help? Check Testing Workflows or Troubleshooting