PayPal Capabilities

Naftiko 0.5 capability definitions for PayPal - 100 capabilities showing integration workflows and service orchestrations.

Sort
Expand

Detects abandoned PayPal checkouts, creates follow-up tasks in HubSpot, and sends reminder emails to recover lost conversions.

naftiko: "0.5"
info:
  label: "Abandoned Checkout Follow-Up Pipeline"
  description: "Detects abandoned PayPal checkouts, creates follow-up tasks in HubSpot, and sends reminder emails to recover lost conversions."
  tags:
    - checkout
    - paypal
    - hubspot
    - sendgrid
    - conversion
capability:
  exposes:
    - type: mcp
      namespace: checkout-recovery
      port: 8080
      tools:
        - name: follow-up-abandoned-checkout
          description: "Send recovery communications for abandoned PayPal checkouts."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The abandoned PayPal order ID."
            - name: customer_email
              in: body
              type: string
              description: "The customer email."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: create-followup
              type: call
              call: "hubspot.create-task"
              with:
                subject: "Abandoned checkout follow-up: {{order_id}}"
                email: "{{customer_email}}"
                amount: "{{get-order.purchase_units[0].amount.value}}"
            - name: send-reminder
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{customer_email}}"
                template_id: "d-abandoned-checkout"
                dynamic_data:
                  order_amount: "{{get-order.purchase_units[0].amount.value}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/orders/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: hubspot
      baseUri: "https://api.hubapi.com"
      authentication:
        type: bearer
        token: "$secrets.hubspot_token"
      resources:
        - name: tasks
          path: "/crm/v3/objects/tasks"
          operations:
            - name: create-task
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Detects potential account takeovers by monitoring login anomalies, cross-referencing PayPal user info, and triggering security lockdowns with team notifications.

naftiko: "0.5"
info:
  label: "Account Takeover Detection Pipeline"
  description: "Detects potential account takeovers by monitoring login anomalies, cross-referencing PayPal user info, and triggering security lockdowns with team notifications."
  tags:
    - security
    - paypal
    - splunk
    - slack
    - fraud
capability:
  exposes:
    - type: mcp
      namespace: ato-detection
      port: 8080
      tools:
        - name: detect-account-takeover
          description: "Investigate potential account takeover and trigger security response."
          inputParameters:
            - name: user_id
              in: body
              type: string
              description: "The PayPal user ID."
            - name: login_ip
              in: body
              type: string
              description: "The suspicious login IP address."
          steps:
            - name: get-user-info
              type: call
              call: "paypal.get-user-info"
              with:
                user_id: "{{user_id}}"
            - name: check-login-history
              type: call
              call: "splunk.search"
              with:
                query: "index=auth user_id={{user_id}} | stats count by src_ip, country | where src_ip!='{{login_ip}}'"
            - name: alert-security
              type: call
              call: "slack.post-message"
              with:
                channel: "#security-incidents"
                text: "POTENTIAL ATO: User {{user_id}} ({{get-user-info.email}}) login from {{login_ip}}. Previous IPs: {{check-login-history.results}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/identity"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: userinfo
          path: "/oauth2/userinfo"
          operations:
            - name: get-user-info
              method: GET
    - type: http
      namespace: splunk
      baseUri: "https://splunk.paypal.com:8089/services"
      authentication:
        type: bearer
        token: "$secrets.splunk_token"
      resources:
        - name: search
          path: "/search/jobs"
          operations:
            - name: search
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Rotates PayPal API credentials, stores the new keys in HashiCorp Vault, updates the deployment config, and notifies the security team.

naftiko: "0.5"
info:
  label: "API Key Rotation and Vault Sync"
  description: "Rotates PayPal API credentials, stores the new keys in HashiCorp Vault, updates the deployment config, and notifies the security team."
  tags:
    - security
    - paypal
    - vault
    - slack
capability:
  exposes:
    - type: mcp
      namespace: key-rotation
      port: 8080
      tools:
        - name: rotate-api-keys
          description: "Rotate PayPal API credentials and sync to secret management."
          inputParameters:
            - name: app_id
              in: body
              type: string
              description: "The PayPal application ID."
          steps:
            - name: generate-new-credentials
              type: call
              call: "paypal.rotate-credentials"
              with:
                app_id: "{{app_id}}"
            - name: store-in-vault
              type: call
              call: "vault.write-secret"
              with:
                path: "secret/paypal/{{app_id}}"
                data:
                  client_id: "{{generate-new-credentials.client_id}}"
                  client_secret: "{{generate-new-credentials.client_secret}}"
            - name: notify-security
              type: call
              call: "slack.post-message"
              with:
                channel: "#security-ops"
                text: "PayPal API credentials rotated for app {{app_id}}. New credentials stored in Vault."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/developer"
      authentication:
        type: bearer
        token: "$secrets.paypal_admin_token"
      resources:
        - name: credentials
          path: "/applications/{{app_id}}/credentials/rotate"
          inputParameters:
            - name: app_id
              in: path
          operations:
            - name: rotate-credentials
              method: POST
    - type: http
      namespace: vault
      baseUri: "https://vault.paypal.com/v1"
      authentication:
        type: bearer
        token: "$secrets.vault_token"
      resources:
        - name: secrets
          path: "/secret/data"
          operations:
            - name: write-secret
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Retrieves a PayPal billing agreement, syncs the agreement details into Salesforce, and updates HubSpot contact properties for marketing alignment.

naftiko: "0.5"
info:
  label: "Billing Agreement Sync to CRM"
  description: "Retrieves a PayPal billing agreement, syncs the agreement details into Salesforce, and updates HubSpot contact properties for marketing alignment."
  tags:
    - billing
    - crm
    - paypal
    - salesforce
    - hubspot
capability:
  exposes:
    - type: mcp
      namespace: billing-crm-sync
      port: 8080
      tools:
        - name: sync-billing-agreement
          description: "Given a PayPal billing agreement ID, sync details to Salesforce and HubSpot."
          inputParameters:
            - name: agreement_id
              in: body
              type: string
              description: "The PayPal billing agreement ID."
            - name: hubspot_contact_id
              in: body
              type: string
              description: "The HubSpot contact ID."
            - name: sf_account_id
              in: body
              type: string
              description: "The Salesforce account ID."
          steps:
            - name: get-agreement
              type: call
              call: "paypal.get-agreement"
              with:
                agreement_id: "{{agreement_id}}"
            - name: update-salesforce
              type: call
              call: "salesforce.update-account"
              with:
                account_id: "{{sf_account_id}}"
                PayPal_Agreement_ID__c: "{{agreement_id}}"
                Agreement_Status__c: "{{get-agreement.state}}"
                Agreement_Description__c: "{{get-agreement.description}}"
            - name: update-hubspot
              type: call
              call: "hubspot.update-contact"
              with:
                contact_id: "{{hubspot_contact_id}}"
                properties:
                  paypal_agreement_id: "{{agreement_id}}"
                  paypal_agreement_status: "{{get-agreement.state}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments/billing-agreements"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: agreements
          path: "/{{agreement_id}}"
          inputParameters:
            - name: agreement_id
              in: path
          operations:
            - name: get-agreement
              method: GET
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: accounts
          path: "/Account/{{account_id}}"
          inputParameters:
            - name: account_id
              in: path
          operations:
            - name: update-account
              method: PATCH
    - type: http
      namespace: hubspot
      baseUri: "https://api.hubapi.com/crm/v3"
      authentication:
        type: bearer
        token: "$secrets.hubspot_token"
      resources:
        - name: contacts
          path: "/objects/contacts/{{contact_id}}"
          inputParameters:
            - name: contact_id
              in: path
          operations:
            - name: update-contact
              method: PATCH

# ---------------------------------------------------------------------------
# 36. Compliance Sanctions Screening (orchestrated)
# ---------------------------------------------------------------------------

Processes buyer protection claims by retrieving PayPal dispute details, checking shipping evidence, and issuing conditional refunds.

naftiko: "0.5"
info:
  label: "Buyer Protection Claim Processor"
  description: "Processes buyer protection claims by retrieving PayPal dispute details, checking shipping evidence, and issuing conditional refunds."
  tags:
    - disputes
    - paypal
    - jira
    - refunds
capability:
  exposes:
    - type: mcp
      namespace: buyer-protection
      port: 8080
      tools:
        - name: process-buyer-claim
          description: "Review and process a buyer protection claim with evidence check."
          inputParameters:
            - name: dispute_id
              in: body
              type: string
              description: "The PayPal dispute ID."
          steps:
            - name: get-dispute
              type: call
              call: "paypal.get-dispute"
              with:
                dispute_id: "{{dispute_id}}"
            - name: create-review-ticket
              type: call
              call: "jira.create-issue"
              with:
                project: "CLAIMS"
                summary: "Buyer protection claim {{dispute_id}} - ${{get-dispute.dispute_amount.value}}"
                description: "Reason: {{get-dispute.reason}}\nSeller: {{get-dispute.dispute_life_cycle_stage}}"
                issue_type: "Task"
            - name: notify-claims
              type: call
              call: "slack.post-message"
              with:
                channel: "#claims-team"
                text: "New buyer protection claim {{dispute_id}} for ${{get-dispute.dispute_amount.value}}. Jira: {{create-review-ticket.key}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/disputes/{{dispute_id}}"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: get-dispute
              method: GET
    - type: http
      namespace: jira
      baseUri: "https://paypal-internal.atlassian.net/rest/api/3"
      authentication:
        type: basic
        username: "$secrets.jira_user"
        password: "$secrets.jira_api_token"
      resources:
        - name: issues
          path: "/issue"
          operations:
            - name: create-issue
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

When a chargeback is received, retrieves payment details from PayPal, gathers evidence from Salesforce, and submits a dispute response with documentation.

naftiko: "0.5"
info:
  label: "Chargeback Dispute Response Pipeline"
  description: "When a chargeback is received, retrieves payment details from PayPal, gathers evidence from Salesforce, and submits a dispute response with documentation."
  tags:
    - disputes
    - paypal
    - salesforce
    - chargeback
capability:
  exposes:
    - type: mcp
      namespace: chargeback-response
      port: 8080
      tools:
        - name: respond-to-chargeback
          description: "Gather evidence and respond to a PayPal chargeback dispute."
          inputParameters:
            - name: dispute_id
              in: body
              type: string
              description: "The PayPal dispute ID."
            - name: transaction_id
              in: body
              type: string
              description: "The original transaction ID."
          steps:
            - name: get-dispute
              type: call
              call: "paypal.get-dispute"
              with:
                dispute_id: "{{dispute_id}}"
            - name: get-order-evidence
              type: call
              call: "salesforce.get-case"
              with:
                transaction_id: "{{transaction_id}}"
            - name: submit-evidence
              type: call
              call: "paypal.submit-evidence"
              with:
                dispute_id: "{{dispute_id}}"
                evidence_type: "PROOF_OF_FULFILLMENT"
                notes: "Order delivered per tracking. Salesforce case: {{get-order-evidence.CaseNumber}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/disputes/{{dispute_id}}"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: get-dispute
              method: GET
        - name: evidence
          path: "/disputes/{{dispute_id}}/provide-evidence"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: submit-evidence
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: cases
          path: "/sobjects/Case"
          inputParameters:
            - name: transaction_id
              in: query
          operations:
            - name: get-case
              method: GET

After a PayPal order is completed, retrieves the order, logs the conversion event in Google Analytics, and updates the Salesforce opportunity to Closed Won.

naftiko: "0.5"
info:
  label: "Checkout Conversion Tracker"
  description: "After a PayPal order is completed, retrieves the order, logs the conversion event in Google Analytics, and updates the Salesforce opportunity to Closed Won."
  tags:
    - checkout
    - analytics
    - paypal
    - google-analytics
    - salesforce
capability:
  exposes:
    - type: mcp
      namespace: conversion-tracking
      port: 8080
      tools:
        - name: track-checkout-conversion
          description: "Given a completed PayPal order ID and Salesforce opportunity ID, log the conversion and update the CRM."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: opportunity_id
              in: body
              type: string
              description: "The Salesforce opportunity ID."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: log-analytics
              type: call
              call: "ga.collect-event"
              with:
                measurement_id: "$secrets.ga_measurement_id"
                api_secret: "$secrets.ga_api_secret"
                events:
                  - name: "purchase"
                    params:
                      transaction_id: "{{order_id}}"
                      value: "{{get-order.purchase_units[0].amount.value}}"
                      currency: "{{get-order.purchase_units[0].amount.currency_code}}"
            - name: close-opportunity
              type: call
              call: "salesforce.update-opportunity"
              with:
                opportunity_id: "{{opportunity_id}}"
                StageName: "Closed Won"
                Amount: "{{get-order.purchase_units[0].amount.value}}"
                PayPal_Order_ID__c: "{{order_id}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: ga
      baseUri: "https://www.google-analytics.com"
      authentication:
        type: apiKey
        name: "api_secret"
        in: query
        value: "$secrets.ga_api_secret"
      resources:
        - name: events
          path: "/mp/collect?measurement_id={{measurement_id}}"
          inputParameters:
            - name: measurement_id
              in: query
          operations:
            - name: collect-event
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: opportunities
          path: "/Opportunity/{{opportunity_id}}"
          inputParameters:
            - name: opportunity_id
              in: path
          operations:
            - name: update-opportunity
              method: PATCH

# ---------------------------------------------------------------------------
# 22. Payout Batch Monitor (orchestrated)
# ---------------------------------------------------------------------------

After a PayPal order completes, retrieves the order, logs the variant assignment and conversion in Snowflake, and pushes the event to Mixpanel for experiment analysis.

naftiko: "0.5"
info:
  label: "Checkout Experience A/B Test Tracker"
  description: "After a PayPal order completes, retrieves the order, logs the variant assignment and conversion in Snowflake, and pushes the event to Mixpanel for experiment analysis."
  tags:
    - checkout
    - ab-testing
    - paypal
    - snowflake
    - mixpanel
capability:
  exposes:
    - type: mcp
      namespace: ab-test-tracking
      port: 8080
      tools:
        - name: track-ab-conversion
          description: "Given a PayPal order ID, experiment name, and variant, log the conversion data."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: experiment_name
              in: body
              type: string
              description: "The A/B test experiment name."
            - name: variant
              in: body
              type: string
              description: "The variant assignment (control, treatment)."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: log-snowflake
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.ab_test_conversions (order_id, experiment, variant, amount, currency, converted_at) VALUES ('{{order_id}}', '{{experiment_name}}', '{{variant}}', '{{get-order.purchase_units[0].amount.value}}', '{{get-order.purchase_units[0].amount.currency_code}}', CURRENT_TIMESTAMP())"
                warehouse: "ANALYTICS_WH"
                database: "PAYPAL_DATA"
            - name: track-mixpanel
              type: call
              call: "mixpanel.track-event"
              with:
                event: "checkout_conversion"
                properties:
                  order_id: "{{order_id}}"
                  experiment: "{{experiment_name}}"
                  variant: "{{variant}}"
                  amount: "{{get-order.purchase_units[0].amount.value}}"
                  currency: "{{get-order.purchase_units[0].amount.currency_code}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: mixpanel
      baseUri: "https://api.mixpanel.com"
      authentication:
        type: basic
        username: "$secrets.mixpanel_project_token"
        password: ""
      resources:
        - name: events
          path: "/import"
          operations:
            - name: track-event
              method: POST

# ---------------------------------------------------------------------------
# 50. End-of-Day Payment Summary to Executive Dashboard (orchestrated)
# ---------------------------------------------------------------------------

On a new PayPal payment, retrieves payer identity, screens against an OFAC sanctions API, and logs the result in Elasticsearch for audit.

naftiko: "0.5"
info:
  label: "Compliance Sanctions Screening"
  description: "On a new PayPal payment, retrieves payer identity, screens against an OFAC sanctions API, and logs the result in Elasticsearch for audit."
  tags:
    - compliance
    - sanctions
    - paypal
    - ofac
    - elasticsearch
capability:
  exposes:
    - type: mcp
      namespace: sanctions-screening
      port: 8080
      tools:
        - name: screen-payer-sanctions
          description: "Given a PayPal capture ID, retrieve payer details, screen against OFAC, and log the result."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: screen-ofac
              type: call
              call: "ofac.screen-entity"
              with:
                name: "{{get-payment.payer.name.given_name}} {{get-payment.payer.name.surname}}"
                country: "{{get-payment.payer.address.country_code}}"
            - name: log-screening
              type: call
              call: "elasticsearch.index-doc"
              with:
                index: "sanctions-screening"
                body:
                  capture_id: "{{capture_id}}"
                  payer_name: "{{get-payment.payer.name.given_name}} {{get-payment.payer.name.surname}}"
                  screening_result: "{{screen-ofac.match_status}}"
                  screened_at: "{{screen-ofac.screened_at}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: ofac
      baseUri: "https://api.ofac-api.com/v4"
      authentication:
        type: apiKey
        name: "apiKey"
        in: header
        value: "$secrets.ofac_api_key"
      resources:
        - name: screening
          path: "/screen"
          operations:
            - name: screen-entity
              method: POST
    - type: http
      namespace: elasticsearch
      baseUri: "https://paypal-es.es.us-west-2.aws.found.io"
      authentication:
        type: basic
        username: "$secrets.es_user"
        password: "$secrets.es_password"
      resources:
        - name: documents
          path: "/{{index}}/_doc"
          inputParameters:
            - name: index
              in: path
          operations:
            - name: index-doc
              method: POST

# ---------------------------------------------------------------------------
# 37. Shopping Cart Abandonment Recovery (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a PayPal international payment, checks the recipient country against a restricted list, and logs the compliance check in Elasticsearch and notifies legal via Slack.

naftiko: "0.5"
info:
  label: "Cross-Border Payment Compliance Logger"
  description: "Retrieves a PayPal international payment, checks the recipient country against a restricted list, and logs the compliance check in Elasticsearch and notifies legal via Slack."
  tags:
    - cross-border
    - compliance
    - paypal
    - elasticsearch
    - slack
    - legal
capability:
  exposes:
    - type: mcp
      namespace: cross-border-compliance
      port: 8080
      tools:
        - name: log-cross-border-payment
          description: "Given a PayPal capture ID, verify cross-border compliance, log in Elasticsearch, and notify legal."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: index-compliance
              type: call
              call: "elasticsearch.index-doc"
              with:
                index: "cross-border-payments"
                body:
                  capture_id: "{{capture_id}}"
                  amount: "{{get-payment.amount.value}}"
                  currency: "{{get-payment.amount.currency_code}}"
                  payer_country: "{{get-payment.payer.address.country_code}}"
                  status: "{{get-payment.status}}"
            - name: notify-legal
              type: call
              call: "slack.post-message"
              with:
                channel: "#legal-compliance"
                text: "Cross-border payment: {{capture_id}} for ${{get-payment.amount.value}} {{get-payment.amount.currency_code}}. Payer country: {{get-payment.payer.address.country_code}}. Indexed for compliance review."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: elasticsearch
      baseUri: "https://paypal-es.es.us-west-2.aws.found.io"
      authentication:
        type: basic
        username: "$secrets.es_user"
        password: "$secrets.es_password"
      resources:
        - name: documents
          path: "/{{index}}/_doc"
          inputParameters:
            - name: index
              in: path
          operations:
            - name: index-doc
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 47. Merchant Risk Score Aggregator (orchestrated)
# ---------------------------------------------------------------------------

Optimizes cross-border payment routing by checking exchange rates, selecting optimal corridors, and logging route decisions for compliance.

naftiko: "0.5"
info:
  label: "Cross-Border Payment Routing Optimizer"
  description: "Optimizes cross-border payment routing by checking exchange rates, selecting optimal corridors, and logging route decisions for compliance."
  tags:
    - cross-border
    - paypal
    - snowflake
    - optimization
capability:
  exposes:
    - type: mcp
      namespace: routing-optimization
      port: 8080
      tools:
        - name: optimize-payment-route
          description: "Select optimal cross-border payment corridor and log the decision."
          inputParameters:
            - name: source_country
              in: body
              type: string
              description: "Source country code."
            - name: destination_country
              in: body
              type: string
              description: "Destination country code."
            - name: amount
              in: body
              type: string
              description: "Payment amount."
          steps:
            - name: get-rates
              type: call
              call: "paypal.get-exchange-rates"
              with:
                from: "{{source_country}}"
                to: "{{destination_country}}"
            - name: log-routing
              type: call
              call: "snowflake.run-query"
              with:
                query: "INSERT INTO payments.routing_decisions (source, destination, amount, rate, corridor) VALUES ('{{source_country}}', '{{destination_country}}', '{{amount}}', '{{get-rates.rate}}', '{{get-rates.corridor}}')"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#cross-border-ops"
                text: "Route optimized: {{source_country}} -> {{destination_country}}, ${{amount}} at rate {{get-rates.rate}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: rates
          path: "/exchange-rates"
          operations:
            - name: get-exchange-rates
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

