Skip to main content

Wipöp API Client

Project description

Wipop Python Client

PyPI version Python

A modern Python client library for the Wipop payment processing API with full type safety and comprehensive error handling.

Features

  • Card Charge Operations
    • Payment link generation
    • Refunds
    • Pre-authorization creation
    • Pre-authorization confirmation
    • Pre-authorization reversal
    • Token generation
    • One-click charges
    • Recurring charges
  • Bizum Charge Operations
    • Payment link creation
    • Refunds
  • Checkout Operations
    • Payment link generation
    • Payment button

Installation

# pip
pip install wipop-client

# poetry
poetry add wipop-client

# pipenv
pipenv install wipop-client

Before Getting Started

  • Have completed the identification process during the Wipöp payment gateway contracting.
  • Access the control panel in test mode (sandbox) from your account.
  • Clearly define which method you will use to perform the integration in your system:

Required credentials:

  • Merchant ID
  • Secret API Key
  • Terminal ID (default is 1 in sandbox)

Quick Start

from wipop_client import (
    WipopClient,
    WipopClientConfiguration,
    WipopEnvironment,
    CreateChargeParams,
    ChargeMethod,
    Currency,
    OriginChannel,
    ProductType
)

# Initialize client
config = WipopClientConfiguration(
    location=WipopEnvironment.SANDBOX,
    merchant_id='your-merchant-id',
    secret_key='your-secret-key'
)
client = WipopClient(config)

# Create a charge
charge = client.charge_operation().create(
    CreateChargeParams(
        method=ChargeMethod.CARD,
        origin_channel=OriginChannel.API,
        amount=100.00,
        currency=Currency.EUR,
        description='Payment for order #123',
        order_id='1234a1B2c3D4',
        product_type=ProductType.PAYMENT_LINK,
        terminal={'id': '1'}
    )
)

API Reference

Configuration

Basic Configuration

config = WipopClientConfiguration(
    location=WipopEnvironment.SANDBOX,  # WipopEnvironment.PRODUCTION for live
    merchant_id='your-merchant-id',
    secret_key='your-secret-key'
)

Advanced Configuration

from wipop_client import WipopClientHttpConfiguration

http_config = WipopClientHttpConfiguration(
    timeout=30  # request timeout (seconds)
)

config = WipopClientConfiguration(
    location=WipopEnvironment.SANDBOX,
    merchant_id='merchant-id',
    secret_key='secret-key',
    http_configuration=http_config
)

Custom Environment

config = WipopClientConfiguration(
    location='https://custom-api.wipop.es',
    merchant_id='merchant-id',
    secret_key='secret-key'
)

Charge Operations

Create Card Charge

card_charge = client.charge_operation().create(
    CreateChargeParams(
        method=ChargeMethod.CARD,
        origin_channel=OriginChannel.API,
        product_type=ProductType.PAYMENT_LINK,
        amount=31.00,
        currency=Currency.EUR,
        description='Test redirection payment link',
        order_id='1234a1B2c3D4',
        redirect_url='https://example.com',
        send_email=True,
        language='es-ES',
        terminal={'id': '1'}
    )
)

Create Bizum Charge

bizum_charge = client.charge_operation().create(
    CreateChargeParams(
        method=ChargeMethod.BIZUM,
        origin_channel=OriginChannel.API,
        product_type=ProductType.PAYMENT_LINK,
        amount=20.00,
        currency=Currency.EUR,
        description='Checkout charge link bizum',
        order_id='1234a1B2c3D4',
        redirect_url='https://example.com',
        send_email=True,
        language='es-ES',
        terminal={'id': '1'}
    )
)

Create Customer Charge

customer_charge = client.charge_operation().create_customer_charge(
    'customer-id',
    CreateChargeParams(
        method=ChargeMethod.CARD,
        origin_channel=OriginChannel.API,
        amount=75.00,
        currency=Currency.EUR,
        description='Customer payment',
        order_id='1234a1B2c3D4',
        product_type=ProductType.PAYMENT_LINK,
        terminal={'id': '1'}
    )
)

Confirm Charge

from wipop_client import ConfirmChargeParams

confirmed_charge = client.charge_operation().confirm(
    't00000000000000000000',
    ConfirmChargeParams(token_id='k000000000000000000')
)

Refund Charge

from wipop_client import RefundParams

refunded_charge = client.charge_operation().refund(
    't00000000000000000000',
    RefundParams(amount=25.00)
)

Reverse Charge

from wipop_client import ReversalParams

reversed_charge = client.charge_operation().reversal(
    't00000000000000000000',
    ReversalParams(description='Transaction reversal')
)

Capture Charge

from wipop_client import CaptureParams

