Back to Articles
Tutorials6 minJanuary 15, 2025

How to Use GitHub Copilot with MoneyGraph for Payment Integrations

Step-by-step guide to using GitHub Copilot with MoneyGraph SDK. Learn how Copilot understands KYC compliance, FX quotes, and cross-border payouts automatically.

By MoneyGraph Team

GitHub Copilot is the world's most widely used AI coding assistant. With MoneyGraph SDK v2.2, Copilot now understands how to build compliant payment integrations without hallucinating endpoints or skipping critical compliance checks.

What Copilot Learns from MoneyGraph

When you install our SDK, Copilot reads .github/copilot-instructions.md and learns:

What Copilot LearnsWhy It Matters
Never use raw fetch()Use SDK methods instead of API calls
The Golden PathCorrect sequence: Initialize → KYC → Quote → Confirm → Payout
Dual-Mode Awarenesssk_test_* = sandbox, sk_live_* = production
Compliance FirstAlways check KYC before payouts
Environment VariablesNever hardcode API keys

1. Never Use Raw Fetch

Copilot will never generate code like this:

// ❌ Copilot won't do this anymore
const response = await fetch('https://api.moneygraph.ai/v1/payouts');

Instead, it generates:

// ✅ Copilot generates this
import { MoneyGraph } from '@moneygraph/sdk';
const mg = new MoneyGraph({ apiKey: process.env.MONEYGRAPH_API_KEY });

2. The Golden Path

Copilot understands the correct sequence for payment integrations:

  1. Initialize — Create client with API key
  2. Onboard — Create customer and complete KYC
  3. Quote — Get FX rate (valid 2 minutes)
  4. Confirm — Lock the rate
  5. Payout — Send money

3. Dual-Mode Awareness

Copilot knows that sk_test_* keys enable sandbox mode with mock data, while sk_live_* keys trigger real transactions.

Setup (30 Seconds)

npm install @moneygraph/sdk

That's it. Copilot automatically reads the instructions file.

Quick Start Prompt

Copy this into your editor to get started:

// TODO: Install MoneyGraph SDK and create a function that:
// 1. Accepts a customer ID and amount in USD
// 2. Checks if the customer's KYC is approved
// 3. Gets an FX quote to convert USD to Nigerian Naira (NGN)
// 4. Confirms the quote to lock the rate
// 5. Creates a payout to a Nigerian bank account
// Use the MoneyGraph SDK patterns

Watch Copilot generate compliant code with KYC checks, FX handling, and proper error management!

Try It: Prompt Examples

Open a TypeScript file and try these prompts:

Prompt: "Create a function to send $100 to Nigeria"

Copilot generates: ```typescript import { MoneyGraph } from '@moneygraph/sdk';

async function sendToNigeria(customerId: string) { const mg = new MoneyGraph({ apiKey: process.env.MONEYGRAPH_API_KEY });

// Check KYC status first const status = await mg.customers.kyc.canPayout(customerId); if (!status.allowed) { throw new Error('KYC not approved'); }

// Get quote and confirm const quote = await mg.fx.quote({ from: 'USD', to: 'NGN', amount: 100 }); await mg.fx.confirm(quote.id);

// Send payout return mg.payouts.create({ quote_id: quote.id, customer_id: customerId, recipient: { name: 'Recipient Name', bank_code: '058', account_number: '0123456789', }, }); } ```

Notice how Copilot:

  • Used the SDK (not raw fetch)
  • Checked KYC status first
  • Followed Quote → Confirm → Payout flow
  • Used environment variables for API key

Advanced: Copilot Chat

Use Copilot Chat for complex questions:

QuestionWhat Copilot Explains
"How do I handle a QUOTE_EXPIRED error?"Error handling patterns with retry logic
"What's the difference between mg.payouts.create and mg.payouts.swift.create?"Namespace differences and when to use each
"Show me how to issue a virtual card"Complete card issuance flow with KYC checks

Copilot references our SDK patterns from the instructions file for accurate, compliant code.

Troubleshooting

IssueSolution
Copilot ignores the instructionsEnsure `node_modules/@moneygraph/sdk` exists in your workspace. Copilot reads instructions from installed packages.
Copilot still uses raw fetch()Add a comment `// Use MoneyGraph SDK` above your code. This primes Copilot to use SDK patterns.
SDK methods not autocompletingRun `npm install @moneygraph/sdk` and restart your editor to reload TypeScript definitions.

Next Steps

Resources:

Ready to Get Started?

Install MoneyGraph SDK and start building AI-native payment applications today