When a crypto purchase occurs, retrieves the transaction from PayPal, logs it in Elasticsearch for compliance, and posts to the compliance Slack channel.

naftiko: "0.5"
info:
  label: "Crypto Purchase Audit Trail"
  description: "When a crypto purchase occurs, retrieves the transaction from PayPal, logs it in Elasticsearch for compliance, and posts to the compliance Slack channel."
  tags:
    - crypto
    - audit
    - paypal
    - elasticsearch
    - slack
    - compliance
capability:
  exposes:
    - type: mcp
      namespace: crypto-audit
      port: 8080
      tools:
        - name: audit-crypto-purchase
          description: "Given a PayPal transaction ID for a crypto purchase, retrieve details, index in Elasticsearch, and notify compliance."
          inputParameters:
            - name: transaction_id
              in: body
              type: string
              description: "The PayPal transaction ID for the crypto purchase."
          steps:
            - name: get-transaction
              type: call
              call: "paypal.search-transaction"
              with:
                transaction_id: "{{transaction_id}}"
            - name: index-audit
              type: call
              call: "elasticsearch.index-doc"
              with:
                index: "crypto-transactions"
                body:
                  transaction_id: "{{transaction_id}}"
                  amount: "{{get-transaction.transaction_details[0].transaction_info.transaction_amount.value}}"
                  event_code: "{{get-transaction.transaction_details[0].transaction_info.transaction_event_code}}"
                  timestamp: "{{get-transaction.transaction_details[0].transaction_info.transaction_initiation_date}}"
            - name: notify-compliance
              type: call
              call: "slack.post-message"
              with:
                channel: "#compliance-crypto"
                text: "Crypto transaction logged: {{transaction_id}} for ${{get-transaction.transaction_details[0].transaction_info.transaction_amount.value}}. Indexed in Elasticsearch."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting/transactions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/?transaction_id={{transaction_id}}&fields=all"
          inputParameters:
            - name: transaction_id
              in: query
          operations:
            - name: search-transaction
              method: GET
    - type: http
      namespace: elasticsearch
      baseUri: "https://paypal-es.es.us-west-2.aws.found.io"
      authentication:
        type: basic
        username: "$secrets.es_user"
        password: "$secrets.es_password"
      resources:
        - name: documents
          path: "/{{index}}/_doc"
          inputParameters:
            - name: index
              in: path
          operations:
            - name: index-doc
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 32. Venmo Payment Notification Relay (orchestrated)
# ---------------------------------------------------------------------------

Verifies customer identity through PayPal user info, validates against third-party identity service, and updates KYC status in the compliance database.

naftiko: "0.5"
info:
  label: "Customer Identity Verification Pipeline"
  description: "Verifies customer identity through PayPal user info, validates against third-party identity service, and updates KYC status in the compliance database."
  tags:
    - identity
    - paypal
    - compliance
    - snowflake
capability:
  exposes:
    - type: mcp
      namespace: identity-verification
      port: 8080
      tools:
        - name: verify-customer-identity
          description: "Run full identity verification for a PayPal customer."
          inputParameters:
            - name: user_id
              in: body
              type: string
              description: "The PayPal user ID."
          steps:
            - name: get-user-info
              type: call
              call: "paypal.get-user-info"
              with:
                user_id: "{{user_id}}"
            - name: verify-identity
              type: call
              call: "identity-service.verify"
              with:
                name: "{{get-user-info.name}}"
                email: "{{get-user-info.email}}"
                address: "{{get-user-info.address}}"
            - name: update-kyc-status
              type: call
              call: "snowflake.run-query"
              with:
                query: "UPDATE compliance.kyc_status SET verified = '{{verify-identity.result}}', verified_at = CURRENT_TIMESTAMP WHERE user_id = '{{user_id}}'"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/identity"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: userinfo
          path: "/oauth2/userinfo"
          operations:
            - name: get-user-info
              method: GET
    - type: http
      namespace: identity-service
      baseUri: "https://identity-api.paypal.com/v1"
      authentication:
        type: bearer
        token: "$secrets.identity_service_token"
      resources:
        - name: verification
          path: "/verify"
          operations:
            - name: verify
              method: POST
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST

Queries PayPal transaction data for the day, aggregates totals via Snowflake, and posts the daily settlement summary to the finance Slack channel.

naftiko: "0.5"
info:
  label: "Daily Settlement Report"
  description: "Queries PayPal transaction data for the day, aggregates totals via Snowflake, and posts the daily settlement summary to the finance Slack channel."
  tags:
    - settlement
    - reporting
    - paypal
    - snowflake
    - slack
    - finance
capability:
  exposes:
    - type: mcp
      namespace: settlement-reporting
      port: 8080
      tools:
        - name: generate-settlement-report
          description: "Given a date range, query PayPal transactions, run Snowflake aggregation, and post settlement summary to Slack."
          inputParameters:
            - name: start_date
              in: body
              type: string
              description: "Start date in ISO 8601."
            - name: end_date
              in: body
              type: string
              description: "End date in ISO 8601."
          steps:
            - name: get-transactions
              type: call
              call: "paypal.list-transactions"
              with:
                start_date: "{{start_date}}"
                end_date: "{{end_date}}"
            - name: aggregate-totals
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "SELECT SUM(amount) as total_volume, COUNT(*) as txn_count, SUM(fee) as total_fees FROM paypal_data.transactions WHERE created_at BETWEEN '{{start_date}}' AND '{{end_date}}'"
                warehouse: "FINANCE_WH"
                database: "PAYPAL_DATA"
            - name: post-summary
              type: call
              call: "slack.post-message"
              with:
                channel: "#finance-daily"
                text: "Daily Settlement ({{start_date}} to {{end_date}}): Volume=${{aggregate-totals.data[0][0]}}, Transactions={{aggregate-totals.data[0][1]}}, Fees=${{aggregate-totals.data[0][2]}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting/transactions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/?start_date={{start_date}}&end_date={{end_date}}&fields=all"
          inputParameters:
            - name: start_date
              in: query
            - name: end_date
              in: query
          operations:
            - name: list-transactions
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 29. Subscription Renewal Dashboard Update (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a PayPal dispute, fetches order and shipment evidence from ShipStation, and submits the evidence to the dispute via the PayPal API.

naftiko: "0.5"
info:
  label: "Dispute Auto-Response with Evidence"
  description: "Retrieves a PayPal dispute, fetches order and shipment evidence from ShipStation, and submits the evidence to the dispute via the PayPal API."
  tags:
    - disputes
    - evidence
    - paypal
    - shipstation
    - automation
capability:
  exposes:
    - type: mcp
      namespace: dispute-response
      port: 8080
      tools:
        - name: auto-respond-dispute
          description: "Given a PayPal dispute ID and ShipStation order ID, gather evidence and submit a response."
          inputParameters:
            - name: dispute_id
              in: body
              type: string
              description: "The PayPal dispute ID."
            - name: shipstation_order_id
              in: body
              type: string
              description: "The ShipStation order ID for shipment evidence."
          steps:
            - name: get-dispute
              type: call
              call: "paypal.get-dispute"
              with:
                dispute_id: "{{dispute_id}}"
            - name: get-shipment
              type: call
              call: "shipstation.get-order"
              with:
                order_id: "{{shipstation_order_id}}"
            - name: submit-evidence
              type: call
              call: "paypal.provide-evidence"
              with:
                dispute_id: "{{dispute_id}}"
                evidence:
                  - evidence_type: "PROOF_OF_FULFILLMENT"
                    evidence_info:
                      tracking_info:
                        - carrier_name: "{{get-shipment.carrierCode}}"
                          tracking_number: "{{get-shipment.shipments[0].trackingNumber}}"
                message: "Order was shipped and delivered. Tracking: {{get-shipment.shipments[0].trackingNumber}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer/disputes"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/{{dispute_id}}"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: get-dispute
              method: GET
        - name: evidence
          path: "/{{dispute_id}}/provide-evidence"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: provide-evidence
              method: POST
    - type: http
      namespace: shipstation
      baseUri: "https://ssapi.shipstation.com"
      authentication:
        type: basic
        username: "$secrets.shipstation_key"
        password: "$secrets.shipstation_secret"
      resources:
        - name: orders
          path: "/orders/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET

# ---------------------------------------------------------------------------
# 40. Payment Failure Retry Orchestrator (orchestrated)
# ---------------------------------------------------------------------------

When a PayPal dispute is opened, retrieves dispute and transaction details, creates a ServiceNow case, and notifies the merchant via email through SendGrid.

naftiko: "0.5"
info:
  label: "Dispute Escalation Orchestrator"
  description: "When a PayPal dispute is opened, retrieves dispute and transaction details, creates a ServiceNow case, and notifies the merchant via email through SendGrid."
  tags:
    - disputes
    - paypal
    - servicenow
    - sendgrid
    - merchant-support
capability:
  exposes:
    - type: mcp
      namespace: dispute-escalation
      port: 8080
      tools:
        - name: escalate-dispute
          description: "Given a PayPal dispute ID and merchant email, fetch dispute details, open a ServiceNow case, and email the merchant with case info."
          inputParameters:
            - name: dispute_id
              in: body
              type: string
              description: "The PayPal dispute ID."
            - name: merchant_email
              in: body
              type: string
              description: "The merchant contact email."
          steps:
            - name: get-dispute
              type: call
              call: "paypal.get-dispute"
              with:
                dispute_id: "{{dispute_id}}"
            - name: open-case
              type: call
              call: "servicenow.create-case"
              with:
                short_description: "Dispute {{dispute_id}} - {{get-dispute.reason}} - ${{get-dispute.dispute_amount.value}}"
                category: "payment_dispute"
                priority: "2"
                description: "Dispute {{dispute_id}} opened for reason: {{get-dispute.reason}}. Amount: ${{get-dispute.dispute_amount.value}}. Status: {{get-dispute.status}}."
            - name: notify-merchant
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{merchant_email}}"
                subject: "PayPal Dispute {{dispute_id}} - Action Required"
                body: "A dispute has been filed for ${{get-dispute.dispute_amount.value}}. Reason: {{get-dispute.reason}}. Case reference: {{open-case.number}}. Please respond within 10 business days."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer/disputes"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/{{dispute_id}}"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: get-dispute
              method: GET
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: basic
        username: "$secrets.servicenow_user"
        password: "$secrets.servicenow_password"
      resources:
        - name: cases
          path: "/table/sn_customerservice_case"
          operations:
            - name: create-case
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 18. Merchant Onboarding Flow (orchestrated)
# ---------------------------------------------------------------------------

Aggregates the day's PayPal transaction volume via Snowflake, generates key metrics, updates a Google Sheets executive dashboard, and posts a daily summary to the leadership Slack channel.

naftiko: "0.5"
info:
  label: "End-of-Day Payment Summary to Executive Dashboard"
  description: "Aggregates the day's PayPal transaction volume via Snowflake, generates key metrics, updates a Google Sheets executive dashboard, and posts a daily summary to the leadership Slack channel."
  tags:
    - reporting
    - executive
    - paypal
    - snowflake
    - google-sheets
    - slack
capability:
  exposes:
    - type: mcp
      namespace: eod-summary
      port: 8080
      tools:
        - name: generate-eod-summary
          description: "Given a date, aggregate PayPal metrics from Snowflake, update the Google Sheets dashboard, and post to Slack."
          inputParameters:
            - name: report_date
              in: body
              type: string
              description: "The report date in YYYY-MM-DD format."
          steps:
            - name: aggregate-metrics
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "SELECT SUM(amount) as total_volume, COUNT(*) as txn_count, SUM(fee) as total_fees, COUNT(DISTINCT merchant_id) as active_merchants, SUM(CASE WHEN status='REFUNDED' THEN amount ELSE 0 END) as refund_volume FROM paypal_data.daily_transactions WHERE txn_date = '{{report_date}}'"
                warehouse: "EXEC_WH"
                database: "PAYPAL_DATA"
            - name: update-sheet
              type: call
              call: "gsheets.append-row"
              with:
                spreadsheet_id: "$secrets.exec_dashboard_sheet_id"
                range: "DailySummary!A:F"
                values:
                  - - "{{report_date}}"
                    - "{{aggregate-metrics.data[0][0]}}"
                    - "{{aggregate-metrics.data[0][1]}}"
                    - "{{aggregate-metrics.data[0][2]}}"
                    - "{{aggregate-metrics.data[0][3]}}"
                    - "{{aggregate-metrics.data[0][4]}}"
            - name: post-summary
              type: call
              call: "slack.post-message"
              with:
                channel: "#leadership-daily"
                text: "EOD Payment Summary ({{report_date}}): Volume=${{aggregate-metrics.data[0][0]}}, Txns={{aggregate-metrics.data[0][1]}}, Fees=${{aggregate-metrics.data[0][2]}}, Active Merchants={{aggregate-metrics.data[0][3]}}, Refunds=${{aggregate-metrics.data[0][4]}}"
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: gsheets
      baseUri: "https://sheets.googleapis.com/v4/spreadsheets"
      authentication:
        type: bearer
        token: "$secrets.google_sheets_token"
      resources:
        - name: values
          path: "/{{spreadsheet_id}}/values/{{range}}:append?valueInputOption=RAW"
          inputParameters:
            - name: spreadsheet_id
              in: path
            - name: range
              in: path
          operations:
            - name: append-row
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

When a high-risk transaction is flagged, retrieves the payment from PayPal, opens a Jira ticket for the fraud team, and sends an alert to the risk Slack channel.

naftiko: "0.5"
info:
  label: "Fraud Alert Triage Pipeline"
  description: "When a high-risk transaction is flagged, retrieves the payment from PayPal, opens a Jira ticket for the fraud team, and sends an alert to the risk Slack channel."
  tags:
    - fraud
    - risk
    - paypal
    - jira
    - slack
