Skip to main content

The SkipCash SDK for Python enables developers to easily integrate SkipCash payment services into their Python applications.

Project description

SkipCash SDK for Python

The SkipCash SDK for Python enables developers to easily integrate SkipCash payment services into their Python applications. This SDK provides a convenient way to create and manage payments, handle webhooks, and interact with the SkipCash API.

Features

  • Create payments with various customization options.
  • Retrieve payment information using payment IDs.
  • Validate and process webhook events securely.
  • Handle various exceptions and errors gracefully.

Getting Started

Prerequisites

  • Python 3.x
  • An active SkipCash account with access to API credentials.

Installation

Currently, this SDK is provided as a Python module. Include it in your project by copying the SDK files to your project directory.

Configuration

To use the SDK, you'll need your SkipCash API credentials. Initialize the SkipCash client with your credentials:

from skipcash.client import SkipCash

skipcash = SkipCash(
    client_id='<your_client_id>',
    key_id='<your_client_key_id>',
    key_secret='<your_client_secret_key>',
    webhook_secret='<your_webhook_secret_key>',
    use_sandbox=True  # Set to False when moving to production
)

Usage

Creating a Payment

To create a payment, you need to prepare PaymentInfo with the necessary details:

from decimal import Decimal
from skipcash.api_resources import Payment
from skipcash.schema import PaymentInfo
from skipcash.exceptions import PaymentResponseError, PaymentValidationError, PaymentInfoError
from skipcash.client import SkipCash

skipcash = SkipCash(
    client_id='<your_client_id>',
    key_id='<your_client_key_id>',
    key_secret='<your_client_secret_key>',
    webhook_secret='<your_webhook_secret_key>',
    use_sandbox=True  # Set to False when moving to production
)
payment_info = PaymentInfo(
    key_id=skipcash.key_id,
    amount=Decimal('100.00'),
    first_name='John',
    last_name='Doe',
    phone='+1234567890',
    email='john.doe@example.com',
    street='123 Main St',
    city='City',
    state='ST',
    country='Country',
    postal_code='00000',
    transaction_id='unique_transaction_id',
    custom_fields={'Custom1': 'value1', 'Custom2': 'value2'}  # Optional
)

payment = Payment(skipcash)

try:
    response = payment.create_payment(payment_info)
    print(f"Payment ID: {response.id}")
    print(f"Payment URL: {response.pay_url}")
except PaymentInfoError as e:
    print(f"Error: {e}")
except PaymentValidationError as e:
    print(f"Validation Error: {e}")
except PaymentResponseError as e:
    print(f"Response Error: {e}")

Retrieving a Payment

To retrieve payment details using a payment ID:

from skipcash.client import SkipCash
from skipcash.exceptions import PaymentRetrievalError, PaymentResponseError
from skipcash.api_resources import Payment

skipcash = SkipCash(
    client_id='<your_client_id>',
    key_id='<your_client_key_id>',
    key_secret='<your_client_secret_key>',
    webhook_secret='<your_webhook_secret_key>',
    use_sandbox=True  # Set to False when moving to production
)
payment = Payment(skipcash)
try:
    response = payment.get_payment('<payment_id>')
    print(f"Payment ID: {response.id}")
    print(f"Payment Status: {response.status}")
except PaymentRetrievalError as e:
    print(f"Retrieval Error: {e}")
except PaymentResponseError as e:
    print(f"Response Error: {e}")

Handling Webhooks

To validate and process webhook events:

from skipcash.client import SkipCash
from skipcash.api_resources import Webhook
from skipcash.exceptions import WebhookValidationError, WebhookSignatureError

request_data = {}  # Your webhook payload here
signature = ''  # Signature from the 'HTTP_AUTHORIZATION' header
skipcash = SkipCash(
    client_id='<your_client_id>',
    key_id='<your_client_key_id>',
    key_secret='<your_client_secret_key>',
    webhook_secret='<your_webhook_secret_key>',
    use_sandbox=True  # Set to False when moving to production
)
webhook = Webhook(client=skipcash)

try:
    webhook.validate(payload=request_data, signature=signature)
    webhook_response = webhook.process_event(request_data)
    print(f"Payment ID: {webhook_response.payment_id}")
    print(f"Payment Status: {webhook_response.status}")
except WebhookValidationError as e:
    print(f"Webhook Validation Error: {e}")
except WebhookSignatureError as e:
    print(f"Webhook Signature Error: {e}")

Error Handling

The SDK raises specific exceptions to help you handle errors gracefully. These exceptions include PaymentResponseError, PaymentValidationError, PaymentInfoError, PaymentRetrievalError, WebhookValidationError, and WebhookSignatureError.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skipcash-0.0.4.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

skipcash-0.0.4-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file skipcash-0.0.4.tar.gz.

File metadata

  • Download URL: skipcash-0.0.4.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for skipcash-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a04e2cf1d398ee8b3765355ac25c8f0b10f73774edc54365a4c7475cad8e6c6f
MD5 fb0d19b675c8dded8dbdac26255837c5
BLAKE2b-256 225021c3846aa3d7ce88b0dea94797ea51058f3e6ff7be66134006ce0a704988

See more details on using hashes here.

File details

Details for the file skipcash-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: skipcash-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for skipcash-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7f9e6b72c3582180047f5b5d49a02c14a51e51a6724c931d17cbd6214fc2cbc1
MD5 a9f993c6a9374eee0d809de88e6bc7b1
BLAKE2b-256 0477e82152969cf750df098ff548f89a2ae4c6848b45799db99eacbb9532f59a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page