Package: skipcash
SkipCash SDK for PythonThe 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.FeaturesCreate payments with various customization options.Retrieve payment information using payment IDs.Validate and process webhook events securely.Handle various exceptions and errors gracefully.Getting StartedPrerequisitesPython 3.xAn active SkipCash account with access to API credentials.InstallationCurrently, this SDK is provided as a Python module. Include it in your project by copying the SDK files to your project directory.ConfigurationTo use the SDK, you'll need your SkipCash API credentials. Initialize theSkipCashclient with your credentials:fromskipcash.clientimportSkipCashskipcash=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)UsageCreating a PaymentTo create a payment, you need to preparePaymentInfowith the necessary details:fromdecimalimportDecimalfromskipcash.api_resourcesimportPaymentfromskipcash.schemaimportPaymentInfofromskipcash.exceptionsimportPaymentResponseError,PaymentValidationError,PaymentInfoErrorfromskipcash.clientimportSkipCashskipcash=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}")exceptPaymentInfoErrorase:print(f"Error:{e}")exceptPaymentValidationErrorase:print(f"Validation Error:{e}")exceptPaymentResponseErrorase:print(f"Response Error:{e}")Retrieving a PaymentTo retrieve payment details using a payment ID:fromskipcash.clientimportSkipCashfromskipcash.exceptionsimportPaymentRetrievalError,PaymentResponseErrorfromskipcash.api_resourcesimportPaymentskipcash=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}")exceptPaymentRetrievalErrorase:print(f"Retrieval Error:{e}")exceptPaymentResponseErrorase:print(f"Response Error:{e}")Handling WebhooksTo validate and process webhook events:fromskipcash.clientimportSkipCashfromskipcash.api_resourcesimportWebhookfromskipcash.exceptionsimportWebhookValidationError,WebhookSignatureErrorrequest_data={}# Your webhook payload heresignature=''# Signature from the 'HTTP_AUTHORIZATION' headerskipcash=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}")exceptWebhookValidationErrorase:print(f"Webhook Validation Error:{e}")exceptWebhookSignatureErrorase:print(f"Webhook Signature Error:{e}")Error HandlingThe SDK raises specific exceptions to help you handle errors gracefully. These exceptions includePaymentResponseError,PaymentValidationError,PaymentInfoError,PaymentRetrievalError,WebhookValidationError, andWebhookSignatureError.