capability:
  exposes:
    - type: mcp
      namespace: fraud-triage
      port: 8080
      tools:
        - name: triage-fraud-alert
          description: "Given a flagged PayPal capture ID, retrieve payment details, create a Jira ticket for investigation, and alert the risk team on Slack."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID that triggered the fraud alert."
            - name: risk_score
              in: body
              type: number
              description: "The computed risk score for this transaction."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: create-ticket
              type: call
              call: "jira.create-issue"
              with:
                project: "FRAUD"
                summary: "High-risk transaction {{capture_id}} - ${{get-payment.amount.value}} {{get-payment.amount.currency_code}}"
                description: "Payer: {{get-payment.payer.email_address}}\nRisk Score: {{risk_score}}\nStatus: {{get-payment.status}}"
                issue_type: "Task"
                priority: "High"
            - name: alert-slack
              type: call
              call: "slack.post-message"
              with:
                channel: "#fraud-alerts"
                text: "FRAUD ALERT: Capture {{capture_id}} for ${{get-payment.amount.value}} flagged with risk score {{risk_score}}. Jira: {{create-ticket.key}} - {{create-ticket.self}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: jira
      baseUri: "https://paypal-internal.atlassian.net/rest/api/3"
      authentication:
        type: basic
        username: "$secrets.jira_user"
        password: "$secrets.jira_api_token"
      resources:
        - name: issues
          path: "/issue"
          operations:
            - name: create-issue
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 17. Dispute Escalation Orchestrator (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a PayPal payment authorization by authorization ID, returning status, amount, and expiration time for auth-capture flows.

naftiko: "0.5"
info:
  label: "Get Authorization Details"
  description: "Retrieves a PayPal payment authorization by authorization ID, returning status, amount, and expiration time for auth-capture flows."
  tags:
    - authorizations
    - payments
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: auth-payments
      port: 8080
      tools:
        - name: get-authorization
          description: "Look up a PayPal authorization by ID. Returns status, amount, and expiration time."
          inputParameters:
            - name: authorization_id
              in: body
              type: string
              description: "The PayPal authorization ID."
          call: "paypal.get-auth"
          with:
            authorization_id: "{{authorization_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: amount
              type: string
              mapping: "$.amount.value"
            - name: expiration
              type: string
              mapping: "$.expiration_time"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments/authorizations"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: authorizations
          path: "/{{authorization_id}}"
          inputParameters:
            - name: authorization_id
              in: path
          operations:
            - name: get-auth
              method: GET

# ---------------------------------------------------------------------------
# 15. Get Vault Payment Token (simple)
# ---------------------------------------------------------------------------

Retrieves details for a PayPal billing agreement including status, payer, and plan info.

naftiko: "0.5"
info:
  label: "Get Billing Agreement Details"
  description: "Retrieves details for a PayPal billing agreement including status, payer, and plan info."
  tags:
    - billing
    - paypal
    - agreements
capability:
  exposes:
    - type: mcp
      namespace: billing
      port: 8080
      tools:
        - name: get-billing-agreement
          description: "Look up a PayPal billing agreement by agreement ID."
          inputParameters:
            - name: agreement_id
              in: body
              type: string
              description: "The PayPal billing agreement ID."
          call: "paypal.get-agreement"
          with:
            agreement_id: "{{agreement_id}}"
          outputParameters:
            - name: state
              type: string
              mapping: "$.state"
            - name: payer_email
              type: string
              mapping: "$.payer.payer_info.email"
            - name: plan_name
              type: string
              mapping: "$.plan.name"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: billing-agreements
          path: "/billing-agreements/{{agreement_id}}"
          inputParameters:
            - name: agreement_id
              in: path
          operations:
            - name: get-agreement
              method: GET

Retrieves a PayPal billing plan by plan ID, including pricing tiers, billing cycles, and payment preferences for subscription management.

naftiko: "0.5"
info:
  label: "Get Billing Plan Details"
  description: "Retrieves a PayPal billing plan by plan ID, including pricing tiers, billing cycles, and payment preferences for subscription management."
  tags:
    - billing
    - subscriptions
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: billing-plans
      port: 8080
      tools:
        - name: get-billing-plan
          description: "Look up a PayPal billing plan by plan ID. Returns name, status, billing cycles, and payment preferences."
          inputParameters:
            - name: plan_id
              in: body
              type: string
              description: "The PayPal billing plan ID."
          call: "paypal.get-plan"
          with:
            plan_id: "{{plan_id}}"
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: status
              type: string
              mapping: "$.status"
            - name: billing_cycles
              type: string
              mapping: "$.billing_cycles"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing/plans"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: plans
          path: "/{{plan_id}}"
          inputParameters:
            - name: plan_id
              in: path
          operations:
            - name: get-plan
              method: GET

# ---------------------------------------------------------------------------
# 10. Get Transaction Event Details (simple)
# ---------------------------------------------------------------------------

Retrieves details for a product in the PayPal product catalog by product ID.

naftiko: "0.5"
info:
  label: "Get Catalog Product Details"
  description: "Retrieves details for a product in the PayPal product catalog by product ID."
  tags:
    - catalog
    - paypal
    - products
capability:
  exposes:
    - type: mcp
      namespace: catalog
      port: 8080
      tools:
        - name: get-catalog-product
          description: "Look up a product in the PayPal catalog by ID."
          inputParameters:
            - name: product_id
              in: body
              type: string
              description: "The PayPal catalog product ID."
          call: "paypal.get-product"
          with:
            product_id: "{{product_id}}"
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: description
              type: string
              mapping: "$.description"
            - name: type
              type: string
              mapping: "$.type"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/catalogs"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: products
          path: "/products/{{product_id}}"
          inputParameters:
            - name: product_id
              in: path
          operations:
            - name: get-product
              method: GET

Retrieves the available and pending balance for a PayPal merchant account.

naftiko: "0.5"
info:
  label: "Get Customer Balance"
  description: "Retrieves the available and pending balance for a PayPal merchant account."
  tags:
    - payments
    - paypal
    - balance
capability:
  exposes:
    - type: mcp
      namespace: payments
      port: 8080
      tools:
        - name: get-customer-balance
          description: "Look up available and pending balance for a PayPal account."
          inputParameters:
            - name: account_id
              in: body
              type: string
              description: "The PayPal account ID."
          call: "paypal.get-balance"
          with:
            account_id: "{{account_id}}"
          outputParameters:
            - name: available_balance
              type: string
              mapping: "$.balances[0].available.value"
            - name: currency
              type: string
              mapping: "$.balances[0].available.currency_code"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: balances
          path: "/balances"
          inputParameters:
            - name: account_id
              in: query
          operations:
            - name: get-balance
              method: GET

Lists all open disputes for a given PayPal merchant account with pagination.

naftiko: "0.5"
info:
  label: "Get Customer Disputes List"
  description: "Lists all open disputes for a given PayPal merchant account with pagination."
  tags:
    - disputes
    - paypal
    - customer-service
capability:
  exposes:
    - type: mcp
      namespace: disputes
      port: 8080
      tools:
        - name: list-disputes
          description: "Retrieve paginated list of disputes for a merchant."
          inputParameters:
            - name: start_time
              in: body
              type: string
              description: "ISO 8601 start date filter."
          call: "paypal.list-disputes"
          with:
            start_time: "{{start_time}}"
          outputParameters:
            - name: disputes
              type: array
              mapping: "$.items"
            - name: total_items
              type: integer
              mapping: "$.total_items"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/disputes"
          inputParameters:
            - name: start_time
              in: query
          operations:
            - name: list-disputes
              method: GET

Retrieves the current PayPal exchange rate between two currency codes.

naftiko: "0.5"
info:
  label: "Get Exchange Rate Lookup"
  description: "Retrieves the current PayPal exchange rate between two currency codes."
  tags:
    - payments
    - paypal
    - currency
capability:
  exposes:
    - type: mcp
      namespace: payments
      port: 8080
      tools:
        - name: get-exchange-rate
          description: "Look up PayPal exchange rate between two currencies."
          inputParameters:
            - name: from_currency
              in: body
              type: string
              description: "Source currency code."
            - name: to_currency
              in: body
              type: string
              description: "Target currency code."
          call: "paypal.get-exchange-rate"
          with:
            from_currency: "{{from_currency}}"
            to_currency: "{{to_currency}}"
          outputParameters:
            - name: rate
              type: string
              mapping: "$.exchange_rate"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: exchange-rates
          path: "/exchange-rates"
          inputParameters:
            - name: from_currency
              in: query
            - name: to_currency
              in: query
          operations:
            - name: get-exchange-rate
              method: GET

Retrieves a PayPal invoice by invoice ID, returning status, total amount, due date, and recipient information.

naftiko: "0.5"
info:
  label: "Get Invoice Details"
  description: "Retrieves a PayPal invoice by invoice ID, returning status, total amount, due date, and recipient information."
  tags:
    - invoicing
    - paypal
    - billing
capability:
  exposes:
    - type: mcp
      namespace: invoicing
      port: 8080
      tools:
        - name: get-invoice
          description: "Look up a PayPal invoice by invoice ID. Returns status, total due, due date, and recipient name."
          inputParameters:
            - name: invoice_id
              in: body
              type: string
              description: "The PayPal invoice ID."
          call: "paypal.get-invoice"
          with:
            invoice_id: "{{invoice_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: amount_due
              type: string
              mapping: "$.amount.value"
            - name: due_date
              type: string
              mapping: "$.detail.payment_term.due_date"
            - name: recipient_name
              type: string
              mapping: "$.primary_recipients[0].billing_info.name.full_name"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/invoicing/invoices"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: invoices
          path: "/{{invoice_id}}"
          inputParameters:
            - name: invoice_id
              in: path
          operations:
            - name: get-invoice
              method: GET

# ---------------------------------------------------------------------------
# 8. Get Product Catalog Entry (simple)
# ---------------------------------------------------------------------------

Retrieves an invoice template by template ID from the PayPal invoicing API.

naftiko: "0.5"
info:
  label: "Get Invoicing Template"
  description: "Retrieves an invoice template by template ID from the PayPal invoicing API."
  tags:
    - invoicing
    - paypal
    - templates
capability:
  exposes:
    - type: mcp
      namespace: invoicing
      port: 8080
      tools:
        - name: get-invoice-template
          description: "Look up a PayPal invoice template by template ID."
          inputParameters:
            - name: template_id
              in: body
              type: string
              description: "The PayPal invoice template ID."
          call: "paypal.get-template"
          with:
            template_id: "{{template_id}}"
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: default
              type: boolean
              mapping: "$.default"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/invoicing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: templates
          path: "/templates/{{template_id}}"
          inputParameters:
            - name: template_id
              in: path
          operations:
            - name: get-template
              method: GET

Retrieves configuration details for a specific PayPal webhook by webhook ID.

naftiko: "0.5"
info:
  label: "Get Notification Webhook Details"
  description: "Retrieves configuration details for a specific PayPal webhook by webhook ID."
  tags:
    - webhooks
    - paypal
    - notifications
capability:
  exposes:
    - type: mcp
      namespace: webhooks
      port: 8080
      tools:
        - name: get-webhook-details
          description: "Look up a webhook configuration by webhook ID."
          inputParameters:
            - name: webhook_id
              in: body
              type: string
              description: "The PayPal webhook ID."
          call: "paypal.get-webhook"
          with:
            webhook_id: "{{webhook_id}}"
          outputParameters:
            - name: url
              type: string
              mapping: "$.url"
            - name: event_types
              type: array
              mapping: "$.event_types"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/notifications"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: webhooks
          path: "/webhooks/{{webhook_id}}"
          inputParameters:
            - name: webhook_id
              in: path
          operations:
            - name: get-webhook
              method: GET

Checks the onboarding status of a merchant partner in the PayPal Commerce Platform.

naftiko: "0.5"
info:
  label: "Get Onboarding Partner Status"
  description: "Checks the onboarding status of a merchant partner in the PayPal Commerce Platform."
  tags:
    - onboarding
    - paypal
    - partners
capability:
  exposes:
    - type: mcp
      namespace: onboarding
      port: 8080
      tools:
        - name: get-partner-onboarding-status
          description: "Check onboarding status for a merchant partner."
          inputParameters:
            - name: partner_merchant_id
              in: body
              type: string
              description: "The partner merchant ID."
          call: "paypal.get-partner-status"
          with:
            partner_merchant_id: "{{partner_merchant_id}}"
          outputParameters:
            - name: merchant_id
              type: string
              mapping: "$.merchant_id"
            - name: payments_receivable
              type: boolean
              mapping: "$.payments_receivable"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: partner-referrals
          path: "/partners/{{partner_merchant_id}}/merchant-integrations"
          inputParameters:
            - name: partner_merchant_id
              in: path
          operations:
            - name: get-partner-status
              method: GET

Retrieves PayPal order details by order ID, including intent, purchase units, and current order status.

naftiko: "0.5"
info:
  label: "Get Order Details"
  description: "Retrieves PayPal order details by order ID, including intent, purchase units, and current order status."
  tags:
    - orders
    - checkout
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: checkout
      port: 8080
      tools:
        - name: get-order
          description: "Look up a PayPal order by order ID. Returns status, intent, total amount, and payee email."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
          call: "paypal.get-order"
          with:
            order_id: "{{order_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: intent
              type: string
              mapping: "$.intent"
            - name: total
              type: string
              mapping: "$.purchase_units[0].amount.value"
            - name: payee_email
              type: string
              mapping: "$.purchase_units[0].payee.email_address"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET

# ---------------------------------------------------------------------------
# 6. Retrieve Webhook Event (simple)
# ---------------------------------------------------------------------------

Checks the status of a PayPal partner referral by referral ID, used for marketplace and platform onboarding flows.

naftiko: "0.5"
info:
  label: "Get Partner Referral Status"
  description: "Checks the status of a PayPal partner referral by referral ID, used for marketplace and platform onboarding flows."
  tags:
    - partner
    - onboarding
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: partner-referrals
      port: 8080
      tools:
        - name: get-referral
          description: "Look up a PayPal partner referral by referral ID. Returns referral status and partner link."
          inputParameters:
            - name: partner_referral_id
              in: body
              type: string
              description: "The PayPal partner referral ID."
          call: "paypal.get-referral"
          with:
            partner_referral_id: "{{partner_referral_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: action_url
              type: string
              mapping: "$.links[1].href"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/customer/partner-referrals"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: referrals
          path: "/{{partner_referral_id}}"
          inputParameters:
            - name: partner_referral_id
              in: path
          operations:
            - name: get-referral
              method: GET

# ---------------------------------------------------------------------------
# 14. Get Authorization Details (simple)
# ---------------------------------------------------------------------------

Retrieves full details for a PayPal payment by capture ID, including amount, status, currency, and payer information.

naftiko: "0.5"
info:
  label: "Get Payment Details"
  description: "Retrieves full details for a PayPal payment by capture ID, including amount, status, currency, and payer information."
  tags:
    - payments
    - paypal
    - capture
capability:
  exposes:
    - type: mcp
      namespace: payments
      port: 8080
      tools:
        - name: get-payment
          description: "Look up a PayPal captured payment by its capture ID. Returns status, amount, currency, and payer email."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID for the payment."
          call: "paypal.get-capture"
          with:
            capture_id: "{{capture_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: amount
              type: string
              mapping: "$.amount.value"
            - name: currency
              type: string
              mapping: "$.amount.currency_code"
            - name: payer_email
              type: string
              mapping: "$.payer.email_address"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET

# ---------------------------------------------------------------------------
# 2. Lookup Dispute Details (simple)
# ---------------------------------------------------------------------------

Lists all vaulted payment method tokens for a customer in PayPal.

naftiko: "0.5"
info:
  label: "Get Payment Method Tokens List"
  description: "Lists all vaulted payment method tokens for a customer in PayPal."
  tags:
    - vault
    - paypal
    - tokens
capability:
  exposes:
    - type: mcp
      namespace: vault
      port: 8080
      tools:
        - name: list-payment-tokens
          description: "Retrieve all vaulted payment tokens for a customer."
          inputParameters:
            - name: customer_id
              in: body
              type: string
              description: "The PayPal customer ID."
          call: "paypal.list-payment-tokens"
          with:
            customer_id: "{{customer_id}}"
          outputParameters:
            - name: payment_tokens
              type: array
              mapping: "$.payment_tokens"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v3/vault"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payment-tokens
          path: "/payment-tokens"
          inputParameters:
            - name: customer_id
              in: query
          operations:
            - name: list-payment-tokens
              method: GET

Checks the status of an individual payout item within a PayPal batch payout, returning transaction status, amount, and receiver.

naftiko: "0.5"
info:
  label: "Get Payout Item Status"
  description: "Checks the status of an individual payout item within a PayPal batch payout, returning transaction status, amount, and receiver."
  tags:
    - payouts
    - paypal
    - disbursements
capability:
  exposes:
    - type: mcp
      namespace: payouts
      port: 8080
      tools:
        - name: get-payout-item
          description: "Look up a PayPal payout item by item ID. Returns transaction status, amount, and receiver email."
          inputParameters:
            - name: payout_item_id
              in: body
              type: string
              description: "The PayPal payout item ID."
          call: "paypal.get-payout-item"
          with:
            payout_item_id: "{{payout_item_id}}"
          outputParameters:
            - name: transaction_status
              type: string
              mapping: "$.transaction_status"
            - name: amount
              type: string
              mapping: "$.payout_item.amount.value"
            - name: receiver
              type: string
              mapping: "$.payout_item.receiver"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments/payouts-item"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payout-items
          path: "/{{payout_item_id}}"
          inputParameters:
            - name: payout_item_id
              in: path
          operations:
            - name: get-payout-item
              method: GET

# ---------------------------------------------------------------------------
# 5. Get Order Details (simple)
# ---------------------------------------------------------------------------

Retrieves the status and item details for a PayPal payouts batch by batch ID.

naftiko: "0.5"
info:
  label: "Get Payouts Batch Status"
  description: "Retrieves the status and item details for a PayPal payouts batch by batch ID."
  tags:
    - payouts
    - paypal
    - batch
capability:
  exposes:
    - type: mcp
      namespace: payouts
      port: 8080
      tools:
        - name: get-payout-batch
          description: "Look up a payouts batch by its batch ID."
          inputParameters:
            - name: batch_id
              in: body
              type: string
              description: "The PayPal payouts batch ID."
          call: "paypal.get-payout-batch"
          with:
            batch_id: "{{batch_id}}"
          outputParameters:
            - name: batch_status
              type: string
              mapping: "$.batch_header.batch_status"
            - name: amount
              type: string
              mapping: "$.batch_header.amount.value"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payouts
          path: "/payouts/{{batch_id}}"
          inputParameters:
            - name: batch_id
              in: path
          operations:
            - name: get-payout-batch
              method: GET

Retrieves a product from the PayPal catalog by product ID, used for validating subscription plan product linkage.

naftiko: "0.5"
info:
  label: "Get Product Catalog Entry"
  description: "Retrieves a product from the PayPal catalog by product ID, used for validating subscription plan product linkage."
  tags:
    - catalog
    - paypal
    - products
capability:
  exposes:
    - type: mcp
      namespace: catalog
      port: 8080
      tools:
        - name: get-product
          description: "Look up a PayPal catalog product by ID. Returns name, type, category, and description."
          inputParameters:
            - name: product_id
              in: body
              type: string
              description: "The PayPal product ID."
          call: "paypal.get-product"
          with:
            product_id: "{{product_id}}"
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: product_type
              type: string
              mapping: "$.type"
            - name: category
              type: string
              mapping: "$.category"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/catalogs/products"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: products
          path: "/{{product_id}}"
          inputParameters:
            - name: product_id
              in: path
          operations:
            - name: get-product
              method: GET

# ---------------------------------------------------------------------------
# 9. Get Billing Plan Details (simple)
# ---------------------------------------------------------------------------

Retrieves details for a specific referenced payouts item by item ID.

naftiko: "0.5"
info:
  label: "Get Referenced Payouts Item"
  description: "Retrieves details for a specific referenced payouts item by item ID."
  tags:
    - payouts
    - paypal
    - referenced-payouts
capability:
  exposes:
    - type: mcp
      namespace: payouts
      port: 8080
      tools:
        - name: get-referenced-payouts-item
          description: "Look up a referenced payouts item by its item ID."
          inputParameters:
            - name: payouts_item_id
              in: body
              type: string
              description: "The PayPal referenced payouts item ID."
          call: "paypal.get-referenced-item"
          with:
            payouts_item_id: "{{payouts_item_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.processing_state.status"
            - name: amount
              type: string
              mapping: "$.amount.value"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: referenced-payouts-items
          path: "/referenced-payouts-items/{{payouts_item_id}}"
          inputParameters:
            - name: payouts_item_id
              in: path
          operations:
            - name: get-referenced-item
              method: GET

Retrieves the configuration and pricing tiers for a PayPal subscription plan.

naftiko: "0.5"
info:
  label: "Get Subscription Plan Details"
  description: "Retrieves the configuration and pricing tiers for a PayPal subscription plan."
  tags:
    - subscriptions
    - paypal
    - billing
capability:
  exposes:
    - type: mcp
      namespace: subscriptions
      port: 8080
      tools:
        - name: get-subscription-plan
          description: "Look up a PayPal subscription plan by plan ID."
          inputParameters:
            - name: plan_id
              in: body
              type: string
              description: "The PayPal billing plan ID."
          call: "paypal.get-plan"
          with:
            plan_id: "{{plan_id}}"
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: status
              type: string
              mapping: "$.status"
            - name: billing_cycles
              type: array
              mapping: "$.billing_cycles"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: plans
          path: "/plans/{{plan_id}}"
          inputParameters:
            - name: plan_id
              in: path
          operations:
            - name: get-plan
              method: GET

Retrieves the current status of a PayPal billing subscription including plan details, next billing date, and subscriber info.

naftiko: "0.5"
info:
  label: "Get Subscription Status"
  description: "Retrieves the current status of a PayPal billing subscription including plan details, next billing date, and subscriber info."
  tags:
    - subscriptions
    - billing
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: billing
      port: 8080
      tools:
        - name: get-subscription
          description: "Look up a PayPal subscription by ID. Returns status, plan ID, next billing date, and subscriber name."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
          call: "paypal.get-subscription"
          with:
            subscription_id: "{{subscription_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: plan_id
              type: string
              mapping: "$.plan_id"
            - name: next_billing
              type: string
              mapping: "$.billing_info.next_billing_time"
            - name: subscriber_name
              type: string
              mapping: "$.subscriber.name.given_name"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing/subscriptions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET

# ---------------------------------------------------------------------------
# 4. Get Payout Item Status (simple)
# ---------------------------------------------------------------------------

Retrieves shipment tracking details associated with a PayPal transaction.

naftiko: "0.5"
info:
  label: "Get Tracking Information"
  description: "Retrieves shipment tracking details associated with a PayPal transaction."
  tags:
    - shipping
    - paypal
    - tracking
capability:
  exposes:
    - type: mcp
      namespace: shipping
      port: 8080
      tools:
        - name: get-tracking
          description: "Look up tracking information for a PayPal transaction."
          inputParameters:
            - name: transaction_id
              in: body
              type: string
              description: "The PayPal transaction ID."
          call: "paypal.get-tracking"
          with:
            transaction_id: "{{transaction_id}}"
          outputParameters:
            - name: tracking_number
              type: string
              mapping: "$.tracking_number"
            - name: carrier
              type: string
              mapping: "$.carrier"
            - name: status
              type: string
              mapping: "$.status"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/shipping"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: trackers
          path: "/trackers/{{transaction_id}}"
          inputParameters:
            - name: transaction_id
              in: path
          operations:
            - name: get-tracking
              method: GET

Retrieves transaction details from PayPal Sync API by transaction ID, returning event code, transaction amount, and fee.

naftiko: "0.5"
info:
  label: "Get Transaction Event Details"
  description: "Retrieves transaction details from PayPal Sync API by transaction ID, returning event code, transaction amount, and fee."
  tags:
    - transactions
    - reporting
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: transaction-reporting
      port: 8080
      tools:
        - name: get-transaction
          description: "Look up a PayPal transaction by ID via the Sync API. Returns event code, gross amount, fee, and transaction status."
          inputParameters:
            - name: transaction_id
              in: body
              type: string
              description: "The PayPal transaction ID."
          call: "paypal.search-transaction"
          with:
            transaction_id: "{{transaction_id}}"
          outputParameters:
            - name: event_code
              type: string
              mapping: "$.transaction_details[0].transaction_info.transaction_event_code"
            - name: gross_amount
              type: string
              mapping: "$.transaction_details[0].transaction_info.transaction_amount.value"
            - name: fee
              type: string
              mapping: "$.transaction_details[0].transaction_info.fee_amount.value"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting/transactions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/?transaction_id={{transaction_id}}&fields=all"
          inputParameters:
            - name: transaction_id
              in: query
          operations:
            - name: search-transaction
              method: GET

# ---------------------------------------------------------------------------
# 11. Refund Lookup (simple)
# ---------------------------------------------------------------------------

Searches PayPal transaction history with date range and filter criteria.

naftiko: "0.5"
info:
  label: "Get Transaction Search Results"
  description: "Searches PayPal transaction history with date range and filter criteria."
  tags:
    - transactions
    - paypal
    - reporting
capability:
  exposes:
    - type: mcp
      namespace: reporting
      port: 8080
      tools:
        - name: search-transactions
          description: "Search PayPal transactions within a date range."
          inputParameters:
            - name: start_date
              in: body
              type: string
              description: "ISO 8601 start date."
            - name: end_date
              in: body
              type: string
              description: "ISO 8601 end date."
          call: "paypal.search-transactions"
          with:
            start_date: "{{start_date}}"
            end_date: "{{end_date}}"
          outputParameters:
            - name: transactions
              type: array
              mapping: "$.transaction_details"
            - name: total_items
              type: integer
              mapping: "$.total_items"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/transactions"
          inputParameters:
            - name: start_date
              in: query
            - name: end_date
              in: query
          operations:
            - name: search-transactions
              method: GET

Retrieves a vaulted payment token from PayPal Vault, returning token metadata, payment source type, and customer ID.

naftiko: "0.5"
info:
  label: "Get Vault Payment Token"
  description: "Retrieves a vaulted payment token from PayPal Vault, returning token metadata, payment source type, and customer ID."
  tags:
    - vault
    - payment-tokens
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: vault
      port: 8080
      tools:
        - name: get-payment-token
          description: "Look up a vaulted payment token by ID. Returns payment source type, customer ID, and creation time."
          inputParameters:
            - name: token_id
              in: body
              type: string
              description: "The PayPal vault payment token ID."
          call: "paypal.get-token"
          with:
            token_id: "{{token_id}}"
          outputParameters:
            - name: payment_source
              type: string
              mapping: "$.payment_source"
            - name: customer_id
              type: string
              mapping: "$.customer.id"
            - name: create_time
              type: string
              mapping: "$.create_time"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v3/vault/payment-tokens"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payment-tokens
          path: "/{{token_id}}"
          inputParameters:
            - name: token_id
              in: path
          operations:
            - name: get-token
              method: GET

# ---------------------------------------------------------------------------
# 16. Fraud Alert Triage Pipeline (orchestrated)
# ---------------------------------------------------------------------------

Lists all available webhook event types for PayPal API integrations.

naftiko: "0.5"
info:
  label: "Get Webhook Event Types"
  description: "Lists all available webhook event types for PayPal API integrations."
  tags:
    - webhooks
    - paypal
    - integration
capability:
  exposes:
    - type: mcp
      namespace: webhooks
      port: 8080
      tools:
        - name: list-webhook-event-types
          description: "Retrieve all supported PayPal webhook event types."
          inputParameters: []
          call: "paypal.list-event-types"
          with: {}
          outputParameters:
            - name: event_types
              type: array
              mapping: "$.event_types"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/notifications"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: event-types
          path: "/webhooks-event-types"
          operations:
            - name: list-event-types
              method: GET

For transactions exceeding a threshold, retrieves payment details from PayPal, runs sanctions screening, and logs the result to ServiceNow for audit.

naftiko: "0.5"
info:
  label: "High Value Transaction Compliance Check"
  description: "For transactions exceeding a threshold, retrieves payment details from PayPal, runs sanctions screening, and logs the result to ServiceNow for audit."
  tags:
    - compliance
    - paypal
    - servicenow
    - sanctions
capability:
  exposes:
    - type: mcp
      namespace: compliance
      port: 8080
      tools:
        - name: check-high-value-transaction
          description: "Screen a high-value PayPal transaction for compliance and log to audit trail."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: screen-sanctions
              type: call
              call: "compliance-api.screen-entity"
              with:
                name: "{{get-payment.payer.name.given_name}} {{get-payment.payer.name.surname}}"
                email: "{{get-payment.payer.email_address}}"
            - name: log-audit
              type: call
              call: "servicenow.create-record"
              with:
                table: "u_compliance_audit"
                data:
                  transaction_id: "{{capture_id}}"
                  amount: "{{get-payment.amount.value}}"
                  screening_result: "{{screen-sanctions.status}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: compliance-api
      baseUri: "https://compliance.paypal.com/api/v1"
      authentication:
        type: bearer
        token: "$secrets.compliance_api_token"
      resources:
        - name: screening
          path: "/screen"
          operations:
            - name: screen-entity
              method: POST
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: bearer
        token: "$secrets.servicenow_token"
      resources:
        - name: records
          path: "/table/u_compliance_audit"
          operations:
            - name: create-record
              method: POST

Generates batch invoices from PayPal billing data, creates PDF invoices, and delivers them via SendGrid email to merchants.

naftiko: "0.5"
info:
  label: "Invoice Batch Generation and Delivery"
  description: "Generates batch invoices from PayPal billing data, creates PDF invoices, and delivers them via SendGrid email to merchants."
  tags:
    - invoicing
    - paypal
    - sendgrid
    - snowflake
capability:
  exposes:
    - type: mcp
      namespace: invoice-batch
      port: 8080
      tools:
        - name: generate-batch-invoices
          description: "Generate and deliver batch invoices to merchants."
          inputParameters:
            - name: billing_period
              in: body
              type: string
              description: "The billing period in YYYY-MM format."
          steps:
            - name: get-billing-data
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT merchant_id, total_fees FROM billing.monthly_summary WHERE period = '{{billing_period}}'"
            - name: create-invoice
              type: call
              call: "paypal.create-invoice"
              with:
                billing_period: "{{billing_period}}"
                items: "{{get-billing-data.results}}"
            - name: send-invoice
              type: call
              call: "sendgrid.send-email"
              with:
                template_id: "d-monthly-invoice"
                subject: "Your PayPal invoice for {{billing_period}}"
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/invoicing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: invoices
          path: "/invoices"
          operations:
            - name: create-invoice
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Creates a PayPal invoice for a customer, logs the invoice in Salesforce, and sends a personalized notification via SendGrid.

naftiko: "0.5"
info:
  label: "Invoice Generation and Delivery"
  description: "Creates a PayPal invoice for a customer, logs the invoice in Salesforce, and sends a personalized notification via SendGrid."
  tags:
    - invoicing
    - paypal
    - salesforce
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: invoice-delivery
      port: 8080
      tools:
        - name: generate-and-deliver-invoice
          description: "Given invoice details, create a PayPal invoice, log it in Salesforce, and email the customer."
          inputParameters:
            - name: customer_email
              in: body
              type: string
              description: "The customer email."
            - name: customer_name
              in: body
              type: string
              description: "The customer full name."
            - name: amount
              in: body
              type: string
              description: "The invoice amount."
            - name: description
              in: body
              type: string
              description: "The invoice line item description."
          steps:
            - name: create-invoice
              type: call
              call: "paypal.create-invoice"
              with:
                detail:
                  currency_code: "USD"
                primary_recipients:
                  - billing_info:
                      email_address: "{{customer_email}}"
                      name:
                        full_name: "{{customer_name}}"
                items:
                  - name: "{{description}}"
                    unit_amount:
                      currency_code: "USD"
                      value: "{{amount}}"
                    quantity: "1"
            - name: log-salesforce
              type: call
              call: "salesforce.create-record"
              with:
                object: "Invoice__c"
                PayPal_Invoice_ID__c: "{{create-invoice.id}}"
                Customer_Email__c: "{{customer_email}}"
                Amount__c: "{{amount}}"
            - name: email-customer
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{customer_email}}"
                subject: "Invoice from PayPal - {{description}}"
                body: "Hello {{customer_name}}, an invoice for ${{amount}} has been created. View and pay here: https://www.paypal.com/invoice/p/#/{{create-invoice.id}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/invoicing/invoices"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: invoices
          path: "/"
          operations:
            - name: create-invoice
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: records
          path: "/{{object}}"
          inputParameters:
            - name: object
              in: path
          operations:
            - name: create-record
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 24. Webhook Event Replay and Audit (orchestrated)
# ---------------------------------------------------------------------------

