web_payments package

Submodules

web_payments.forms module

class web_payments.forms.DateValidator(message=None)[source]

Bases: object

class web_payments.forms.CreditCardNumberValidator(message=None)[source]

Bases: object

static cart_number_checksum_validation(number)[source]
class web_payments.forms.PaymentForm(*, provider=None, payment=None, **kwargs)[source]

Bases: wtforms.form.Form

Payment form

When displaying the form remember to use action and method. use always formdata except for defaults. formdata of is different to Wtforms as it supports dicts

class Meta[source]

Bases: object

wrap_formdata(form, formdata)[source]

work around wtform implementation

action = ''
method = 'post'
payment = None
provider = None
class web_payments.forms.CreditCardPaymentForm(*, valid_types=None, **kwargs)[source]

Bases: web_payments.forms.PaymentForm

VALID_TYPES = None
cvv2 = <UnboundField(StringField, (), {'label': 'CVV2 Security Number', 'validators': [<wtforms.validators.InputRequired object>, <wtforms.validators.Regexp object>], 'description': 'Last three digits located on the back of your card. For American Express the four digits found on the front side.', 'render_kw': {'autocomplete': 'cc-csc'}})>
expiration = <UnboundField(DateField, (), {'label': 'Expiration date (MM/YYYY):', 'validators': [<wtforms.validators.InputRequired object>, <web_payments.forms.DateValidator object>], 'format': '%m/%Y', 'render_kw': {'autocomplete': 'cc-exp', 'pattern': '[0-9]{2}/[0-9]{4}'}})>
number = <UnboundField(StringField, (), {'label': 'Credit Card Number', 'validators': [<wtforms.validators.InputRequired object>, <wtforms.validators.Length object>, <web_payments.forms.CreditCardNumberValidator object>], 'render_kw': {'autocomplete': 'cc-number'}})>
validate_number(field)[source]
class web_payments.forms.CreditCardPaymentFormWithName(*, valid_types=None, **kwargs)[source]

Bases: web_payments.forms.CreditCardPaymentForm

name = <UnboundField(StringField, (), {'label': 'Name on Credit Card', 'validators': [<wtforms.validators.Length object>], 'render_kw': {'autocomplete': 'cc-name'}})>

web_payments.logic module

class web_payments.logic.BasicPayment[source]

Bases: object

Logic of a Payment object, basis for implementations

attrs

Access payment extra attributes like an object

capture(amount=None, final=True)[source]

Capture a fraction of the total amount of a payment. Return amount captured or None

captured_amount = NotImplemented

captured = current captured amount

change_fraud_status(status, message='', commit=True)[source]
change_status(status, message='')[source]

Updates the Payment status and sends the status_changed signal.

classmethod check_token_exists(token)[source]

create token for process_url

create_token()[source]
currency = NotImplemented

Currency code (may be provider-specific)

extra_data = NotImplemented

for attrs pseudo dict

fraud_message = NotImplemented

fraud message

fraud_status = NotImplemented

fraud status

get_billing_address()[source]

return billing address

get_failure_url()[source]

url where customer should be redirected if payment had an error

get_form(data=None, **kwargs)[source]
get_payment_extra()[source]

extra costs like delivery or tax (required, Decimal), defaults to zero Payment message, minimumage,… (not required, provider SHOULD not depend on it) Overwrite or extend to add functionality universal types: type: what type is the transaction (official, physical, …), VALID value can be provider dependent message: message for customer minimumage: minimum age for customer

get_process_url(extra_data=None)[source]

returns a communication url, should kept secret except if provider communication is with customer

get_provider_variant()[source]

return ProviderVariant for this payment object

get_purchased_items()[source]
get_shipping_address()[source]

return shipping address

get_success_url()[source]

url where customer should be redirected if payment was successful

classmethod list_providers(**_kwargs)[source]

returns an iterable with ProviderVariants possible keywords: name=<variantname>: extract variant, return list with one provider or [], required for static_callback

classmethod load_providers()[source]

Load all providers in cache Also useful method to check if all providers are valid

message = NotImplemented

Transaction status message

provider

returns provider object

refund(amount=None)[source]

Refund payment, return amount which was refunded

release()[source]

Annilates captured payment

save(**kwargs)[source]

save model implementation dependent

signal_status_change()[source]

Called on status change. Should send signal (see django.models for example). must to be overwritten to be useful

status = NotImplemented

Transaction status

token = NotImplemented

secret token (for get_process_url)

total = NotImplemented

Total amount (gross)

transaction_id = NotImplemented

Transaction ID (if applicable)

variant = NotImplemented

select payment provider

class web_payments.logic.BasicProvider(capture=True, time_reserve=datetime.timedelta(0))[source]

