Adds payment method support (Card, Wallet, Bank Transfer, UPI, BNPL, etc.) to an existing connector in the connector-service (UCS) Rust codebase. Modifies the Authorize flow transformers to handle new payment method data types. Use when a connector exists with Authorize flow but needs to support additional payment methods.
Adds payment method support to an existing connector's Authorize flow.
MANDATORY SUBAGENT DELEGATION: You are the orchestrator. You MUST delegate every step
to a subagent using the prompts in references/subagent-prompts.md. Do NOT implement
code, run tests, or review quality yourself. Spawn subagents and coordinate their outputs.
Inputs: connector name + payment methods to add (e.g., "add Apple Pay and Google Pay to AcmePay") Output: payment methods implemented, tested, quality-reviewed Prerequisite: connector must have Authorize flow implemented
| Category | PaymentMethodData Variant | Pattern File |
|---|---|---|
| Card | PaymentMethodData::Card(card) | references/payment-method-patterns/card.md |
| Wallet | PaymentMethodData::Wallet(wallet) |
references/payment-method-patterns/wallet.md| BankTransfer | PaymentMethodData::BankTransfer(bt) (Box) | references/payment-method-patterns/bank-transfer.md |
| BankDebit | PaymentMethodData::BankDebit(bd) | references/payment-method-patterns/bank-debit.md |
| BankRedirect | PaymentMethodData::BankRedirect(br) | references/payment-method-patterns/bank-redirect.md |
| UPI | PaymentMethodData::Upi(upi) | references/payment-method-patterns/upi.md |
| BNPL | PaymentMethodData::PayLater(pl) | references/payment-method-patterns/bnpl.md |
| Crypto | PaymentMethodData::Crypto(crypto) | references/payment-method-patterns/crypto.md |
| GiftCard | PaymentMethodData::GiftCard(gc) (Box) | references/payment-method-patterns/gift-card.md |
| MobilePayment | PaymentMethodData::MobilePayment(mp) | references/payment-method-patterns/mobile-payment.md |
| Reward | PaymentMethodData::Reward | references/payment-method-patterns/reward.md |
Full PM name → category mapping: references/category-mapping.md
_ to silently drop payment methods -- always return IntegrationError::NotImplementedBankTransferData and GiftCardData are Box-wrapped -- use .deref()missing_field_errget_unimplemented_payment_method_error_message("ConnectorName") for error messagesFull subagent prompts: references/subagent-prompts.md
Subagent prompt:
references/subagent-prompts.md→ Subagent 1
Inputs: connector_name, requested_payment_methods
What it does:
PaymentMethodData category (via references/category-mapping.md)Outputs: category mapping per PM, existing PMs, implementation plan
Gates:
generate-tech-spec skill first. Do NOT proceed without it.add-connector-flow skill to add Authorize first.CRITICAL: You MUST delegate implementation to a subagent. Do NOT implement code yourself. Read the subagent prompt from
references/subagent-prompts.md→ Subagent 2, fill in the variables ({ConnectorName}, {PaymentMethod}, {Category}, pattern file path), and spawn a subagent. For multiple PMs in the same category (e.g., Apple Pay + Google Pay = both Wallet), you may use one subagent for the whole category.
Per-category patterns:
references/payment-method-patterns/{category}.md
Each PM subagent:
match payment_method_data block in the Authorize TryFromNotImplementedcargo build --package connector-integrationCRITICAL: You MUST delegate testing to a subagent. Do NOT run grpcurl yourself. Subagent prompt:
references/subagent-prompts.md→ Subagent 3 Testing guide:references/grpc-testing-guide.md
Tests Authorize with each new payment method via grpcurl. The payment_method field
in the grpcurl request changes per PM type:
| PM | grpcurl payment_method field |
|---|---|
| Card | {"card": {"card_number": {"value":"4111..."}, ...}} |
| Apple Pay | {"wallet": {"apple_pay_third_party_sdk": {"payment_data":"..."}}} |
| Google Pay | {"wallet": {"google_pay": {"tokenization_data":{"token":"..."}}}} |
| UPI | {"upi": {"upi_collect": {"vpa_id":{"value":"test@upi"}}}} |
| ACH | {"bank_debit": {"ach": {"account_number":{"value":"..."}, ...}}} |
Also tests Refund/Capture with new PMs if those flows were modified.
CRITICAL: You MUST delegate quality review to a subagent. Do NOT review yourself. Subagent prompt:
references/subagent-prompts.md→ Subagent 4
Checks:
NotImplemented with connector namemissing_field_err.deref()'dcargo build passes cleanThe central pattern for all PM handling is a match on PaymentMethodData inside the
Authorize flow's TryFrom. This is the comprehensive pattern:
let payment_method_data = &item.router_data.request.payment_method_data;
match payment_method_data {
// ---- Card ----
PaymentMethodData::Card(card) => {
let card_number = card.card_number.clone();
let expiry_month = card.card_exp_month.clone();
let cvc = card.card_cvc.clone();
Ok(ConnectorPaymentsRequest { payment_type: "card", card_number, ... })
},
// ---- Wallet (nested match for sub-variants) ----
PaymentMethodData::Wallet(wallet_data) => match wallet_data {
WalletData::ApplePayThirdPartySdk(apple_pay) => {
let token = apple_pay.payment_data.clone()
.ok_or_else(missing_field_err("apple_pay.payment_data"))?;
Ok(ConnectorPaymentsRequest { payment_type: "applepay", token, ... })
},
WalletData::GooglePay(google_pay) => {
let token = google_pay.tokenization_data.token.clone();
Ok(ConnectorPaymentsRequest { payment_type: "googlepay", token, ... })
},
_ => Err(errors::IntegrationError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("ConnectorName", Default::default()),
).into()),
},
// ---- Bank Transfer (Box-wrapped, must .deref()) ----
PaymentMethodData::BankTransfer(bt) => match bt.deref() {
BankTransferData::SepaBankTransfer { .. } => { ... },
_ => Err(errors::IntegrationError::NotImplemented(..., Default::default()).into()),
},
// ---- Bank Debit ----
PaymentMethodData::BankDebit(bd) => match bd {
BankDebitData::SepaBankDebit { iban, .. } => { ... },
_ => Err(errors::IntegrationError::NotImplemented(..., Default::default()).into()),
},
// ---- UPI ----
PaymentMethodData::Upi(upi) => match upi {
UpiData::UpiCollect(c) => {
let vpa = c.vpa_id.clone().ok_or_else(missing_field_err("vpa_id"))?;
Ok(ConnectorPaymentsRequest { payment_type: "upi_collect", vpa, ... })
},
_ => Err(errors::IntegrationError::NotImplemented(..., Default::default()).into()),
},
// ---- BNPL ----
PaymentMethodData::PayLater(pl) => match pl {
PayLaterData::KlarnaRedirect { .. } => { ... },
_ => Err(errors::IntegrationError::NotImplemented(..., Default::default()).into()),
},
// ---- Catch-all: explicit rejection ----
_ => Err(errors::IntegrationError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("ConnectorName", Default::default()),
).into()),
}
Key rules:
PaymentMethodData variantsBankTransferData and GiftCardData are Box-wrapped → .deref()NotImplementedReward is a unit variant with no inner data| Path | Contents |
|---|---|
references/subagent-prompts.md | Full prompts for all 4 subagents |
references/category-mapping.md | PM name → PaymentMethodData variant mapping |
references/grpc-testing-guide.md | grpcurl templates, test validation, testing subagent prompt |
references/macro-reference.md | Connector macro system reference |
references/type-system.md | RouterDataV2, type system reference |
references/payment-method-patterns/card.md | Card payment patterns |
references/payment-method-patterns/wallet.md | Wallet (Apple Pay, Google Pay) patterns |
references/payment-method-patterns/bank-transfer.md | Bank transfer patterns |
references/payment-method-patterns/bank-debit.md | Bank debit (ACH, SEPA DD) patterns |
references/payment-method-patterns/bank-redirect.md | Bank redirect (iDEAL, Sofort) patterns |
references/payment-method-patterns/upi.md | UPI Collect/Intent patterns |
references/payment-method-patterns/bnpl.md | BNPL (Klarna, Afterpay) patterns |
references/payment-method-patterns/crypto.md | Cryptocurrency patterns |
references/payment-method-patterns/gift-card.md | Gift card patterns |
references/payment-method-patterns/mobile-payment.md | Mobile/carrier billing patterns |
references/payment-method-patterns/reward.md | Reward/loyalty points patterns |