Retrieves an overdue PayPal invoice, sends a reminder via the PayPal API, and logs the collection attempt in Salesforce and Slack.

naftiko: "0.5"
info:
  label: "Invoice Overdue Collection Workflow"
  description: "Retrieves an overdue PayPal invoice, sends a reminder via the PayPal API, and logs the collection attempt in Salesforce and Slack."
  tags:
    - invoicing
    - collections
    - paypal
    - salesforce
    - slack
capability:
  exposes:
    - type: mcp
      namespace: invoice-collections
      port: 8080
      tools:
        - name: collect-overdue-invoice
          description: "Given a PayPal invoice ID and Salesforce case ID, send a reminder and log the attempt."
          inputParameters:
            - name: invoice_id
              in: body
              type: string
              description: "The PayPal invoice ID."
            - name: sf_case_id
              in: body
              type: string
              description: "The Salesforce case ID for tracking."
          steps:
            - name: get-invoice
              type: call
              call: "paypal.get-invoice"
              with:
                invoice_id: "{{invoice_id}}"
            - name: send-reminder
              type: call
              call: "paypal.send-invoice-reminder"
              with:
                invoice_id: "{{invoice_id}}"
                subject: "Payment Reminder"
                note: "This is a reminder that your invoice for ${{get-invoice.amount.value}} is overdue. Please make payment at your earliest convenience."
            - name: update-salesforce
              type: call
              call: "salesforce.update-case"
              with:
                case_id: "{{sf_case_id}}"
                Status: "In Progress"
                Description: "Reminder sent for invoice {{invoice_id}} (${{get-invoice.amount.value}}). Due date: {{get-invoice.detail.payment_term.due_date}}."
            - name: notify-collections
              type: call
              call: "slack.post-message"
              with:
                channel: "#collections"
                text: "Invoice reminder sent: {{invoice_id}} for ${{get-invoice.amount.value}}. Recipient: {{get-invoice.primary_recipients[0].billing_info.email_address}}. SF Case: {{sf_case_id}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/invoicing/invoices"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: invoices
          path: "/{{invoice_id}}"
          inputParameters:
            - name: invoice_id
              in: path
          operations:
            - name: get-invoice
              method: GET
        - name: reminders
          path: "/{{invoice_id}}/remind"
          inputParameters:
            - name: invoice_id
              in: path
          operations:
            - name: send-invoice-reminder
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: cases
          path: "/Case/{{case_id}}"
          inputParameters:
            - name: case_id
              in: path
          operations:
            - name: update-case
              method: PATCH
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 45. Real-Time Payment Monitoring Dashboard (orchestrated)
# ---------------------------------------------------------------------------

Fetches dispute details from PayPal by dispute ID, returning reason, status, amount, and transaction ID for customer-service review.

naftiko: "0.5"
info:
  label: "Lookup Dispute Details"
  description: "Fetches dispute details from PayPal by dispute ID, returning reason, status, amount, and transaction ID for customer-service review."
  tags:
    - disputes
    - paypal
    - customer-service
capability:
  exposes:
    - type: mcp
      namespace: disputes
      port: 8080
      tools:
        - name: get-dispute
          description: "Look up a PayPal dispute by dispute ID. Returns reason, status, disputed amount, and linked transaction ID."
          inputParameters:
            - name: dispute_id
              in: body
              type: string
              description: "The PayPal dispute ID."
          call: "paypal.get-dispute"
          with:
            dispute_id: "{{dispute_id}}"
          outputParameters:
            - name: reason
              type: string
              mapping: "$.reason"
            - name: status
              type: string
              mapping: "$.status"
            - name: amount
              type: string
              mapping: "$.dispute_amount.value"
            - name: transaction_id
              type: string
              mapping: "$.disputed_transactions[0].buyer_transaction_id"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer/disputes"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/{{dispute_id}}"
          inputParameters:
            - name: dispute_id
              in: path
          operations:
            - name: get-dispute
              method: GET

# ---------------------------------------------------------------------------
# 3. Get Subscription Status (simple)
# ---------------------------------------------------------------------------

Creates a PayPal payout to a marketplace seller, logs it in Snowflake, and sends a confirmation email to the seller via SendGrid.

naftiko: "0.5"
info:
  label: "Marketplace Seller Payout and Notification"
  description: "Creates a PayPal payout to a marketplace seller, logs it in Snowflake, and sends a confirmation email to the seller via SendGrid."
  tags:
    - payouts
    - marketplace
    - paypal
    - snowflake
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: seller-payouts
      port: 8080
      tools:
        - name: payout-seller
          description: "Given a seller email and payout amount, create a PayPal payout, log it, and confirm via email."
          inputParameters:
            - name: seller_email
              in: body
              type: string
              description: "The seller PayPal email."
            - name: amount
              in: body
              type: string
              description: "The payout amount."
            - name: currency
              in: body
              type: string
              description: "The payout currency code."
            - name: note
              in: body
              type: string
              description: "A note for the seller."
          steps:
            - name: create-payout
              type: call
              call: "paypal.create-payout"
              with:
                sender_batch_header:
                  sender_batch_id: "batch_{{seller_email}}_{{amount}}"
                  email_subject: "You have a payout!"
                items:
                  - recipient_type: "EMAIL"
                    amount:
                      value: "{{amount}}"
                      currency: "{{currency}}"
                    receiver: "{{seller_email}}"
                    note: "{{note}}"
            - name: log-payout
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.seller_payouts (batch_id, seller_email, amount, currency, created_at) VALUES ('{{create-payout.batch_header.payout_batch_id}}', '{{seller_email}}', '{{amount}}', '{{currency}}', CURRENT_TIMESTAMP())"
                warehouse: "FINANCE_WH"
                database: "PAYPAL_DATA"
            - name: confirm-email
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{seller_email}}"
                subject: "Payout Sent - ${{amount}} {{currency}}"
                body: "A payout of ${{amount}} {{currency}} has been sent to your PayPal account. Batch ID: {{create-payout.batch_header.payout_batch_id}}. Note: {{note}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments/payouts"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payouts
          path: "/"
          operations:
            - name: create-payout
              method: POST
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 39. Dispute Auto-Response with Evidence (orchestrated)
# ---------------------------------------------------------------------------

Processes marketplace orders by splitting payments between sellers via PayPal, recording commissions in the ERP, and notifying sellers via email.

naftiko: "0.5"
info:
  label: "Marketplace Split Payment Processor"
  description: "Processes marketplace orders by splitting payments between sellers via PayPal, recording commissions in the ERP, and notifying sellers via email."
  tags:
    - marketplace
    - paypal
    - sap
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: split-payments
      port: 8080
      tools:
        - name: process-split-payment
          description: "Split a marketplace payment between sellers and record commissions."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: seller_email
              in: body
              type: string
              description: "The seller email address."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: record-commission
              type: call
              call: "sap.create-journal-entry"
              with:
                reference: "{{order_id}}"
                amount: "{{get-order.purchase_units[0].payment_instruction.platform_fees[0].amount.value}}"
                type: "COMMISSION"
            - name: notify-seller
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{seller_email}}"
                template_id: "d-seller-payment-notification"
                dynamic_data:
                  order_id: "{{order_id}}"
                  net_amount: "{{get-order.purchase_units[0].amount.value}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/orders/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: sap
      baseUri: "https://paypal-erp.s4hana.ondemand.com/api/v1"
      authentication:
        type: basic
        username: "$secrets.sap_user"
        password: "$secrets.sap_password"
      resources:
        - name: journal-entries
          path: "/journal-entries"
          operations:
            - name: create-journal-entry
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Checks merchant account health by reviewing dispute ratio from PayPal, updating risk scores in Datadog, and alerting the risk team when thresholds are exceeded.

naftiko: "0.5"
info:
  label: "Merchant Account Health Monitor"
  description: "Checks merchant account health by reviewing dispute ratio from PayPal, updating risk scores in Datadog, and alerting the risk team when thresholds are exceeded."
  tags:
    - risk
    - paypal
    - datadog
    - slack
    - monitoring
capability:
  exposes:
    - type: mcp
      namespace: merchant-health
      port: 8080
      tools:
        - name: monitor-merchant-health
          description: "Check merchant dispute ratios and alert on risk threshold breaches."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant account ID."
          steps:
            - name: get-disputes
              type: call
              call: "paypal.list-disputes"
              with:
                merchant_id: "{{merchant_id}}"
            - name: push-metric
              type: call
              call: "datadog.submit-metric"
              with:
                metric: "paypal.merchant.dispute_ratio"
                value: "{{get-disputes.dispute_ratio}}"
                tags:
                  - "merchant:{{merchant_id}}"
            - name: alert-risk
              type: call
              call: "slack.post-message"
              with:
                channel: "#merchant-risk"
                text: "Merchant {{merchant_id}} dispute ratio: {{get-disputes.dispute_ratio}}%. Total disputes: {{get-disputes.total_items}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: disputes
          path: "/disputes"
          inputParameters:
            - name: merchant_id
              in: query
          operations:
            - name: list-disputes
              method: GET
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v2"
      authentication:
        type: apiKey
        key: "$secrets.datadog_api_key"
      resources:
        - name: metrics
          path: "/series"
          operations:
            - name: submit-metric
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Analyzes merchant API usage patterns from logs, identifies anomalies, and generates usage reports in Tableau for the platform team.

naftiko: "0.5"
info:
  label: "Merchant API Usage Analytics Pipeline"
  description: "Analyzes merchant API usage patterns from logs, identifies anomalies, and generates usage reports in Tableau for the platform team."
  tags:
    - analytics
    - paypal
    - splunk
    - tableau
    - api-usage
capability:
  exposes:
    - type: mcp
      namespace: api-analytics
      port: 8080
      tools:
        - name: analyze-api-usage
          description: "Generate API usage analytics for a merchant."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
            - name: date_range
              in: body
              type: string
              description: "The date range for analysis."
          steps:
            - name: query-logs
              type: call
              call: "splunk.search"
              with:
                query: "index=paypal_api merchant_id={{merchant_id}} earliest={{date_range}} | stats count by endpoint, status_code"
            - name: refresh-dashboard
              type: call
              call: "tableau.refresh-workbook"
              with:
                workbook_id: "api-usage-analytics"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#platform-analytics"
                text: "API usage report for merchant {{merchant_id}} refreshed. Total calls: {{query-logs.total_count}}"
  consumes:
    - type: http
      namespace: splunk
      baseUri: "https://splunk.paypal.com:8089/services"
      authentication:
        type: bearer
        token: "$secrets.splunk_token"
      resources:
        - name: search
          path: "/search/jobs"
          operations:
            - name: search
              method: POST
    - type: http
      namespace: tableau
      baseUri: "https://tableau.paypal.com/api/3.19"
      authentication:
        type: bearer
        token: "$secrets.tableau_token"
      resources:
        - name: workbooks
          path: "/sites/default/workbooks/{{workbook_id}}/refresh"
          operations:
            - name: refresh-workbook
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Analyzes merchant transaction fees from PayPal data, computes fee breakdowns in Snowflake, and publishes a Power BI dashboard refresh.

naftiko: "0.5"
info:
  label: "Merchant Fee Analysis Report"
  description: "Analyzes merchant transaction fees from PayPal data, computes fee breakdowns in Snowflake, and publishes a Power BI dashboard refresh."
  tags:
    - fees
    - paypal
    - snowflake
    - power-bi
    - analytics
capability:
  exposes:
    - type: mcp
      namespace: fee-analysis
      port: 8080
      tools:
        - name: analyze-merchant-fees
          description: "Generate fee analysis report for a merchant."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
            - name: period
              in: body
              type: string
              description: "The reporting period in YYYY-MM format."
          steps:
            - name: get-fee-data
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT fee_type, SUM(fee_amount) as total FROM paypal.transaction_fees WHERE merchant_id = '{{merchant_id}}' AND period = '{{period}}' GROUP BY fee_type"
            - name: refresh-dashboard
              type: call
              call: "powerbi.refresh-dataset"
              with:
                dataset_id: "merchant-fee-analysis"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#merchant-analytics"
                text: "Fee analysis for merchant {{merchant_id}} period {{period}} completed. Dashboard refreshed."
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: powerbi
      baseUri: "https://api.powerbi.com/v1.0/myorg"
      authentication:
        type: bearer
        token: "$secrets.powerbi_token"
      resources:
        - name: datasets
          path: "/datasets/{{dataset_id}}/refreshes"
          operations:
            - name: refresh-dataset
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Retrieves PayPal merchant account details, runs identity verification through a compliance API, and updates the merchant status in Salesforce.

naftiko: "0.5"
info:
  label: "Merchant KYC Verification Pipeline"
  description: "Retrieves PayPal merchant account details, runs identity verification through a compliance API, and updates the merchant status in Salesforce."
  tags:
    - kyc
    - compliance
    - paypal
    - salesforce
    - onboarding
capability:
  exposes:
    - type: mcp
      namespace: merchant-kyc
      port: 8080
      tools:
        - name: verify-merchant-kyc
          description: "Given a PayPal merchant ID and Salesforce account ID, verify merchant identity and update CRM status."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant account ID."
            - name: sf_account_id
              in: body
              type: string
              description: "The Salesforce account ID."
          steps:
            - name: get-merchant
              type: call
              call: "paypal.get-merchant-status"
              with:
                merchant_id: "{{merchant_id}}"
            - name: check-identity
              type: call
              call: "compliance.verify-identity"
              with:
                legal_name: "{{get-merchant.legal_name}}"
                country: "{{get-merchant.country}}"
                merchant_id: "{{merchant_id}}"
            - name: update-salesforce
              type: call
              call: "salesforce.update-account"
              with:
                account_id: "{{sf_account_id}}"
                KYC_Status__c: "{{check-identity.verification_status}}"
                KYC_Verified_Date__c: "{{check-identity.verified_at}}"
                PayPal_Merchant_ID__c: "{{merchant_id}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer/partners"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: merchant-integrations
          path: "/{{partner_id}}/merchant-integrations/{{merchant_id}}"
          inputParameters:
            - name: merchant_id
              in: path
          operations:
            - name: get-merchant-status
              method: GET
    - type: http
      namespace: compliance
      baseUri: "https://compliance-api.paypal.com/v1"
      authentication:
        type: bearer
        token: "$secrets.compliance_api_token"
      resources:
        - name: identity
          path: "/identity/verify"
          operations:
            - name: verify-identity
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: accounts
          path: "/Account/{{account_id}}"
          inputParameters:
            - name: account_id
              in: path
          operations:
            - name: update-account
              method: PATCH

# ---------------------------------------------------------------------------
# 26. Transaction Velocity Alert (orchestrated)
# ---------------------------------------------------------------------------

Orchestrates new merchant onboarding by creating a PayPal partner referral, provisioning a Salesforce account, and sending a welcome email via SendGrid.

