web_payments package¶
Subpackages¶
Submodules¶
web_payments.forms module¶
-
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
-
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'}})>¶
-
-
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_status
(status, message='')[source]¶ Updates the Payment status and sends the status_changed signal.
-
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_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
-
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
-
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
-
extra
= None¶
-
form_class
= None¶
-
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
-
process_data
(payment, request)[source]¶ Process callback request from a payment provider. Default: return 404 if somebody tries it
-
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
web_payments.utils module¶
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'¶
-