captured_charge = client.charge_operation().capture(
    't00000000000000000000',
    CaptureParams(amount=100.00)
)

Checkout Operations

Create Checkout

from wipop_client import CheckoutParams

checkout = client.checkout_operation().create_checkout(
    CheckoutParams(
        amount=10.00,
        currency=Currency.EUR,
        description='Checkout test payment gateway',
        redirect_url='https://www.example.com',
        order_id='1234a1B2c3D4',
        origin_channel=OriginChannel.API,
        product_type=ProductType.PAYMENT_GATEWAY,
        expiration_date='2025-10-29 12:50',
        language='es-ES',
        terminal={'id': '1'}
    )
)

print(f'Checkout URL: {checkout.checkout_url}')

Create Customer Checkout

customer_checkout = client.checkout_operation().create_customer_checkout(
    'customer-id',
    CheckoutParams(
        origin_channel=OriginChannel.API,
        amount=100.00,
        currency=Currency.EUR,
        description='Customer checkout',
        order_id='1234a1B2c3D4',
        product_type=ProductType.PAYMENT_LINK
    )
)

Language Support

The library includes support for internationalization with the Language class:

from wipop_client import Language

# Create language instances
spanish = Language('es', 'ES')  # Spanish (Spain)
english = Language('en', 'US')  # English (United States)
french = Language('fr', 'FR')   # French (France)

# Use in checkout parameters
checkout = CheckoutParams(
    origin_channel=OriginChannel.API,
    amount=100.00,
    description='Product purchase',
    order_id='1234a1B2c3D4',
    language=spanish,
    product_type=ProductType.PAYMENT_LINK
)

# Use in charge parameters
charge = CreateChargeParams(
    method=ChargeMethod.CARD,
    origin_channel=OriginChannel.API,
    amount=100.00,
    order_id='1234a1B2c3D4',
    language=english,
    product_type=ProductType.PAYMENT_LINK
)

Supported Payment Methods

  • CARD - Credit and debit card payments
  • BIZUM - Spanish mobile payment system

Supported Currencies

  • EUR - Euro
  • Additional currencies as supported by the Wipop API

Transaction Status

The client uses the TransactionStatus enum for type-safe status handling:

  • CHARGE_PENDING - Charge is pending processing
  • COMPLETED - Transaction completed successfully
  • ERROR - Transaction failed with error
  • FAILED - Transaction failed
  • IN_PROGRESS - Transaction is being processed

Error Handling

from wipop_client import WipopClientError

try:
    charge = client.charge_operation().create(charge_params)
except WipopClientError as error:
    print(f'Wipop API Error: {error.message}')
    
    if error.response_code:
        print(f'Error Code: {error.response_code.code}')
        print(f'Error Message: {error.response_code.message}')
        print(f'Error Level: {error.response_code.level}')
except Exception as error:
    print(f'Unexpected error: {error}')

Development

Prerequisites

  • Python 3.8+
  • Poetry (recommended) or pip

Scripts

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=wipop_client

# Run tests in watch mode
poetry run ptw

# Format code
poetry run black wipop_client tests

# Check formatting
poetry run black --check wipop_client tests

# Type checking
poetry run mypy wipop_client

# Linting
poetry run flake8 wipop_client tests

Testing

The project uses pytest for testing with comprehensive test coverage:

# Run all tests
poetry run pytest

# Run specific test module
poetry run pytest tests/test_charge.py

# Generate coverage report
poetry run pytest --cov=wipop_client --cov-report=html

Support

For support and questions, please contact the support team or create an issue in the project repository.

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

wipop_client-0.0.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wipop_client-0.0.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file wipop_client-0.0.1.tar.gz.

File metadata

  • Download URL: wipop_client-0.0.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Linux/5.10.228-219.884.amzn2.x86_64

File hashes

Hashes for wipop_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 50e0ed9efd52f50166d42ccb4b270858ec0d6cdea58ebf04e64ca5d8b23a2f2a
MD5 0a07107cfa2b89eb372946081e60eb87
BLAKE2b-256 37ec78469e4c52c7e025941abad007e0d28fd8880caac9e7c88eab19a8e4726b

See more details on using hashes here.

File details

Details for the file wipop_client-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: wipop_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Linux/5.10.228-219.884.amzn2.x86_64

File hashes

Hashes for wipop_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac4763f6408cc0ad9a6605a744caea1be8e2d93098e863fda5fedcb13f30b235
MD5 90ad1fc14e005e466b9d37cd466b69e3
BLAKE2b-256 bf4a954714db297b36c4cc202439b40a5a32fc263077e459c177293484a44836

See more details on using hashes here.

Supported by

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