naftiko: "0.5"
info:
  label: "Merchant Onboarding Flow"
  description: "Orchestrates new merchant onboarding by creating a PayPal partner referral, provisioning a Salesforce account, and sending a welcome email via SendGrid."
  tags:
    - onboarding
    - partner
    - paypal
    - salesforce
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: merchant-onboarding
      port: 8080
      tools:
        - name: onboard-merchant
          description: "Given merchant details, create a PayPal partner referral, set up a Salesforce account, and send a welcome email."
          inputParameters:
            - name: merchant_name
              in: body
              type: string
              description: "The merchant business name."
            - name: merchant_email
              in: body
              type: string
              description: "The merchant contact email."
            - name: business_type
              in: body
              type: string
              description: "The type of business (e.g., INDIVIDUAL, CORPORATION)."
          steps:
            - name: create-referral
              type: call
              call: "paypal.create-referral"
              with:
                partner_config_override:
                  return_url: "https://paypal.com/merchant/onboarding/complete"
                operations:
                  - operation: "API_INTEGRATION"
                legal_consents:
                  - type: "SHARE_DATA_CONSENT"
                    granted: true
            - name: create-sf-account
              type: call
              call: "salesforce.create-account"
              with:
                Name: "{{merchant_name}}"
                Type: "{{business_type}}"
                Industry: "E-commerce"
                Email__c: "{{merchant_email}}"
                PayPal_Referral_ID__c: "{{create-referral.partner_referral_id}}"
            - name: send-welcome
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{merchant_email}}"
                subject: "Welcome to PayPal - Complete Your Setup"
                body: "Hello {{merchant_name}}, complete your PayPal onboarding here: {{create-referral.links[1].href}}. Your Salesforce account ID: {{create-sf-account.id}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/customer/partner-referrals"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: referrals
          path: "/"
          operations:
            - name: create-referral
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: accounts
          path: "/Account"
          operations:
            - name: create-account
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 19. Subscription Churn Prevention (orchestrated)
# ---------------------------------------------------------------------------

Verifies merchant PCI compliance status from PayPal, checks attestation documents in SharePoint, and creates remediation tasks in ServiceNow if non-compliant.

naftiko: "0.5"
info:
  label: "Merchant PCI Compliance Verifier"
  description: "Verifies merchant PCI compliance status from PayPal, checks attestation documents in SharePoint, and creates remediation tasks in ServiceNow if non-compliant."
  tags:
    - compliance
    - paypal
    - sharepoint
    - servicenow
capability:
  exposes:
    - type: mcp
      namespace: pci-compliance
      port: 8080
      tools:
        - name: verify-pci-compliance
          description: "Verify PCI compliance for a merchant and create remediation if needed."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
          steps:
            - name: get-merchant-status
              type: call
              call: "paypal.get-merchant-compliance"
              with:
                merchant_id: "{{merchant_id}}"
            - name: check-attestation
              type: call
              call: "sharepoint.search-document"
              with:
                query: "PCI attestation {{merchant_id}}"
                site: "compliance-docs"
            - name: create-remediation
              type: call
              call: "servicenow.create-incident"
              with:
                short_description: "PCI non-compliance: merchant {{merchant_id}}"
                category: "Compliance"
                priority: "2"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: compliance
          path: "/partners/{{merchant_id}}/compliance"
          inputParameters:
            - name: merchant_id
              in: path
          operations:
            - name: get-merchant-compliance
              method: GET
    - type: http
      namespace: sharepoint
      baseUri: "https://graph.microsoft.com/v1.0"
      authentication:
        type: bearer
        token: "$secrets.sharepoint_token"
      resources:
        - name: search
          path: "/search/query"
          operations:
            - name: search-document
              method: POST
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: bearer
        token: "$secrets.servicenow_token"
      resources:
        - name: incidents
          path: "/table/incident"
          operations:
            - name: create-incident
              method: POST

Forecasts merchant revenue by analyzing PayPal transaction trends in Snowflake, running ML predictions, and publishing forecasts to Power BI.

naftiko: "0.5"
info:
  label: "Merchant Revenue Forecast Pipeline"
  description: "Forecasts merchant revenue by analyzing PayPal transaction trends in Snowflake, running ML predictions, and publishing forecasts to Power BI."
  tags:
    - analytics
    - paypal
    - snowflake
    - power-bi
    - forecasting
capability:
  exposes:
    - type: mcp
      namespace: revenue-forecast
      port: 8080
      tools:
        - name: forecast-merchant-revenue
          description: "Generate revenue forecasts based on PayPal transaction history."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
            - name: forecast_months
              in: body
              type: integer
              description: "Number of months to forecast."
          steps:
            - name: get-historical-data
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT month, SUM(amount) as revenue FROM paypal.transactions WHERE merchant_id = '{{merchant_id}}' GROUP BY month ORDER BY month"
            - name: refresh-forecast-dashboard
              type: call
              call: "powerbi.refresh-dataset"
              with:
                dataset_id: "merchant-revenue-forecasts"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#merchant-analytics"
                text: "Revenue forecast for merchant {{merchant_id}} updated for next {{forecast_months}} months."
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: powerbi
      baseUri: "https://api.powerbi.com/v1.0/myorg"
      authentication:
        type: bearer
        token: "$secrets.powerbi_token"
      resources:
        - name: datasets
          path: "/datasets/{{dataset_id}}/refreshes"
          operations:
            - name: refresh-dataset
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Queries PayPal transaction history for a merchant, computes risk metrics via Snowflake, and updates the risk profile in Salesforce.

naftiko: "0.5"
info:
  label: "Merchant Risk Score Aggregator"
  description: "Queries PayPal transaction history for a merchant, computes risk metrics via Snowflake, and updates the risk profile in Salesforce."
  tags:
    - risk
    - merchant
    - paypal
    - snowflake
    - salesforce
capability:
  exposes:
    - type: mcp
      namespace: risk-aggregation
      port: 8080
      tools:
        - name: aggregate-merchant-risk
          description: "Given a merchant email and Salesforce account ID, query transactions, compute risk in Snowflake, and update CRM."
          inputParameters:
            - name: merchant_email
              in: body
              type: string
              description: "The merchant PayPal email."
            - name: sf_account_id
              in: body
              type: string
              description: "The Salesforce account ID."
            - name: lookback_days
              in: body
              type: number
              description: "Number of days to look back."
          steps:
            - name: compute-risk
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "SELECT COUNT(*) as txn_count, SUM(amount) as total_volume, COUNT(CASE WHEN dispute_flag = true THEN 1 END) as dispute_count, AVG(risk_score) as avg_risk FROM paypal_data.transactions WHERE merchant_email = '{{merchant_email}}' AND created_at >= DATEADD(day, -{{lookback_days}}, CURRENT_DATE())"
                warehouse: "RISK_WH"
                database: "PAYPAL_DATA"
            - name: update-salesforce
              type: call
              call: "salesforce.update-account"
              with:
                account_id: "{{sf_account_id}}"
                Transaction_Count__c: "{{compute-risk.data[0][0]}}"
                Total_Volume__c: "{{compute-risk.data[0][1]}}"
                Dispute_Count__c: "{{compute-risk.data[0][2]}}"
                Average_Risk_Score__c: "{{compute-risk.data[0][3]}}"
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: accounts
          path: "/Account/{{account_id}}"
          inputParameters:
            - name: account_id
              in: path
          operations:
            - name: update-account
              method: PATCH

# ---------------------------------------------------------------------------
# 48. Subscription Cancellation Feedback Loop (orchestrated)
# ---------------------------------------------------------------------------

Pulls daily settlement data from PayPal, reconciles against Snowflake financial records, and posts discrepancy alerts to Microsoft Teams.

naftiko: "0.5"
info:
  label: "Merchant Settlement Reconciliation Pipeline"
  description: "Pulls daily settlement data from PayPal, reconciles against Snowflake financial records, and posts discrepancy alerts to Microsoft Teams."
  tags:
    - settlements
    - paypal
    - snowflake
    - microsoft-teams
    - reconciliation
capability:
  exposes:
    - type: mcp
      namespace: settlement-recon
      port: 8080
      tools:
        - name: reconcile-settlements
          description: "Reconcile PayPal settlements against internal financial records."
          inputParameters:
            - name: settlement_date
              in: body
              type: string
              description: "The settlement date to reconcile in YYYY-MM-DD format."
          steps:
            - name: get-settlements
              type: call
              call: "paypal.get-settlements"
              with:
                start_date: "{{settlement_date}}T00:00:00Z"
                end_date: "{{settlement_date}}T23:59:59Z"
            - name: query-internal
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT * FROM finance.daily_settlements WHERE settlement_date = '{{settlement_date}}'"
            - name: notify-discrepancies
              type: call
              call: "teams.post-message"
              with:
                channel: "finance-reconciliation"
                text: "Settlement reconciliation for {{settlement_date}}: PayPal total ${{get-settlements.total_amount}} vs Internal ${{query-internal.total_amount}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: settlements
          path: "/transactions"
          inputParameters:
            - name: start_date
              in: query
            - name: end_date
              in: query
          operations:
            - name: get-settlements
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: queries
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: teams
      baseUri: "https://graph.microsoft.com/v1.0"
      authentication:
        type: bearer
        token: "$secrets.teams_token"
      resources:
        - name: messages
          path: "/teams/channels/messages"
          operations:
            - name: post-message
              method: POST

Routes merchant support tickets by analyzing the issue, looking up merchant status in PayPal, and assigning to the appropriate team in ServiceNow.

naftiko: "0.5"
info:
  label: "Merchant Support Ticket Auto Router"
  description: "Routes merchant support tickets by analyzing the issue, looking up merchant status in PayPal, and assigning to the appropriate team in ServiceNow."
  tags:
    - support
    - paypal
    - servicenow
    - slack
capability:
  exposes:
    - type: mcp
      namespace: support-routing
      port: 8080
      tools:
        - name: route-support-ticket
          description: "Automatically route a merchant support ticket to the correct team."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
            - name: issue_description
              in: body
              type: string
              description: "Description of the support issue."
          steps:
            - name: get-merchant-info
              type: call
              call: "paypal.get-merchant-info"
              with:
                merchant_id: "{{merchant_id}}"
            - name: create-ticket
              type: call
              call: "servicenow.create-incident"
              with:
                short_description: "Merchant support: {{merchant_id}}"
                description: "{{issue_description}}\nMerchant tier: {{get-merchant-info.tier}}"
                priority: "3"
            - name: alert-team
              type: call
              call: "slack.post-message"
              with:
                channel: "#merchant-support"
                text: "New ticket {{create-ticket.number}} for merchant {{merchant_id}} ({{get-merchant-info.tier}} tier)"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: merchants
          path: "/partners/{{merchant_id}}"
          inputParameters:
            - name: merchant_id
              in: path
          operations:
            - name: get-merchant-info
              method: GET
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: bearer
        token: "$secrets.servicenow_token"
      resources:
        - name: incidents
          path: "/table/incident"
          operations:
            - name: create-incident
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Retrieves a PayPal payment, converts the amount using an exchange rate API, and updates the accounting record in Snowflake for multi-currency reconciliation.

naftiko: "0.5"
info:
  label: "Multi-Currency Payment Reconciliation"
  description: "Retrieves a PayPal payment, converts the amount using an exchange rate API, and updates the accounting record in Snowflake for multi-currency reconciliation."
  tags:
    - multi-currency
    - reconciliation
    - paypal
    - exchange-rates
    - snowflake
capability:
  exposes:
    - type: mcp
      namespace: currency-reconciliation
      port: 8080
      tools:
        - name: reconcile-currency
          description: "Given a PayPal capture ID and target currency, convert the amount and update the Snowflake ledger."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID."
            - name: target_currency
              in: body
              type: string
              description: "The target currency code (e.g., EUR, GBP)."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: get-rate
              type: call
              call: "exchangerate.get-rate"
              with:
                base: "{{get-payment.amount.currency_code}}"
                target: "{{target_currency}}"
            - name: update-ledger
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "UPDATE finance.multicurrency_ledger SET converted_amount = {{get-payment.amount.value}} * {{get-rate.rate}}, target_currency = '{{target_currency}}', exchange_rate = {{get-rate.rate}} WHERE capture_id = '{{capture_id}}'"
                warehouse: "FINANCE_WH"
                database: "PAYPAL_DATA"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: exchangerate
      baseUri: "https://api.exchangerate-api.com/v4"
      authentication:
        type: apiKey
        name: "apikey"
        in: query
        value: "$secrets.exchangerate_api_key"
      resources:
        - name: rates
          path: "/latest/{{base}}"
          inputParameters:
            - name: base
              in: path
          operations:
            - name: get-rate
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST

# ---------------------------------------------------------------------------
# 35. Billing Agreement Sync to CRM (orchestrated)
# ---------------------------------------------------------------------------

Disburses payments for multi-party orders by capturing PayPal payments, splitting funds to sellers, and logging disbursements in the ledger.

naftiko: "0.5"
info:
  label: "Multi-Party Order Disbursement Pipeline"
  description: "Disburses payments for multi-party orders by capturing PayPal payments, splitting funds to sellers, and logging disbursements in the ledger."
  tags:
    - disbursement
    - paypal
    - snowflake
    - slack
capability:
  exposes:
    - type: mcp
      namespace: disbursement
      port: 8080
      tools:
        - name: disburse-multi-party-order
          description: "Capture and disburse funds for a multi-party PayPal order."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
          steps:
            - name: capture-order
              type: call
              call: "paypal.capture-order"
              with:
                order_id: "{{order_id}}"
            - name: log-disbursement
              type: call
              call: "snowflake.run-query"
              with:
                query: "INSERT INTO finance.disbursements (order_id, amount, status, captured_at) VALUES ('{{order_id}}', '{{capture-order.purchase_units[0].payments.captures[0].amount.value}}', 'COMPLETED', CURRENT_TIMESTAMP)"
            - name: notify-ops
              type: call
              call: "slack.post-message"
              with:
                channel: "#disbursements"
                text: "Order {{order_id}} disbursed: ${{capture-order.purchase_units[0].payments.captures[0].amount.value}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/orders/{{order_id}}/capture"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: capture-order
              method: POST
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Provisions a new merchant by creating a PayPal partner referral, setting up Salesforce account, and notifying the sales team via Slack.

naftiko: "0.5"
info:
  label: "New Merchant Setup Pipeline"
  description: "Provisions a new merchant by creating a PayPal partner referral, setting up Salesforce account, and notifying the sales team via Slack."
  tags:
    - onboarding
    - paypal
    - salesforce
    - slack
capability:
  exposes:
    - type: mcp
      namespace: merchant-setup
      port: 8080
      tools:
        - name: setup-new-merchant
          description: "Provision a new merchant account across PayPal, CRM, and notify sales."
          inputParameters:
            - name: merchant_name
              in: body
              type: string
              description: "The merchant business name."
            - name: merchant_email
              in: body
              type: string
              description: "The merchant contact email."
            - name: sales_rep
              in: body
              type: string
              description: "The assigned sales representative."
          steps:
            - name: create-referral
              type: call
              call: "paypal.create-partner-referral"
              with:
                business_name: "{{merchant_name}}"
                email: "{{merchant_email}}"
            - name: create-account
              type: call
              call: "salesforce.create-account"
              with:
                Name: "{{merchant_name}}"
                PayPal_Referral_ID__c: "{{create-referral.partner_referral_id}}"
                Owner: "{{sales_rep}}"
            - name: notify-sales
              type: call
              call: "slack.post-message"
              with:
                channel: "#merchant-onboarding"
                text: "New merchant {{merchant_name}} created. Referral: {{create-referral.partner_referral_id}}. SF Account: {{create-account.id}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: partner-referrals
          path: "/partner-referrals"
          operations:
            - name: create-partner-referral
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: accounts
          path: "/sobjects/Account"
          operations:
            - name: create-account
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Captures an authorized PayPal order, creates a shipment in ShipStation, and sends the tracking info to the buyer via SendGrid.

naftiko: "0.5"
info:
  label: "Order Capture and Fulfillment"
  description: "Captures an authorized PayPal order, creates a shipment in ShipStation, and sends the tracking info to the buyer via SendGrid."
  tags:
    - checkout
    - fulfillment
    - paypal
    - shipstation
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: order-fulfillment
      port: 8080
      tools:
        - name: capture-and-fulfill
          description: "Given a PayPal order ID and buyer email, capture the payment, create a shipment, and email tracking details."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID to capture."
            - name: buyer_email
              in: body
              type: string
              description: "The buyer email for shipping notification."
            - name: shipping_address
              in: body
              type: string
              description: "The delivery address."
          steps:
            - name: capture-order
              type: call
              call: "paypal.capture-order"
              with:
                order_id: "{{order_id}}"
            - name: create-shipment
              type: call
              call: "shipstation.create-order"
              with:
                orderNumber: "{{order_id}}"
                shipTo:
                  street1: "{{shipping_address}}"
                amountPaid: "{{capture-order.purchase_units[0].payments.captures[0].amount.value}}"
            - name: notify-buyer
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{buyer_email}}"
                subject: "Order Confirmed - {{order_id}}"
                body: "Your payment of ${{capture-order.purchase_units[0].payments.captures[0].amount.value}} has been captured. ShipStation order: {{create-shipment.orderId}}. You will receive tracking info shortly."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}/capture"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: capture-order
              method: POST
    - type: http
      namespace: shipstation
      baseUri: "https://ssapi.shipstation.com"
      authentication:
        type: basic
        username: "$secrets.shipstation_key"
        password: "$secrets.shipstation_secret"
      resources:
        - name: orders
          path: "/orders/createorder"
          operations:
            - name: create-order
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 28. Daily Settlement Report (orchestrated)
# ---------------------------------------------------------------------------

When an order completion webhook fires, verifies the order in PayPal, updates inventory in the warehouse system, and sends a confirmation via Twilio SMS.

naftiko: "0.5"
info:
  label: "Order Completion Webhook Processor"
  description: "When an order completion webhook fires, verifies the order in PayPal, updates inventory in the warehouse system, and sends a confirmation via Twilio SMS."
  tags:
    - orders
    - paypal
    - twilio
    - warehouse
capability:
  exposes:
    - type: mcp
      namespace: order-completion
      port: 8080
      tools:
        - name: process-order-completion
          description: "Verify a completed PayPal order, update inventory, and send SMS confirmation."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: customer_phone
              in: body
              type: string
              description: "Customer phone number for SMS."
          steps:
            - name: verify-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: update-inventory
              type: call
              call: "warehouse.decrement-stock"
              with:
                sku: "{{verify-order.purchase_units[0].items[0].sku}}"
                quantity: "{{verify-order.purchase_units[0].items[0].quantity}}"
            - name: send-sms
              type: call
              call: "twilio.send-message"
              with:
                to: "{{customer_phone}}"
                body: "Your PayPal order {{order_id}} for ${{verify-order.purchase_units[0].amount.value}} is confirmed!"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/orders/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: warehouse
      baseUri: "https://wms.paypal.com/api/v1"
      authentication:
        type: bearer
        token: "$secrets.wms_token"
      resources:
        - name: inventory
          path: "/inventory/adjust"
          operations:
            - name: decrement-stock
              method: POST
    - type: http
      namespace: twilio
      baseUri: "https://api.twilio.com/2010-04-01"
      authentication:
        type: basic
        username: "$secrets.twilio_account_sid"
        password: "$secrets.twilio_auth_token"
      resources:
        - name: messages
          path: "/Accounts/{{twilio_account_sid}}/Messages.json"
          operations:
            - name: send-message
              method: POST

Certifies partner integrations by running automated tests against PayPal APIs, scoring results, and updating partner status in Salesforce.

naftiko: "0.5"
info:
  label: "Partner Integration Certification Pipeline"
  description: "Certifies partner integrations by running automated tests against PayPal APIs, scoring results, and updating partner status in Salesforce."
  tags:
    - partners
    - paypal
    - salesforce
    - testing
capability:
  exposes:
    - type: mcp
      namespace: partner-certification
      port: 8080
      tools:
        - name: certify-partner-integration
          description: "Run certification tests for a partner PayPal integration."
          inputParameters:
            - name: partner_id
              in: body
              type: string
              description: "The partner ID."
            - name: integration_type
              in: body
              type: string
              description: "The integration type being certified."
          steps:
            - name: run-tests
              type: call
              call: "paypal.run-integration-tests"
              with:
                partner_id: "{{partner_id}}"
                type: "{{integration_type}}"
            - name: update-partner-record
              type: call
              call: "salesforce.update-account"
              with:
                partner_id: "{{partner_id}}"
                certification_status: "{{run-tests.result}}"
                certified_date: "{{run-tests.completed_at}}"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#partner-integrations"
                text: "Partner {{partner_id}} certification: {{run-tests.result}} ({{run-tests.score}}/100)"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/developer"
      authentication:
        type: bearer
        token: "$secrets.paypal_admin_token"
      resources:
        - name: tests
          path: "/integrations/{{partner_id}}/test"
          inputParameters:
            - name: partner_id
              in: path
          operations:
            - name: run-integration-tests
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: accounts
          path: "/sobjects/Account"
          operations:
            - name: update-account
              method: PATCH
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Checks a PayPal partner merchant integration status, logs health metrics to Datadog, and creates a ServiceNow incident if the integration is unhealthy.