Bases: object

This class defines the backend provider API. It should not be instantiated directly. Use BasicPayment methods instead.

Parameters:
  • capture (bool) – automatic capture of payments, False not supported by all backends
  • time_reserve (timedelta) – minimum time left to expire until a new token is requested, defaults to zero
capture(payment, amount=None, final=True)[source]

Capture a fraction of the total amount of a payment. Return amount captured or None

clear_token_cache()[source]

clear token cache

extra = None
form_class = None
get_action(payment)[source]
get_auth_token(now)[source]

Takes now, a datetime object with timezone utc, as argument

Must return (authentication token, datetime when it will expire)

datetime can be now to disable caching

get_form(payment, data=None, **kwargs)[source]

Converts payment into a form

get_token_from_request(payment, request)[source]

Return payment token from provider request.

process_data(payment, request)[source]

Process callback request from a payment provider. Default: return 404 if somebody tries it

refund(payment, amount=None)[source]

Refund payment, return amount which was refunded

release(payment)[source]

Annilates captured payment

token

Access to authentication token

web_payments.status module

web_payments.testcommon module

web_payments.testcommon.create_test_payment(PAYMENT_VARIANTS_API={'DirectPaymentProvider': ('web_payments_externalpayments.DirectPaymentProvider', {}, {}), 'DummyProvider': ('web_payments_dummy.DummyProvider', {}, {'test_var': 'test'}), 'default': ('web_payments_dummy.DummyProvider', {}, {}), 'iban': ('web_payments_externalpayments.BankTransferProvider', {'iban': 'GL5604449876543210', 'bic': 'DABAIE2D'}, {'localized_name': 'iban'})}, **attributes)[source]

web_payments.translation module

web_payments.translation.set_language(language)[source]

Set language. Default implementation can be overwritten. Note: if get_language is overwritten this method should be also overwritten or not used Note: loading with django overwrites this method if not initialized

Parameters:language (str) – language to set to
web_payments.translation.get_language()[source]

Get language. For translations. Default implementation can be overwritten. Note: if set_language is overwritten this method should be also overwritten Note: loading with django overwrites this method if not initialized

class web_payments.translation.Translation(instance_path, translation_path, domain='web_payments', fallback=None)[source]

Bases: object

domain = None
fallback = None
gettext(msg, cur_lang=None)[source]
gettext_lazy(msg, cur_lang=None)[source]
instance_path = None
ngettext(msg, msgplural, n, cur_lang=None)[source]
ngettext_lazy(msg, msgplural, n, cur_lang=None)[source]
trans(cur_lang=None)[source]
translation_path = None

web_payments.utils module

web_payments.utils.split_streetnr(address, fallback=None)[source]
web_payments.utils.getter_prefixed_address(prefix)[source]

create getter for prefixed address format

web_payments.utils.get_credit_card_issuer(number)[source]

Module contents

class web_payments.PurchasedItem(name, quantity, price, currency, sku)

Bases: tuple

currency

Alias for field number 3

name

Alias for field number 0

price

Alias for field number 2

quantity

Alias for field number 1

sku

Alias for field number 4

class web_payments.HttpRequest(method, GET, POST, content_type)

Bases: tuple

GET

Alias for field number 1

POST

Alias for field number 2

content_type

Alias for field number 3

method

Alias for field number 0

class web_payments.PaymentStatus[source]

Bases: object

CHOICES = [('waiting', 'Waiting for confirmation'), ('preauth', 'Pre-authorized'), ('confirmed', 'Confirmed'), ('rejected', 'Rejected'), ('refunded', 'Refunded'), ('error', 'Error'), ('input', 'Input')]
CONFIRMED = 'confirmed'
ERROR = 'error'
INPUT = 'input'
PREAUTH = 'preauth'
REFUNDED = 'refunded'
REJECTED = 'rejected'
WAITING = 'waiting'
class web_payments.FraudStatus[source]

Bases: object

ACCEPT = 'accept'
CHOICES = [('unknown', 'Unknown'), ('accept', 'Passed'), ('reject', 'Rejected'), ('review', 'Review')]
REJECT = 'reject'
REVIEW = 'review'
UNKNOWN = 'unknown'
exception web_payments.RedirectNeeded[source]

Bases: Exception

exception web_payments.ExternalPostNeeded[source]

Bases: Exception

exception web_payments.PaymentError(message, code=None, gateway_message=None)[source]

Bases: Exception

exception web_payments.NotInitialized[source]

Bases: NotImplementedError

exception web_payments.NotSupported[source]

Bases: Exception

web_payments.provider_factory(variant)[source]

Return the provider instance based on ProviderVariant