BOB Docs
APIApplicationPayment

PaymentService

Key Features

  • Subscription Management: Create, update, and synchronize subscriptions with external providers.
  • Billing Integration: Manage customer billing data and synchronize it with external systems.
  • Payment Processing: Support for both one-time payments and subscription checkout sessions.
  • Product and Pricing Synchronization: Maintain consistency between internal and external product/pricing data.
  • Webhook Handling: Process external provider events to synchronize the internal system.

Methods

  1. Checkout Management:
  • checkout_subscription: Initiates a subscription checkout session with Stripe.
  • checkout: Handles one-time payment sessions.
  1. Billing and Customer Synchronization:
  • synchronize_customer: Synchronizes customer data with Stripe, creating or updating records.
  • create_external_customer: Links internal customers with external provider accounts.
  • synchronize_customers: Synchronizes multiple customers with external systems.
  1. Subscription Management:
  • create_external_subscription: Creates a subscription record in the external provider.
  • get_subscription: Retrieves a subscription using its external ID.
  • get_external_subscription: Fetches subscription data from the external provider.
  1. Product and Pricing Synchronization:
  • synchronize_products: Ensures product and pricing data align with external providers.
  • get_pricing: Fetches pricing details from external systems.
  1. Webhook Handling:
  • handle_webhook: Decodes and processes webhook events from external providers.
  1. Tax and VIES Validation:
  • is_country_from_eu: Checks if a country is an EU member.
  • verify_vies_number: Validates VAT numbers using the VIES API.
  1. Stripe-Specific Operations:
  • create_stripe_customer_portal_link: Generates a customer management portal link in Stripe.
  • get_customer: Retrieves customer details linked to an external provider.

Example Workflow

  1. Initiate Subscription Checkout
checkout_url = await payment_service.checkout_subscription(customer_id=123, pricing_id=456)
  1. Synchronize Products
await payment_service.synchronize_products(products)
  1. Validate VAT Number
vat_details = await payment_service.verify_vies_number(country_iso_2_code="PL", vat_number="123456789")

Dependencies

  • Repositories

  • ExternalCustomerRepository: Manages customer records with external providers.

  • ExternalProductRepository: Handles product synchronization with external systems.

  • ExternalPricingRepository: Tracks external pricing data.

  • ExternalSubscriptionRepository: Manages external subscription records.

  • Services

  • StripeProvider: Integrates with Stripe for managing customers, subscriptions, and payments.

Purpose

This service provides a centralized abstraction for payment processing and external integrations, ensuring reliable coordination between the internal system and external payment providers.

On this page