naftiko: "0.5"
info:
  label: "Partner Integration Health Check"
  description: "Checks a PayPal partner merchant integration status, logs health metrics to Datadog, and creates a ServiceNow incident if the integration is unhealthy."
  tags:
    - partner
    - health-check
    - paypal
    - datadog
    - servicenow
capability:
  exposes:
    - type: mcp
      namespace: partner-health
      port: 8080
      tools:
        - name: check-partner-health
          description: "Given a partner and merchant ID, check integration status, log to Datadog, and escalate if unhealthy."
          inputParameters:
            - name: partner_id
              in: body
              type: string
              description: "The PayPal partner ID."
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
          steps:
            - name: get-integration
              type: call
              call: "paypal.get-merchant-integration"
              with:
                partner_id: "{{partner_id}}"
                merchant_id: "{{merchant_id}}"
            - name: log-health
              type: call
              call: "datadog.submit-metric"
              with:
                metric: "paypal.partner.integration_status"
                type: "gauge"
                points:
                  - value: 1
                tags:
                  - "partner_id:{{partner_id}}"
                  - "merchant_id:{{merchant_id}}"
                  - "payments_receivable:{{get-integration.payments_receivable}}"
            - name: create-incident
              type: call
              call: "servicenow.create-incident"
              with:
                short_description: "Partner integration issue: {{partner_id}} / {{merchant_id}}"
                description: "Payments receivable: {{get-integration.payments_receivable}}. Primary email confirmed: {{get-integration.primary_email_confirmed}}."
                category: "partner_integration"
                urgency: "2"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer/partners"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: merchant-integrations
          path: "/{{partner_id}}/merchant-integrations/{{merchant_id}}"
          inputParameters:
            - name: partner_id
              in: path
            - name: merchant_id
              in: path
          operations:
            - name: get-merchant-integration
              method: GET
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v2"
      authentication:
        type: apiKey
        name: "DD-API-KEY"
        in: header
        value: "$secrets.datadog_api_key"
      resources:
        - name: metrics
          path: "/series"
          operations:
            - name: submit-metric
              method: POST
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: basic
        username: "$secrets.servicenow_user"
        password: "$secrets.servicenow_password"
      resources:
        - name: incidents
          path: "/table/incident"
          operations:
            - name: create-incident
              method: POST

# ---------------------------------------------------------------------------
# 44. Invoice Overdue Collection Workflow (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a PayPal authorization, checks if it is nearing expiry, and sends an alert to the merchant via Slack and logs a ServiceNow ticket.

naftiko: "0.5"
info:
  label: "Payment Authorization Hold Manager"
  description: "Retrieves a PayPal authorization, checks if it is nearing expiry, and sends an alert to the merchant via Slack and logs a ServiceNow ticket."
  tags:
    - authorizations
    - payments
    - paypal
    - slack
    - servicenow
capability:
  exposes:
    - type: mcp
      namespace: auth-hold-manager
      port: 8080
      tools:
        - name: manage-auth-hold
          description: "Given a PayPal authorization ID, check expiry and alert merchant via Slack and ServiceNow if nearing expiration."
          inputParameters:
            - name: authorization_id
              in: body
              type: string
              description: "The PayPal authorization ID."
            - name: merchant_slack_channel
              in: body
              type: string
              description: "The Slack channel to notify."
          steps:
            - name: get-auth
              type: call
              call: "paypal.get-auth"
              with:
                authorization_id: "{{authorization_id}}"
            - name: alert-merchant
              type: call
              call: "slack.post-message"
              with:
                channel: "{{merchant_slack_channel}}"
                text: "Authorization {{authorization_id}} for ${{get-auth.amount.value}} is {{get-auth.status}}. Expires: {{get-auth.expiration_time}}. Capture before expiry to avoid re-authorization."
            - name: create-ticket
              type: call
              call: "servicenow.create-incident"
              with:
                short_description: "PayPal auth hold expiring: {{authorization_id}}"
                description: "Authorization {{authorization_id}} for ${{get-auth.amount.value}} expires at {{get-auth.expiration_time}}. Status: {{get-auth.status}}."
                category: "payment_operations"
                urgency: "2"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments/authorizations"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: authorizations
          path: "/{{authorization_id}}"
          inputParameters:
            - name: authorization_id
              in: path
          operations:
            - name: get-auth
              method: GET
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: basic
        username: "$secrets.servicenow_user"
        password: "$secrets.servicenow_password"
      resources:
        - name: incidents
          path: "/table/incident"
          operations:
            - name: create-incident
              method: POST

# ---------------------------------------------------------------------------
# 31. Crypto Purchase Audit Trail (orchestrated)
# ---------------------------------------------------------------------------

When a PayPal payment capture fails, retrieves the order details, logs the failure in Datadog, and creates a Jira ticket for payment engineering to investigate.

naftiko: "0.5"
info:
  label: "Payment Failure Retry Orchestrator"
  description: "When a PayPal payment capture fails, retrieves the order details, logs the failure in Datadog, and creates a Jira ticket for payment engineering to investigate."
  tags:
    - payments
    - failure-handling
    - paypal
    - datadog
    - jira
capability:
  exposes:
    - type: mcp
      namespace: payment-retry
      port: 8080
      tools:
        - name: handle-payment-failure
          description: "Given a failed PayPal order ID, log the failure and create an investigation ticket."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID that failed capture."
            - name: error_code
              in: body
              type: string
              description: "The error code returned by PayPal."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: log-failure
              type: call
              call: "datadog.submit-event"
              with:
                title: "PayPal payment capture failed: {{order_id}}"
                text: "Order {{order_id}} for ${{get-order.purchase_units[0].amount.value}} failed with error {{error_code}}. Payer: {{get-order.payer.email_address}}."
                alert_type: "error"
                tags:
                  - "order_id:{{order_id}}"
                  - "error_code:{{error_code}}"
            - name: create-ticket
              type: call
              call: "jira.create-issue"
              with:
                project: "PAY"
                summary: "Payment capture failure: {{order_id}} - {{error_code}}"
                description: "Order: {{order_id}}\nAmount: ${{get-order.purchase_units[0].amount.value}}\nError: {{error_code}}\nPayer: {{get-order.payer.email_address}}"
                issue_type: "Bug"
                priority: "High"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v1"
      authentication:
        type: apiKey
        name: "DD-API-KEY"
        in: header
        value: "$secrets.datadog_api_key"
      resources:
        - name: events
          path: "/events"
          operations:
            - name: submit-event
              method: POST
    - type: http
      namespace: jira
      baseUri: "https://paypal-internal.atlassian.net/rest/api/3"
      authentication:
        type: basic
        username: "$secrets.jira_user"
        password: "$secrets.jira_api_token"
      resources:
        - name: issues
          path: "/issue"
          operations:
            - name: create-issue
              method: POST

# ---------------------------------------------------------------------------
# 41. Product Catalog and Plan Provisioner (orchestrated)
# ---------------------------------------------------------------------------

Monitors PayPal API response times, logs metrics to Datadog, and triggers PagerDuty alerts when latency exceeds thresholds.

naftiko: "0.5"
info:
  label: "Payment Gateway Latency Monitor"
  description: "Monitors PayPal API response times, logs metrics to Datadog, and triggers PagerDuty alerts when latency exceeds thresholds."
  tags:
    - monitoring
    - paypal
    - datadog
    - pagerduty
capability:
  exposes:
    - type: mcp
      namespace: latency-monitor
      port: 8080
      tools:
        - name: check-gateway-latency
          description: "Monitor PayPal API latency and alert on threshold breaches."
          inputParameters:
            - name: endpoint
              in: body
              type: string
              description: "The PayPal API endpoint to monitor."
          steps:
            - name: check-health
              type: call
              call: "paypal.health-check"
              with:
                endpoint: "{{endpoint}}"
            - name: log-metric
              type: call
              call: "datadog.submit-metric"
              with:
                metric: "paypal.api.latency_ms"
                value: "{{check-health.response_time_ms}}"
                tags:
                  - "endpoint:{{endpoint}}"
            - name: trigger-alert
              type: call
              call: "pagerduty.create-incident"
              with:
                service: "paypal-gateway"
                title: "High latency on {{endpoint}}: {{check-health.response_time_ms}}ms"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: health
          path: "/health"
          operations:
            - name: health-check
              method: GET
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v2"
      authentication:
        type: apiKey
        key: "$secrets.datadog_api_key"
      resources:
        - name: metrics
          path: "/series"
          operations:
            - name: submit-metric
              method: POST
    - type: http
      namespace: pagerduty
      baseUri: "https://api.pagerduty.com"
      authentication:
        type: bearer
        token: "$secrets.pagerduty_token"
      resources:
        - name: incidents
          path: "/incidents"
          operations:
            - name: create-incident
              method: POST

Generates PayPal payment links for invoices, tracks click-through and conversion rates, and syncs results to the CRM.

naftiko: "0.5"
info:
  label: "Payment Link Generation and Tracking"
  description: "Generates PayPal payment links for invoices, tracks click-through and conversion rates, and syncs results to the CRM."
  tags:
    - payments
    - paypal
    - salesforce
    - analytics
capability:
  exposes:
    - type: mcp
      namespace: payment-links
      port: 8080
      tools:
        - name: generate-and-track-payment-link
          description: "Create a PayPal payment link and set up conversion tracking."
          inputParameters:
            - name: invoice_id
              in: body
              type: string
              description: "The invoice ID."
            - name: amount
              in: body
              type: string
              description: "The payment amount."
          steps:
            - name: create-payment-link
              type: call
              call: "paypal.create-payment-link"
              with:
                amount: "{{amount}}"
                invoice_id: "{{invoice_id}}"
            - name: update-crm
              type: call
              call: "salesforce.update-invoice"
              with:
                invoice_id: "{{invoice_id}}"
                payment_link: "{{create-payment-link.url}}"
                status: "LINK_SENT"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#ar-collections"
                text: "Payment link created for invoice {{invoice_id}}: {{create-payment-link.url}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payment-links
          path: "/orders"
          operations:
            - name: create-payment-link
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: invoices
          path: "/sobjects/Invoice__c"
          operations:
            - name: update-invoice
              method: PATCH
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Migrates customer payment methods from legacy vault to new PayPal vault API, validates tokens, and sends migration confirmation emails.

naftiko: "0.5"
info:
  label: "Payment Method Migration Orchestrator"
  description: "Migrates customer payment methods from legacy vault to new PayPal vault API, validates tokens, and sends migration confirmation emails."
  tags:
    - vault
    - paypal
    - migration
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: vault-migration
      port: 8080
      tools:
        - name: migrate-payment-method
          description: "Migrate a payment method from legacy to new vault and confirm with customer."
          inputParameters:
            - name: customer_id
              in: body
              type: string
              description: "The PayPal customer ID."
            - name: legacy_token
              in: body
              type: string
              description: "The legacy vault token."
          steps:
            - name: get-legacy-token
              type: call
              call: "paypal.get-vault-token"
              with:
                token_id: "{{legacy_token}}"
            - name: create-new-token
              type: call
              call: "paypal.create-payment-token"
              with:
                customer_id: "{{customer_id}}"
                payment_source: "{{get-legacy-token.payment_source}}"
            - name: confirm-migration
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{get-legacy-token.customer.email_address}}"
                template_id: "d-vault-migration-confirmation"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v3/vault"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payment-tokens
          path: "/payment-tokens/{{token_id}}"
          inputParameters:
            - name: token_id
              in: path
          operations:
            - name: get-vault-token
              method: GET
        - name: new-tokens
          path: "/payment-tokens"
          operations:
            - name: create-payment-token
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Monitors PayPal payment processing SLAs, compares actual vs target metrics, and escalates breaches through PagerDuty and Jira.

naftiko: "0.5"
info:
  label: "Payment Processing SLA Monitor"
  description: "Monitors PayPal payment processing SLAs, compares actual vs target metrics, and escalates breaches through PagerDuty and Jira."
  tags:
    - sla
    - paypal
    - pagerduty
    - jira
    - monitoring
capability:
  exposes:
    - type: mcp
      namespace: sla-monitor
      port: 8080
      tools:
        - name: check-processing-sla
          description: "Monitor payment processing SLA compliance and escalate breaches."
          inputParameters:
            - name: time_window
              in: body
              type: string
              description: "Time window to evaluate in minutes."
          steps:
            - name: get-metrics
              type: call
              call: "datadog.query-metrics"
              with:
                query: "avg:paypal.payment.processing_time_ms{*}.rollup(avg, {{time_window}})"
            - name: create-incident
              type: call
              call: "pagerduty.create-incident"
              with:
                service: "paypal-payments"
                title: "Payment SLA breach: avg processing time {{get-metrics.value}}ms exceeds threshold"
            - name: create-ticket
              type: call
              call: "jira.create-issue"
              with:
                project: "SRE"
                summary: "Payment processing SLA breach - {{get-metrics.value}}ms avg"
                issue_type: "Bug"
                priority: "High"
  consumes:
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v1"
      authentication:
        type: apiKey
        key: "$secrets.datadog_api_key"
      resources:
        - name: query
          path: "/query"
          operations:
            - name: query-metrics
              method: GET
    - type: http
      namespace: pagerduty
      baseUri: "https://api.pagerduty.com"
      authentication:
        type: bearer
        token: "$secrets.pagerduty_token"
      resources:
        - name: incidents
          path: "/incidents"
          operations:
            - name: create-incident
              method: POST
    - type: http
      namespace: jira
      baseUri: "https://paypal-internal.atlassian.net/rest/api/3"
      authentication:
        type: basic
        username: "$secrets.jira_user"
        password: "$secrets.jira_api_token"
      resources:
        - name: issues
          path: "/issue"
          operations:
            - name: create-issue
              method: POST

Processes a refund through PayPal, creates a credit memo in the ERP, and notifies the customer via SendGrid email.

naftiko: "0.5"
info:
  label: "Payment Refund and Credit Memo Pipeline"
  description: "Processes a refund through PayPal, creates a credit memo in the ERP, and notifies the customer via SendGrid email."
  tags:
    - refunds
    - paypal
    - sap
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: refund-processing
      port: 8080
      tools:
        - name: process-refund-with-credit-memo
          description: "Issue a PayPal refund, create a credit memo, and notify the customer."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID to refund."
            - name: amount
              in: body
              type: string
              description: "The refund amount."
            - name: customer_email
              in: body
              type: string
              description: "Customer email for notification."
          steps:
            - name: issue-refund
              type: call
              call: "paypal.refund-capture"
              with:
                capture_id: "{{capture_id}}"
                amount: "{{amount}}"
            - name: create-credit-memo
              type: call
              call: "sap.create-credit-memo"
              with:
                reference: "{{issue-refund.id}}"
                amount: "{{amount}}"
            - name: notify-customer
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{customer_email}}"
                subject: "Your refund of ${{amount}} has been processed"
                template_id: "d-refund-confirmation"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: refunds
          path: "/captures/{{capture_id}}/refund"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: refund-capture
              method: POST
    - type: http
      namespace: sap
      baseUri: "https://paypal-erp.s4hana.ondemand.com/api/v1"
      authentication:
        type: basic
        username: "$secrets.sap_user"
        password: "$secrets.sap_password"
      resources:
        - name: credit-memos
          path: "/credit-memos"
          operations:
            - name: create-credit-memo
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Retrieves a PayPal payout batch status, checks for failed items, and posts a summary report to the operations Slack channel and logs to Datadog.

naftiko: "0.5"
info:
  label: "Payout Batch Monitor"
  description: "Retrieves a PayPal payout batch status, checks for failed items, and posts a summary report to the operations Slack channel and logs to Datadog."
  tags:
    - payouts
    - monitoring
    - paypal
    - slack
    - datadog
capability:
  exposes:
    - type: mcp
      namespace: payout-monitoring
      port: 8080
      tools:
        - name: monitor-payout-batch
          description: "Given a PayPal batch payout ID, retrieve the batch status, post a summary to Slack, and log metrics to Datadog."
          inputParameters:
            - name: payout_batch_id
              in: body
              type: string
              description: "The PayPal payout batch ID."
          steps:
            - name: get-batch
              type: call
              call: "paypal.get-batch"
              with:
                payout_batch_id: "{{payout_batch_id}}"
            - name: notify-ops
              type: call
              call: "slack.post-message"
              with:
                channel: "#payout-ops"
                text: "Payout batch {{payout_batch_id}}: Status={{get-batch.batch_header.batch_status}}, Total=${{get-batch.batch_header.amount.value}}, Items={{get-batch.batch_header.payments}}"
            - name: log-metric
              type: call
              call: "datadog.submit-metric"
              with:
                metric: "paypal.payout.batch_total"
                type: "gauge"
                points:
                  - value: "{{get-batch.batch_header.amount.value}}"
                tags:
                  - "batch_id:{{payout_batch_id}}"
                  - "status:{{get-batch.batch_header.batch_status}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/payments/payouts"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: batches
          path: "/{{payout_batch_id}}"
          inputParameters:
            - name: payout_batch_id
              in: path
          operations:
            - name: get-batch
              method: GET
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v2"
      authentication:
        type: apiKey
        name: "DD-API-KEY"
        in: header
        value: "$secrets.datadog_api_key"
      resources:
        - name: metrics
          path: "/series"
          operations:
            - name: submit-metric
              method: POST

# ---------------------------------------------------------------------------
# 23. Invoice Generation and Delivery (orchestrated)
# ---------------------------------------------------------------------------

Aggregates payout data from PayPal, generates 1099 tax summaries in Snowflake, and uploads reports to SharePoint for compliance review.

naftiko: "0.5"
info:
  label: "Payout Tax Reporting Pipeline"
  description: "Aggregates payout data from PayPal, generates 1099 tax summaries in Snowflake, and uploads reports to SharePoint for compliance review."
  tags:
    - payouts
    - paypal
    - snowflake
    - sharepoint
    - tax
capability:
  exposes:
    - type: mcp
      namespace: tax-reporting
      port: 8080
      tools:
        - name: generate-tax-report
          description: "Generate annual payout tax reports from PayPal data."
          inputParameters:
            - name: tax_year
              in: body
              type: string
              description: "The tax year for reporting."
          steps:
            - name: query-payouts
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT payee_email, SUM(amount) as total FROM paypal.payouts WHERE YEAR(created_at) = {{tax_year}} GROUP BY payee_email HAVING total >= 600"
            - name: upload-report
              type: call
              call: "sharepoint.upload-file"
              with:
                site: "finance-compliance"
                folder: "/Tax Reports/{{tax_year}}"
                filename: "paypal_1099_summary_{{tax_year}}.csv"
            - name: notify-compliance
              type: call
              call: "slack.post-message"
              with:
                channel: "#tax-compliance"
                text: "PayPal 1099 report for {{tax_year}} uploaded to SharePoint. {{query-payouts.row_count}} payees above threshold."
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: sharepoint
      baseUri: "https://graph.microsoft.com/v1.0/sites"
      authentication:
        type: bearer
        token: "$secrets.sharepoint_token"
      resources:
        - name: files
          path: "/drives/root/children"
          operations:
            - name: upload-file
              method: PUT
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Creates a product in the PayPal catalog, then creates a billing plan for it, and logs the new plan in Salesforce for sales enablement.

naftiko: "0.5"
info:
  label: "Product Catalog and Plan Provisioner"
  description: "Creates a product in the PayPal catalog, then creates a billing plan for it, and logs the new plan in Salesforce for sales enablement."
  tags:
    - catalog
    - billing
    - paypal
    - salesforce
    - subscriptions
