Payments API Documentation

Complete guide to integrating Stripe payments, subscriptions, and marketplace functionality.

Quick Start

Base URL: https://api.tayaribykmg.com

Authentication: Bearer token required

Content-Type: application/json

Test Mode: Use test API keys for sandbox environment

Create Payment Intent

POST /api/stripe/payment-intent

Request Body:

{
  "amount": 2000,
  "currency": "usd",
  "customer_id": "cus_123456789",
  "metadata": {
    "order_id": "order_123",
    "product": "premium_subscription"
  }
}

Response:

{
  "id": "pi_1ABC123def456",
  "amount": 2000,
  "currency": "usd",
  "status": "requires_payment_method",
  "client_secret": "pi_1ABC123def456_secret_xyz",
  "created": 1609459200
}

Process Payment

POST /api/stripe/confirm-payment

Request Body:

{
  "payment_intent_id": "pi_1ABC123def456",
  "payment_method": "pm_1ABC123def456",
  "return_url": "https://your-site.com/return"
}

Create Customer

POST /api/stripe/customers

Request Body:

{
  "email": "customer@example.com",
  "name": "John Doe",
  "phone": "+1234567890",
  "metadata": {
    "user_id": "123",
    "source": "website"
  }
}

Create Subscription

POST /api/stripe/subscriptions

Request Body:

{
  "customer_id": "cus_123456789",
  "price_id": "price_1ABC123def456",
  "trial_period_days": 14,
  "metadata": {
    "plan": "premium",
    "features": "unlimited_api_calls"
  }
}

Create Connect Account

POST /api/stripe/connect/accounts

Request Body:

{
  "type": "express",
  "country": "US",
  "email": "merchant@example.com",
  "business_profile": {
    "name": "Merchant Business",
    "url": "https://merchant.com"
  }
}

Webhook Events

POST /api/stripe/webhooks

Supported Events:

  • payment_intent.succeeded - Payment completed successfully
  • payment_intent.payment_failed - Payment failed
  • customer.subscription.created - New subscription created
  • customer.subscription.updated - Subscription modified
  • customer.subscription.deleted - Subscription cancelled
  • invoice.payment_succeeded - Invoice paid
  • invoice.payment_failed - Invoice payment failed
  • account.updated - Connect account updated

Payment Methods

GET /api/stripe/payment-methods

Supported Payment Methods:

Cards

Visa, Mastercard, Amex

Digital Wallets

Apple Pay, Google Pay

Bank Transfers

ACH, SEPA

Buy Now Pay Later

Klarna, Afterpay

Local Methods

iDEAL, Bancontact

Crypto

Bitcoin (via partners)

Common Error Codes

400Bad Request - Invalid parameters or missing required fields
401Unauthorized - Invalid API key
402Payment Required - Card declined or insufficient funds
403Forbidden - Request not allowed
429Too Many Requests - Rate limit exceeded

SDKs & Libraries

JavaScript/React

npm install @stripe/stripe-js

Node.js

npm install stripe

Python

pip install stripe

PHP

composer require stripe/stripe-php

Ruby

gem install stripe

Flutter/Dart

flutter pub add stripe_payment

Testing

Test Card Numbers:

4242424242424242 - Visa (Success)

4000000000000002 - Visa (Declined)

4000000000009995 - Visa (Insufficient funds)

5555555555554444 - Mastercard (Success)

Test Environment:

Use test API keys starting with sk_test_ and pk_test_