capability:
  exposes:
    - type: mcp
      namespace: catalog-provisioner
      port: 8080
      tools:
        - name: provision-product-and-plan
          description: "Given product and pricing details, create a PayPal catalog product and billing plan, then log in Salesforce."
          inputParameters:
            - name: product_name
              in: body
              type: string
              description: "The product name."
            - name: product_type
              in: body
              type: string
              description: "The product type (SERVICE, PHYSICAL, DIGITAL)."
            - name: plan_name
              in: body
              type: string
              description: "The billing plan name."
            - name: price
              in: body
              type: string
              description: "The monthly price."
          steps:
            - name: create-product
              type: call
              call: "paypal.create-product"
              with:
                name: "{{product_name}}"
                type: "{{product_type}}"
            - name: create-plan
              type: call
              call: "paypal.create-plan"
              with:
                product_id: "{{create-product.id}}"
                name: "{{plan_name}}"
                billing_cycles:
                  - frequency:
                      interval_unit: "MONTH"
                      interval_count: 1
                    tenure_type: "REGULAR"
                    pricing_scheme:
                      fixed_price:
                        value: "{{price}}"
                        currency_code: "USD"
                payment_preferences:
                  auto_bill_outstanding: true
            - name: log-salesforce
              type: call
              call: "salesforce.create-record"
              with:
                object: "Product2"
                Name: "{{product_name}}"
                PayPal_Product_ID__c: "{{create-product.id}}"
                PayPal_Plan_ID__c: "{{create-plan.id}}"
                Monthly_Price__c: "{{price}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/catalogs/products"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: products
          path: "/"
          operations:
            - name: create-product
              method: POST
    - type: http
      namespace: paypal-billing
      baseUri: "https://api-m.paypal.com/v1/billing/plans"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: plans
          path: "/"
          operations:
            - name: create-plan
              method: POST
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: records
          path: "/{{object}}"
          inputParameters:
            - name: object
              in: path
          operations:
            - name: create-record
              method: POST

# ---------------------------------------------------------------------------
# 42. Vault Token Rotation and Sync (orchestrated)
# ---------------------------------------------------------------------------

Assembles quarterly merchant review packages by pulling transaction data from PayPal, dispute metrics from Snowflake, and creating a Confluence report.

naftiko: "0.5"
info:
  label: "Quarterly Merchant Review Assembler"
  description: "Assembles quarterly merchant review packages by pulling transaction data from PayPal, dispute metrics from Snowflake, and creating a Confluence report."
  tags:
    - reporting
    - paypal
    - snowflake
    - confluence
capability:
  exposes:
    - type: mcp
      namespace: quarterly-review
      port: 8080
      tools:
        - name: assemble-quarterly-review
          description: "Compile quarterly merchant review data from multiple sources."
          inputParameters:
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
            - name: quarter
              in: body
              type: string
              description: "The quarter in YYYY-Q# format."
          steps:
            - name: get-transaction-summary
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT COUNT(*) as txn_count, SUM(amount) as total_volume, AVG(amount) as avg_txn FROM paypal.transactions WHERE merchant_id = '{{merchant_id}}' AND quarter = '{{quarter}}'"
            - name: get-dispute-metrics
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT COUNT(*) as dispute_count, SUM(amount) as dispute_volume FROM paypal.disputes WHERE merchant_id = '{{merchant_id}}' AND quarter = '{{quarter}}'"
            - name: create-report
              type: call
              call: "confluence.create-page"
              with:
                space: "MERCHANT"
                title: "Quarterly Review - {{merchant_id}} - {{quarter}}"
                body: "Transaction volume: ${{get-transaction-summary.total_volume}}, Count: {{get-transaction-summary.txn_count}}, Disputes: {{get-dispute-metrics.dispute_count}}"
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: confluence
      baseUri: "https://paypal-internal.atlassian.net/wiki/rest/api"
      authentication:
        type: basic
        username: "$secrets.confluence_user"
        password: "$secrets.confluence_api_token"
      resources:
        - name: pages
          path: "/content"
          operations:
            - name: create-page
              method: POST

Retrieves a PayPal capture, pushes the transaction details to New Relic as a custom event, and logs to Grafana annotations for real-time dashboards.

naftiko: "0.5"
info:
  label: "Real-Time Payment Monitoring Dashboard"
  description: "Retrieves a PayPal capture, pushes the transaction details to New Relic as a custom event, and logs to Grafana annotations for real-time dashboards."
  tags:
    - monitoring
    - real-time
    - paypal
    - new-relic
    - grafana
capability:
  exposes:
    - type: mcp
      namespace: payment-monitoring
      port: 8080
      tools:
        - name: monitor-payment
          description: "Given a PayPal capture ID, push transaction data to New Relic and Grafana for monitoring."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: log-newrelic
              type: call
              call: "newrelic.create-event"
              with:
                eventType: "PayPalTransaction"
                capture_id: "{{capture_id}}"
                amount: "{{get-payment.amount.value}}"
                currency: "{{get-payment.amount.currency_code}}"
                status: "{{get-payment.status}}"
            - name: annotate-grafana
              type: call
              call: "grafana.create-annotation"
              with:
                text: "PayPal capture {{capture_id}}: ${{get-payment.amount.value}} {{get-payment.amount.currency_code}} - {{get-payment.status}}"
                tags:
                  - "paypal"
                  - "payment"
                  - "{{get-payment.status}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: newrelic
      baseUri: "https://insights-collector.newrelic.com/v1"
      authentication:
        type: apiKey
        name: "X-Insert-Key"
        in: header
        value: "$secrets.newrelic_insert_key"
      resources:
        - name: events
          path: "/accounts/$secrets.newrelic_account_id/events"
          operations:
            - name: create-event
              method: POST
    - type: http
      namespace: grafana
      baseUri: "https://paypal-grafana.grafana.net/api"
      authentication:
        type: bearer
        token: "$secrets.grafana_token"
      resources:
        - name: annotations
          path: "/annotations"
          operations:
            - name: create-annotation
              method: POST

# ---------------------------------------------------------------------------
# 46. Cross-Border Payment Compliance Logger (orchestrated)
# ---------------------------------------------------------------------------

Manages recurring donations by tracking PayPal subscriptions, syncing donor data to HubSpot CRM, and sending tax receipts via SendGrid.

naftiko: "0.5"
info:
  label: "Recurring Donation Management Pipeline"
  description: "Manages recurring donations by tracking PayPal subscriptions, syncing donor data to HubSpot CRM, and sending tax receipts via SendGrid."
  tags:
    - donations
    - paypal
    - hubspot
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: donations
      port: 8080
      tools:
        - name: manage-recurring-donation
          description: "Sync recurring donation data and send tax receipts."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID for the donation."
          steps:
            - name: get-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: sync-donor
              type: call
              call: "hubspot.update-contact"
              with:
                email: "{{get-subscription.subscriber.email_address}}"
                properties:
                  donation_status: "{{get-subscription.status}}"
                  last_donation_amount: "{{get-subscription.billing_info.last_payment.amount.value}}"
            - name: send-receipt
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{get-subscription.subscriber.email_address}}"
                template_id: "d-donation-receipt"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/subscriptions/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: hubspot
      baseUri: "https://api.hubapi.com"
      authentication:
        type: bearer
        token: "$secrets.hubspot_token"
      resources:
        - name: contacts
          path: "/crm/v3/objects/contacts"
          operations:
            - name: update-contact
              method: PATCH
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

On a refund event, retrieves the refund from PayPal, updates the corresponding Snowflake ledger record, and posts a summary to the finance Slack channel.

naftiko: "0.5"
info:
  label: "Refund and Chargeback Reconciliation"
  description: "On a refund event, retrieves the refund from PayPal, updates the corresponding Snowflake ledger record, and posts a summary to the finance Slack channel."
  tags:
    - refunds
    - reconciliation
    - paypal
    - snowflake
    - slack
    - finance
capability:
  exposes:
    - type: mcp
      namespace: refund-reconciliation
      port: 8080
      tools:
        - name: reconcile-refund
          description: "Given a PayPal refund ID, fetch refund details, update the Snowflake finance ledger, and notify the finance team on Slack."
          inputParameters:
            - name: refund_id
              in: body
              type: string
              description: "The PayPal refund ID."
            - name: original_order_id
              in: body
              type: string
              description: "The original PayPal order ID."
          steps:
            - name: get-refund
              type: call
              call: "paypal.get-refund"
              with:
                refund_id: "{{refund_id}}"
            - name: update-ledger
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "UPDATE finance.ledger SET refund_amount = '{{get-refund.amount.value}}', refund_status = '{{get-refund.status}}', refund_id = '{{refund_id}}' WHERE order_id = '{{original_order_id}}'"
                warehouse: "FINANCE_WH"
                database: "PAYPAL_DATA"
            - name: notify-finance
              type: call
              call: "slack.post-message"
              with:
                channel: "#finance-reconciliation"
                text: "Refund processed: {{refund_id}} for ${{get-refund.amount.value}} ({{get-refund.status}}). Order: {{original_order_id}}. Ledger updated."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments/refunds"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: refunds
          path: "/{{refund_id}}"
          inputParameters:
            - name: refund_id
              in: path
          operations:
            - name: get-refund
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 21. Checkout Conversion Tracker (orchestrated)
# ---------------------------------------------------------------------------

Retrieves refund details by refund ID from PayPal, returning status, amount refunded, and linked capture ID.

naftiko: "0.5"
info:
  label: "Refund Lookup"
  description: "Retrieves refund details by refund ID from PayPal, returning status, amount refunded, and linked capture ID."
  tags:
    - refunds
    - payments
    - paypal
capability:
  exposes:
    - type: mcp
      namespace: refunds
      port: 8080
      tools:
        - name: get-refund
          description: "Look up a PayPal refund by refund ID. Returns status, amount, and linked capture ID."
          inputParameters:
            - name: refund_id
              in: body
              type: string
              description: "The PayPal refund ID."
          call: "paypal.get-refund"
          with:
            refund_id: "{{refund_id}}"
          outputParameters:
            - name: status
              type: string
              mapping: "$.status"
            - name: amount
              type: string
              mapping: "$.amount.value"
            - name: capture_id
              type: string
              mapping: "$.links[0].href"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments/refunds"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: refunds
          path: "/{{refund_id}}"
          inputParameters:
            - name: refund_id
              in: path
          operations:
            - name: get-refund
              method: GET

# ---------------------------------------------------------------------------
# 12. Retrieve Identity User Info (simple)
# ---------------------------------------------------------------------------

Generates regulatory transaction reports from PayPal data, formats them per jurisdiction requirements, and submits to compliance systems.

naftiko: "0.5"
info:
  label: "Regulatory Transaction Report Generator"
  description: "Generates regulatory transaction reports from PayPal data, formats them per jurisdiction requirements, and submits to compliance systems."
  tags:
    - compliance
    - paypal
    - snowflake
    - sharepoint
capability:
  exposes:
    - type: mcp
      namespace: regulatory-reporting
      port: 8080
      tools:
        - name: generate-regulatory-report
          description: "Generate and submit jurisdiction-specific regulatory reports."
          inputParameters:
            - name: jurisdiction
              in: body
              type: string
              description: "The regulatory jurisdiction code."
            - name: period
              in: body
              type: string
              description: "Reporting period in YYYY-Q# format."
          steps:
            - name: query-transactions
              type: call
              call: "snowflake.run-query"
              with:
                query: "SELECT * FROM compliance.regulatory_transactions WHERE jurisdiction = '{{jurisdiction}}' AND period = '{{period}}'"
            - name: upload-report
              type: call
              call: "sharepoint.upload-file"
              with:
                site: "regulatory-filings"
                folder: "/{{jurisdiction}}/{{period}}"
                filename: "transaction_report_{{jurisdiction}}_{{period}}.csv"
            - name: notify
              type: call
              call: "slack.post-message"
              with:
                channel: "#regulatory-compliance"
                text: "Regulatory report for {{jurisdiction}} period {{period}} uploaded. {{query-transactions.row_count}} transactions included."
  consumes:
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: run-query
              method: POST
    - type: http
      namespace: sharepoint
      baseUri: "https://graph.microsoft.com/v1.0/sites"
      authentication:
        type: bearer
        token: "$secrets.sharepoint_token"
      resources:
        - name: files
          path: "/drives/root/children"
          operations:
            - name: upload-file
              method: PUT
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Fetches the authenticated PayPal user profile, including name, email, and account verification status.

naftiko: "0.5"
info:
  label: "Retrieve Identity User Info"
  description: "Fetches the authenticated PayPal user profile, including name, email, and account verification status."
  tags:
    - identity
    - paypal
    - user-profile
capability:
  exposes:
    - type: mcp
      namespace: identity
      port: 8080
      tools:
        - name: get-user-info
          description: "Retrieve the authenticated PayPal user profile. Returns name, email, and verified status."
          inputParameters: []
          call: "paypal.get-userinfo"
          with: {}
          outputParameters:
            - name: name
              type: string
              mapping: "$.name"
            - name: email
              type: string
              mapping: "$.emails[0].value"
            - name: verified
              type: string
              mapping: "$.verified_account"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/identity"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: user-info
          path: "/openidconnect/userinfo/?schema=openid"
          operations:
            - name: get-userinfo
              method: GET

# ---------------------------------------------------------------------------
# 13. Get Partner Referral Status (simple)
# ---------------------------------------------------------------------------

Fetches a single webhook event by event ID from PayPal, returning event type, resource type, and summary for debugging webhook integrations.

naftiko: "0.5"
info:
  label: "Retrieve Webhook Event"
  description: "Fetches a single webhook event by event ID from PayPal, returning event type, resource type, and summary for debugging webhook integrations."
  tags:
    - webhooks
    - paypal
    - integrations
capability:
  exposes:
    - type: mcp
      namespace: webhooks
      port: 8080
      tools:
        - name: get-webhook-event
          description: "Look up a PayPal webhook event by event ID. Returns event type, resource type, and create time."
          inputParameters:
            - name: event_id
              in: body
              type: string
              description: "The PayPal webhook event ID."
          call: "paypal.get-event"
          with:
            event_id: "{{event_id}}"
          outputParameters:
            - name: event_type
              type: string
              mapping: "$.event_type"
            - name: resource_type
              type: string
              mapping: "$.resource_type"
            - name: create_time
              type: string
              mapping: "$.create_time"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/notifications/webhooks-events"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: webhook-events
          path: "/{{event_id}}"
          inputParameters:
            - name: event_id
              in: path
          operations:
            - name: get-event
              method: GET

# ---------------------------------------------------------------------------
# 7. Get Invoice Details (simple)
# ---------------------------------------------------------------------------

Collects onboarding documents from new sellers via DocuSign, validates business details through PayPal partner APIs, and tracks progress in Salesforce.

naftiko: "0.5"
info:
  label: "Seller Onboarding Document Collector"
  description: "Collects onboarding documents from new sellers via DocuSign, validates business details through PayPal partner APIs, and tracks progress in Salesforce."
  tags:
    - onboarding
    - paypal
    - docusign
    - salesforce
capability:
  exposes:
    - type: mcp
      namespace: seller-onboarding
      port: 8080
      tools:
        - name: collect-seller-documents
          description: "Send document requests and track seller onboarding progress."
          inputParameters:
            - name: seller_email
              in: body
              type: string
              description: "The seller email address."
            - name: merchant_id
              in: body
              type: string
              description: "The PayPal merchant ID."
          steps:
            - name: send-envelope
              type: call
              call: "docusign.create-envelope"
              with:
                recipient_email: "{{seller_email}}"
                template_id: "seller-onboarding-docs"
            - name: check-partner-status
              type: call
              call: "paypal.get-partner-status"
              with:
                merchant_id: "{{merchant_id}}"
            - name: update-salesforce
              type: call
              call: "salesforce.update-opportunity"
              with:
                merchant_id: "{{merchant_id}}"
                stage: "Documents Sent"
                docusign_envelope_id: "{{send-envelope.envelope_id}}"
  consumes:
    - type: http
      namespace: docusign
      baseUri: "https://na4.docusign.net/restapi/v2.1"
      authentication:
        type: bearer
        token: "$secrets.docusign_access_token"
      resources:
        - name: envelopes
          path: "/accounts/{{account_id}}/envelopes"
          operations:
            - name: create-envelope
              method: POST
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/customer"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: partner-status
          path: "/partners/{{merchant_id}}/merchant-integrations"
          inputParameters:
            - name: merchant_id
              in: path
          operations:
            - name: get-partner-status
              method: GET
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: opportunities
          path: "/sobjects/Opportunity"
          operations:
            - name: update-opportunity
              method: PATCH

Checks a PayPal order for seller protection eligibility, logs the result in Snowflake, and notifies the seller via Slack.

naftiko: "0.5"
info:
  label: "Seller Protection Eligibility Check"
  description: "Checks a PayPal order for seller protection eligibility, logs the result in Snowflake, and notifies the seller via Slack."
  tags:
    - seller-protection
    - risk
    - paypal
    - snowflake
    - slack
capability:
  exposes:
    - type: mcp
      namespace: seller-protection
      port: 8080
      tools:
        - name: check-seller-protection
          description: "Given a PayPal order ID and seller Slack channel, check protection eligibility and report results."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: seller_channel
              in: body
              type: string
              description: "The seller Slack channel."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: log-result
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.seller_protection_checks (order_id, status, protection_eligibility, checked_at) VALUES ('{{order_id}}', '{{get-order.status}}', '{{get-order.purchase_units[0].payments.captures[0].seller_protection.status}}', CURRENT_TIMESTAMP())"
                warehouse: "RISK_WH"
                database: "PAYPAL_DATA"
            - name: notify-seller
              type: call
              call: "slack.post-message"
              with:
                channel: "{{seller_channel}}"
                text: "Order {{order_id}}: Seller Protection = {{get-order.purchase_units[0].payments.captures[0].seller_protection.status}}. Amount: ${{get-order.purchase_units[0].amount.value}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 34. Multi-Currency Payment Reconciliation (orchestrated)
# ---------------------------------------------------------------------------

When a PayPal order is created but not completed within a time window, retrieves the order, logs the abandonment in Snowflake, and sends a recovery email via SendGrid.

naftiko: "0.5"
info:
  label: "Shopping Cart Abandonment Recovery"
  description: "When a PayPal order is created but not completed within a time window, retrieves the order, logs the abandonment in Snowflake, and sends a recovery email via SendGrid."
  tags:
    - checkout
    - cart-abandonment
    - paypal
    - snowflake
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: cart-recovery
      port: 8080
      tools:
        - name: recover-abandoned-cart
          description: "Given an incomplete PayPal order ID and buyer email, log the abandonment and send a recovery email."
          inputParameters:
            - name: order_id
              in: body
              type: string
              description: "The PayPal order ID."
            - name: buyer_email
              in: body
              type: string
              description: "The buyer email for recovery."
          steps:
            - name: get-order
              type: call
              call: "paypal.get-order"
              with:
                order_id: "{{order_id}}"
            - name: log-abandonment
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.cart_abandonments (order_id, amount, status, buyer_email, logged_at) VALUES ('{{order_id}}', '{{get-order.purchase_units[0].amount.value}}', '{{get-order.status}}', '{{buyer_email}}', CURRENT_TIMESTAMP())"
                warehouse: "ANALYTICS_WH"
                database: "PAYPAL_DATA"
            - name: send-recovery
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{buyer_email}}"
                subject: "Complete Your Purchase - ${{get-order.purchase_units[0].amount.value}} Awaiting"
                body: "You left items in your cart totaling ${{get-order.purchase_units[0].amount.value}}. Complete your PayPal checkout now before the offer expires."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/checkout/orders"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: orders
          path: "/{{order_id}}"
          inputParameters:
            - name: order_id
              in: path
          operations:
            - name: get-order
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 38. Marketplace Seller Payout and Notification (orchestrated)
# ---------------------------------------------------------------------------

When a PayPal subscription is cancelled, retrieves subscription details, logs churn data in Snowflake, and creates a HubSpot re-engagement contact for win-back campaigns.

naftiko: "0.5"
info:
  label: "Subscription Cancellation Feedback Loop"
  description: "When a PayPal subscription is cancelled, retrieves subscription details, logs churn data in Snowflake, and creates a HubSpot re-engagement contact for win-back campaigns."
  tags:
    - subscriptions
    - churn
    - paypal
    - snowflake
    - hubspot
capability:
  exposes:
    - type: mcp
      namespace: cancellation-feedback
      port: 8080
      tools:
        - name: process-cancellation
          description: "Given a cancelled PayPal subscription ID and subscriber email, log churn and create a re-engagement contact."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
            - name: subscriber_email
              in: body
              type: string
              description: "The subscriber email."
            - name: cancellation_reason
              in: body
              type: string
              description: "The stated reason for cancellation."
          steps:
            - name: get-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: log-churn
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.subscription_churn (subscription_id, plan_id, subscriber_email, reason, cancelled_at) VALUES ('{{subscription_id}}', '{{get-subscription.plan_id}}', '{{subscriber_email}}', '{{cancellation_reason}}', CURRENT_TIMESTAMP())"
                warehouse: "ANALYTICS_WH"
                database: "PAYPAL_DATA"
            - name: create-reengage
              type: call
              call: "hubspot.create-contact"
              with:
                properties:
                  email: "{{subscriber_email}}"
                  paypal_subscription_id: "{{subscription_id}}"
                  churn_reason: "{{cancellation_reason}}"
                  lifecycle_stage: "opportunity"
                  lead_status: "WINBACK"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing/subscriptions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: hubspot
      baseUri: "https://api.hubapi.com/crm/v3"
      authentication:
        type: bearer
        token: "$secrets.hubspot_token"
      resources:
        - name: contacts
          path: "/objects/contacts"
          operations:
            - name: create-contact
              method: POST

# ---------------------------------------------------------------------------
# 49. Checkout Experience A/B Test Tracker (orchestrated)
# ---------------------------------------------------------------------------

When a PayPal subscription payment fails, retrieves subscription details, logs a Salesforce case, and sends the subscriber a retry notification via SendGrid.

naftiko: "0.5"
info:
  label: "Subscription Churn Prevention"
  description: "When a PayPal subscription payment fails, retrieves subscription details, logs a Salesforce case, and sends the subscriber a retry notification via SendGrid."
  tags:
    - subscriptions
    - churn
    - paypal
    - salesforce
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: churn-prevention
      port: 8080
      tools:
        - name: handle-failed-subscription
          description: "Given a failed subscription ID and subscriber email, fetch details, log a Salesforce case, and send a retry email."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
            - name: subscriber_email
              in: body
              type: string
              description: "The subscriber email address."
          steps:
            - name: get-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: log-case
              type: call
              call: "salesforce.create-case"
              with:
                Subject: "Subscription payment failure: {{subscription_id}}"
                Description: "Plan: {{get-subscription.plan_id}}. Status: {{get-subscription.status}}. Next billing: {{get-subscription.billing_info.next_billing_time}}."
                Priority: "High"
                Origin: "PayPal Webhook"
            - name: send-retry-email
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{subscriber_email}}"
                subject: "Action Needed - Update Your Payment Method"
                body: "Your subscription payment could not be processed. Please update your payment method to avoid service interruption. Subscription: {{subscription_id}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing/subscriptions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0/sobjects"
      authentication:
        type: bearer
        token: "$secrets.salesforce_token"
      resources:
        - name: cases
          path: "/Case"
          operations:
            - name: create-case
              method: POST
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

# ---------------------------------------------------------------------------
# 20. Refund and Chargeback Reconciliation (orchestrated)
# ---------------------------------------------------------------------------

When a subscription payment fails, retrieves the subscription details, updates the CRM record, sends a recovery email via SendGrid, and schedules a retry.

naftiko: "0.5"
info:
  label: "Subscription Payment Failure Recovery"
  description: "When a subscription payment fails, retrieves the subscription details, updates the CRM record, sends a recovery email via SendGrid, and schedules a retry."
  tags:
    - subscriptions
    - paypal
    - salesforce
    - sendgrid
    - recovery
capability:
  exposes:
    - type: mcp
      namespace: subscription-recovery
      port: 8080
      tools:
        - name: recover-failed-payment
          description: "Handle a failed subscription payment with notifications and retry scheduling."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
            - name: subscriber_email
              in: body
              type: string
              description: "The subscriber email address."
          steps:
            - name: get-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: update-crm
              type: call
              call: "salesforce.update-contact"
              with:
                email: "{{subscriber_email}}"
                payment_status: "FAILED"
                last_failure_date: "{{get-subscription.billing_info.last_failed_payment.time}}"
            - name: send-recovery-email
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{subscriber_email}}"
                template_id: "d-payment-recovery"
                dynamic_data:
                  plan_name: "{{get-subscription.plan_id}}"
                  amount: "{{get-subscription.billing_info.last_failed_payment.amount.value}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/subscriptions/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: salesforce
      baseUri: "https://paypal.my.salesforce.com/services/data/v58.0"
      authentication:
        type: bearer
        token: "$secrets.salesforce_access_token"
      resources:
        - name: contacts
          path: "/sobjects/Contact"
          operations:
            - name: update-contact
              method: PATCH
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

On subscription renewal, retrieves the subscription from PayPal, updates the renewal metrics in Datadog, and records the event in Snowflake.

naftiko: "0.5"
info:
  label: "Subscription Renewal Dashboard Update"
  description: "On subscription renewal, retrieves the subscription from PayPal, updates the renewal metrics in Datadog, and records the event in Snowflake."
  tags:
    - subscriptions
    - renewals
    - paypal
    - datadog
    - snowflake
capability:
  exposes:
    - type: mcp
      namespace: renewal-dashboard
      port: 8080
      tools:
        - name: update-renewal-metrics
          description: "Given a renewed subscription ID, fetch details, push metrics to Datadog, and log in Snowflake."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
          steps:
            - name: get-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: push-metric
              type: call
              call: "datadog.submit-metric"
              with:
                metric: "paypal.subscription.renewal"
                type: "count"
                points:
                  - value: 1
                tags:
                  - "plan:{{get-subscription.plan_id}}"
                  - "status:{{get-subscription.status}}"
            - name: log-renewal
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.subscription_events (subscription_id, plan_id, event_type, event_time) VALUES ('{{subscription_id}}', '{{get-subscription.plan_id}}', 'RENEWAL', CURRENT_TIMESTAMP())"
                warehouse: "ANALYTICS_WH"
                database: "PAYPAL_DATA"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing/subscriptions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: datadog
      baseUri: "https://api.datadoghq.com/api/v2"
      authentication:
        type: apiKey
        name: "DD-API-KEY"
        in: header
        value: "$secrets.datadog_api_key"
      resources:
        - name: metrics
          path: "/series"
          operations:
            - name: submit-metric
              method: POST
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST

# ---------------------------------------------------------------------------
# 30. Payment Authorization Hold Manager (orchestrated)
# ---------------------------------------------------------------------------

Handles subscription plan changes by updating the PayPal subscription, adjusting billing in the ERP, and confirming with the customer.

naftiko: "0.5"
info:
  label: "Subscription Upgrade Downgrade Handler"
  description: "Handles subscription plan changes by updating the PayPal subscription, adjusting billing in the ERP, and confirming with the customer."
  tags:
    - subscriptions
    - paypal
    - sap
    - sendgrid
capability:
  exposes:
    - type: mcp
      namespace: subscription-changes
      port: 8080
      tools:
        - name: handle-plan-change
          description: "Process a subscription upgrade or downgrade across systems."
          inputParameters:
            - name: subscription_id
              in: body
              type: string
              description: "The PayPal subscription ID."
            - name: new_plan_id
              in: body
              type: string
              description: "The new plan ID to switch to."
          steps:
            - name: get-current-subscription
              type: call
              call: "paypal.get-subscription"
              with:
                subscription_id: "{{subscription_id}}"
            - name: update-erp
              type: call
              call: "sap.update-billing-plan"
              with:
                subscription_ref: "{{subscription_id}}"
                new_plan: "{{new_plan_id}}"
                previous_plan: "{{get-current-subscription.plan_id}}"
            - name: confirm-change
              type: call
              call: "sendgrid.send-email"
              with:
                to: "{{get-current-subscription.subscriber.email_address}}"
                template_id: "d-plan-change-confirmation"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/billing"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: subscriptions
          path: "/subscriptions/{{subscription_id}}"
          inputParameters:
            - name: subscription_id
              in: path
          operations:
            - name: get-subscription
              method: GET
    - type: http
      namespace: sap
      baseUri: "https://paypal-erp.s4hana.ondemand.com/api/v1"
      authentication:
        type: basic
        username: "$secrets.sap_user"
        password: "$secrets.sap_password"
      resources:
        - name: billing
          path: "/billing-plans"
          operations:
            - name: update-billing-plan
              method: PATCH
    - type: http
      namespace: sendgrid
      baseUri: "https://api.sendgrid.com/v3"
      authentication:
        type: bearer
        token: "$secrets.sendgrid_api_key"
      resources:
        - name: mail
          path: "/mail/send"
          operations:
            - name: send-email
              method: POST

Queries PayPal transaction history for a merchant, checks velocity thresholds, and creates a PagerDuty incident if limits are exceeded.

naftiko: "0.5"
info:
  label: "Transaction Velocity Alert"
  description: "Queries PayPal transaction history for a merchant, checks velocity thresholds, and creates a PagerDuty incident if limits are exceeded."
  tags:
    - risk
    - velocity
    - paypal
    - pagerduty
    - monitoring
capability:
  exposes:
    - type: mcp
      namespace: velocity-alert
      port: 8080
      tools:
        - name: check-transaction-velocity
          description: "Given a merchant email and time window, query PayPal transactions and trigger a PagerDuty alert if velocity exceeds threshold."
          inputParameters:
            - name: merchant_email
              in: body
              type: string
              description: "The merchant PayPal email."
            - name: start_date
              in: body
              type: string
              description: "Start date in ISO 8601 format."
            - name: end_date
              in: body
              type: string
              description: "End date in ISO 8601 format."
            - name: threshold
              in: body
              type: number
              description: "Maximum allowed transaction count."
          steps:
            - name: get-transactions
              type: call
              call: "paypal.list-transactions"
              with:
                start_date: "{{start_date}}"
                end_date: "{{end_date}}"
                fields: "all"
            - name: create-incident
              type: call
              call: "pagerduty.create-incident"
              with:
                title: "Transaction velocity alert for {{merchant_email}}"
                service_id: "$secrets.pagerduty_risk_service_id"
                urgency: "high"
                body: "Transaction count exceeded threshold of {{threshold}} between {{start_date}} and {{end_date}}. Total: {{get-transactions.total_items}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting/transactions"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/?start_date={{start_date}}&end_date={{end_date}}&fields={{fields}}"
          inputParameters:
            - name: start_date
              in: query
            - name: end_date
              in: query
            - name: fields
              in: query
          operations:
            - name: list-transactions
              method: GET
    - type: http
      namespace: pagerduty
      baseUri: "https://api.pagerduty.com"
      authentication:
        type: bearer
        token: "$secrets.pagerduty_token"
      resources:
        - name: incidents
          path: "/incidents"
          operations:
            - name: create-incident
              method: POST

# ---------------------------------------------------------------------------
# 27. Order Capture and Fulfillment (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a PayPal vaulted payment token, checks its age, and syncs token metadata to Snowflake and notifies the security team via Slack if rotation is needed.

naftiko: "0.5"
info:
  label: "Vault Token Rotation and Sync"
  description: "Retrieves a PayPal vaulted payment token, checks its age, and syncs token metadata to Snowflake and notifies the security team via Slack if rotation is needed."
  tags:
    - vault
    - security
    - paypal
    - snowflake
    - slack
capability:
  exposes:
    - type: mcp
      namespace: vault-rotation
      port: 8080
      tools:
        - name: check-vault-token
          description: "Given a PayPal vault token ID, retrieve metadata, log to Snowflake, and alert if rotation is needed."
          inputParameters:
            - name: token_id
              in: body
              type: string
              description: "The PayPal vault payment token ID."
          steps:
            - name: get-token
              type: call
              call: "paypal.get-token"
              with:
                token_id: "{{token_id}}"
            - name: log-token
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.vault_token_audit (token_id, customer_id, payment_source, create_time, checked_at) VALUES ('{{token_id}}', '{{get-token.customer.id}}', '{{get-token.payment_source}}', '{{get-token.create_time}}', CURRENT_TIMESTAMP())"
                warehouse: "SECURITY_WH"
                database: "PAYPAL_DATA"
            - name: notify-security
              type: call
              call: "slack.post-message"
              with:
                channel: "#security-vault"
                text: "Vault token audit: {{token_id}} for customer {{get-token.customer.id}}. Created: {{get-token.create_time}}. Review for rotation policy compliance."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v3/vault/payment-tokens"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: payment-tokens
          path: "/{{token_id}}"
          inputParameters:
            - name: token_id
              in: path
          operations:
            - name: get-token
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 43. Partner Integration Health Check (orchestrated)
# ---------------------------------------------------------------------------

Retrieves a Venmo-originated PayPal payment, logs it in Snowflake analytics, and sends a push notification via Firebase Cloud Messaging.

naftiko: "0.5"
info:
  label: "Venmo Payment Notification Relay"
  description: "Retrieves a Venmo-originated PayPal payment, logs it in Snowflake analytics, and sends a push notification via Firebase Cloud Messaging."
  tags:
    - venmo
    - payments
    - paypal
    - snowflake
    - firebase
capability:
  exposes:
    - type: mcp
      namespace: venmo-notifications
      port: 8080
      tools:
        - name: relay-venmo-payment
          description: "Given a PayPal capture ID from a Venmo payment and a device token, log the payment and send a push notification."
          inputParameters:
            - name: capture_id
              in: body
              type: string
              description: "The PayPal capture ID from Venmo."
            - name: device_token
              in: body
              type: string
              description: "The FCM device token for push notification."
          steps:
            - name: get-payment
              type: call
              call: "paypal.get-capture"
              with:
                capture_id: "{{capture_id}}"
            - name: log-analytics
              type: call
              call: "snowflake.execute-statement"
              with:
                statement: "INSERT INTO paypal_data.venmo_payments (capture_id, amount, currency, status, logged_at) VALUES ('{{capture_id}}', '{{get-payment.amount.value}}', '{{get-payment.amount.currency_code}}', '{{get-payment.status}}', CURRENT_TIMESTAMP())"
                warehouse: "ANALYTICS_WH"
                database: "PAYPAL_DATA"
            - name: send-push
              type: call
              call: "firebase.send-notification"
              with:
                token: "{{device_token}}"
                title: "Payment Received"
                body: "You received ${{get-payment.amount.value}} via Venmo. Status: {{get-payment.status}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v2/payments"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: captures
          path: "/captures/{{capture_id}}"
          inputParameters:
            - name: capture_id
              in: path
          operations:
            - name: get-capture
              method: GET
    - type: http
      namespace: snowflake
      baseUri: "https://paypal.snowflakecomputing.com/api/v2"
      authentication:
        type: bearer
        token: "$secrets.snowflake_token"
      resources:
        - name: statements
          path: "/statements"
          operations:
            - name: execute-statement
              method: POST
    - type: http
      namespace: firebase
      baseUri: "https://fcm.googleapis.com/v1/projects/$secrets.firebase_project_id"
      authentication:
        type: bearer
        token: "$secrets.firebase_token"
      resources:
        - name: messages
          path: "/messages:send"
          operations:
            - name: send-notification
              method: POST

# ---------------------------------------------------------------------------
# 33. Seller Protection Eligibility Check (orchestrated)
# ---------------------------------------------------------------------------

Reconciles Venmo payouts against PayPal records, flags discrepancies in Jira, and updates the finance dashboard in Tableau.

naftiko: "0.5"
info:
  label: "Venmo Payout Reconciliation Pipeline"
  description: "Reconciles Venmo payouts against PayPal records, flags discrepancies in Jira, and updates the finance dashboard in Tableau."
  tags:
    - venmo
    - paypal
    - jira
    - tableau
    - reconciliation
capability:
  exposes:
    - type: mcp
      namespace: venmo-recon
      port: 8080
      tools:
        - name: reconcile-venmo-payouts
          description: "Reconcile Venmo payout records and flag discrepancies."
          inputParameters:
            - name: date
              in: body
              type: string
              description: "The date to reconcile in YYYY-MM-DD format."
          steps:
            - name: get-paypal-records
              type: call
              call: "paypal.search-transactions"
              with:
                start_date: "{{date}}T00:00:00Z"
                end_date: "{{date}}T23:59:59Z"
                channel: "VENMO"
            - name: flag-discrepancy
              type: call
              call: "jira.create-issue"
              with:
                project: "FIN"
                summary: "Venmo reconciliation discrepancy for {{date}}"
                issue_type: "Task"
            - name: refresh-dashboard
              type: call
              call: "tableau.refresh-workbook"
              with:
                workbook_id: "venmo-finance-dashboard"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/reporting"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: transactions
          path: "/transactions"
          operations:
            - name: search-transactions
              method: GET
    - type: http
      namespace: jira
      baseUri: "https://paypal-internal.atlassian.net/rest/api/3"
      authentication:
        type: basic
        username: "$secrets.jira_user"
        password: "$secrets.jira_api_token"
      resources:
        - name: issues
          path: "/issue"
          operations:
            - name: create-issue
              method: POST
    - type: http
      namespace: tableau
      baseUri: "https://tableau.paypal.com/api/3.19"
      authentication:
        type: bearer
        token: "$secrets.tableau_token"
      resources:
        - name: workbooks
          path: "/sites/default/workbooks/{{workbook_id}}/refresh"
          operations:
            - name: refresh-workbook
              method: POST

Detects failed PayPal webhook deliveries, retries the event, logs failures in ServiceNow, and alerts the integration team.

naftiko: "0.5"
info:
  label: "Webhook Delivery Failure Recovery"
  description: "Detects failed PayPal webhook deliveries, retries the event, logs failures in ServiceNow, and alerts the integration team."
  tags:
    - webhooks
    - paypal
    - servicenow
    - slack
capability:
  exposes:
    - type: mcp
      namespace: webhook-recovery
      port: 8080
      tools:
        - name: recover-webhook-failure
          description: "Retry failed webhook events and log incidents."
          inputParameters:
            - name: event_id
              in: body
              type: string
              description: "The PayPal webhook event ID."
          steps:
            - name: get-event
              type: call
              call: "paypal.get-webhook-event"
              with:
                event_id: "{{event_id}}"
            - name: log-incident
              type: call
              call: "servicenow.create-incident"
              with:
                short_description: "Webhook delivery failure: {{event_id}}"
                description: "Event type: {{get-event.event_type}}, Resource: {{get-event.resource_type}}"
            - name: alert-team
              type: call
              call: "slack.post-message"
              with:
                channel: "#integration-alerts"
                text: "Webhook {{event_id}} ({{get-event.event_type}}) failed delivery. ServiceNow: {{log-incident.number}}"
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/notifications"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: events
          path: "/webhooks-events/{{event_id}}"
          inputParameters:
            - name: event_id
              in: path
          operations:
            - name: get-webhook-event
              method: GET
    - type: http
      namespace: servicenow
      baseUri: "https://paypal.service-now.com/api/now"
      authentication:
        type: bearer
        token: "$secrets.servicenow_token"
      resources:
        - name: incidents
          path: "/table/incident"
          operations:
            - name: create-incident
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

Retrieves a missed PayPal webhook event, logs it to Elasticsearch for audit, and posts a notification to the engineering Slack channel for investigation.

naftiko: "0.5"
info:
  label: "Webhook Event Replay and Audit"
  description: "Retrieves a missed PayPal webhook event, logs it to Elasticsearch for audit, and posts a notification to the engineering Slack channel for investigation."
  tags:
    - webhooks
    - audit
    - paypal
    - elasticsearch
    - slack
capability:
  exposes:
    - type: mcp
      namespace: webhook-audit
      port: 8080
      tools:
        - name: replay-webhook-event
          description: "Given a PayPal webhook event ID, retrieve the event, index it in Elasticsearch, and notify engineering on Slack."
          inputParameters:
            - name: event_id
              in: body
              type: string
              description: "The PayPal webhook event ID."
          steps:
            - name: get-event
              type: call
              call: "paypal.get-event"
              with:
                event_id: "{{event_id}}"
            - name: index-event
              type: call
              call: "elasticsearch.index-doc"
              with:
                index: "paypal-webhook-events"
                body:
                  event_id: "{{event_id}}"
                  event_type: "{{get-event.event_type}}"
                  resource_type: "{{get-event.resource_type}}"
                  create_time: "{{get-event.create_time}}"
                  replayed: true
            - name: notify-engineering
              type: call
              call: "slack.post-message"
              with:
                channel: "#webhook-monitoring"
                text: "Webhook event replayed: {{event_id}} ({{get-event.event_type}}). Indexed in Elasticsearch. Created: {{get-event.create_time}}."
  consumes:
    - type: http
      namespace: paypal
      baseUri: "https://api-m.paypal.com/v1/notifications/webhooks-events"
      authentication:
        type: bearer
        token: "$secrets.paypal_access_token"
      resources:
        - name: webhook-events
          path: "/{{event_id}}"
          inputParameters:
            - name: event_id
              in: path
          operations:
            - name: get-event
              method: GET
    - type: http
      namespace: elasticsearch
      baseUri: "https://paypal-es.es.us-west-2.aws.found.io"
      authentication:
        type: basic
        username: "$secrets.es_user"
        password: "$secrets.es_password"
      resources:
        - name: documents
          path: "/{{index}}/_doc"
          inputParameters:
            - name: index
              in: path
          operations:
            - name: index-doc
              method: POST
    - type: http
      namespace: slack
      baseUri: "https://slack.com/api"
      authentication:
        type: bearer
        token: "$secrets.slack_bot_token"
      resources:
        - name: messages
          path: "/chat.postMessage"
          operations:
            - name: post-message
              method: POST

# ---------------------------------------------------------------------------
# 25. Merchant KYC Verification Pipeline (orchestrated)
# ---------------------------------------------------------------------------