Provider backends
These are the payment provider backend implementations included in this
package. Note that you should not usually instantiate these yourself, but use
provider_factory()
instead.
Dummy
- class payments.dummy.DummyProvider(capture=True)
Dummy payment provider.
This is a dummy backend suitable for testing your store without contacting any payment gateways. Instead of using an external service it will simply show you a form that allows you to confirm or reject the payment.
You should only use this in development or in test servers.
Example:
PAYMENT_VARIANTS = {
'dummy': ('payments.dummy.DummyProvider', {})
}
Braintree
- class payments.braintree.BraintreeProvider(merchant_id, public_key, private_key, sandbox=True, **kwargs)
Payment provider for Braintree.
This backend implements payments using Braintree.
This backend does not support fraud detection.
- Parameters:
merchant_id – Merchant ID assigned by Braintree
public_key – Public key assigned by Braintree
private_key – Private key assigned by Braintree
sandbox – Whether to use a sandbox environment for testing
Example:
# use sandbox
PAYMENT_VARIANTS = {
'braintree': (
'payments.braintree.BraintreeProvider',
{
'merchant_id': '112233445566',
'public_key': '1234567890abcdef',
'private_key': 'abcdef123456',
'sandbox': True,
}
)
}
Coinbase
- class payments.coinbase.CoinbaseProvider(key, secret, endpoint='sandbox.coinbase.com', **kwargs)
Payment provider for coinbase.
This backend implements payments using Coinbase.
This backend does not support fraud detection.
- Parameters:
key – Api key generated by Coinbase
secret – Api secret generated by Coinbase
endpoint – Coinbase endpoint domain to use. For the production environment, use
'coinbase.com'
instead
- __init__(key, secret, endpoint='sandbox.coinbase.com', **kwargs)
Create a new provider instance.
This method should not be called directly; use
provider_factory()
instead.
Example:
# use sandbox
PAYMENT_VARIANTS = {
'coinbase': (
'payments.coinbase.CoinbaseProvider',
{
'key': '123abcd',
'secret': 'abcd1234',
'endpoint': 'sandbox.coinbase.com',
}
)
}
Cybersource
- class payments.cybersource.CyberSourceProvider(merchant_id, password, org_id=None, fingerprint_url='https://h.online-metrix.net/fp/', sandbox=True, capture=True)
Payment provider for CyberSource
This backend implements payments using Cybersource.
This backend supports fraud detection.
- Parameters:
merchant_id – Your Merchant ID
password – Generated transaction security key for the SOAP toolkit
org_id – Provide this parameter to enable Cybersource Device Fingerprinting
fingerprint_url – Address of the fingerprint server
sandbox – Whether to use a sandbox environment for testing
capture – Whether to capture the payment automatically. See Authorization and capture for more details.
Example:
# use sandbox
PAYMENT_VARIANTS = {
'cybersource': (
'payments.cybersource.CyberSourceProvider',
{
'merchant_id': 'example',
'password': '1234567890abcdef',
'capture': False,
'sandbox': True,
}
)
}
Merchant-Defined Data
Cybersource allows you to pass Merchant-Defined Data, which is additional information
about the payment or the order, such as an order number, additional customer
information, or a special comment or request from the customer. This can be
accomplished by passing your data to the Payment
instance:
>>> payment.attrs.merchant_defined_data = {'01': 'foo', '02': 'bar'}
Fingerprinting:
Cybersource allows you to pass a fingerprint data to help identify fraud
>>> payment.attrs.fingerprint_session_id
Dotpay
- class payments.dotpay.DotpayProvider(seller_id, pin, endpoint='https://ssl.dotpay.pl/test_payment/', channel=0, channel_groups=None, ignore_last_payment_channel=False, lang='pl', lock=False, type=2, **kwargs)
Payment provider for dotpay.pl
This backend implements payments using a popular Polish gateway, Dotpay.pl.
Due to API limitations there is no support for transferring purchased items.
This backend does not support fraud detection.
- Parameters:
seller_id – Seller ID assigned by Dotpay
pin – PIN assigned by Dotpay
channel – Default payment channel (consult reference guide). Ignored if channel_groups is set.
channel_groups – Payment channels to choose from (consult reference guide). Overrides channel.
lang – UI language
lock – Whether to disable channels other than the default selected above
endpoint – The API endpoint to use. For the production environment, use
'https://ssl.dotpay.pl/'
insteadignore_last_payment_channel – Display default channel or channel groups instead of last used channel.
type – Determines what should be displayed after payment is completed (consult reference guide).
Example:
# use defaults for channel and lang but lock available channels
PAYMENT_VARIANTS = {
'dotpay': (
'payments.dotpay.DotpayProvider',
{
'seller_id': '123',
'pin': '0000',
'lock': True,
'endpoint': 'https://ssl.dotpay.pl/test_payment/',
}
)
}
PayPal
- class payments.paypal.PaypalProvider(client_id, secret, endpoint='https://api.sandbox.paypal.com', capture=True)
Payment provider for Paypal, redirection-based.
This backend implements payments using PayPal.com.
- Parameters:
client_id – Client ID assigned by PayPal or your email address
secret – Secret assigned by PayPal
endpoint – The API endpoint to use. For the production environment, use
'https://api.paypal.com'
insteadcapture – Whether to capture the payment automatically. See Authorization and capture for more details.
Example:
# use sandbox
PAYMENT_VARIANTS = {
'paypal': (
'payments.paypal.PaypalProvider',
{
'client_id': 'user@example.com',
'secret': 'iseedeadpeople',
'endpoint': 'https://api.sandbox.paypal.com',
'capture': False,
}
)
}
- class payments.paypal.PaypalCardProvider(client_id, secret, endpoint='https://api.sandbox.paypal.com', capture=True)
Payment provider for Paypal, form-based.
This backend implements payments using PayPal.com but the credit card data is collected by your site.
Parameters are the same as
PaypalProvider
.This backend does not support fraud detection.
Example:
PAYMENT_VARIANTS = {
'paypal': (
'payments.paypal.PaypalCardProvider',
{
'client_id': 'user@example.com',
'secret': 'iseedeadpeople',
}
)
}
Sage Pay
- class payments.sagepay.SagepayProvider(vendor, encryption_key, endpoint='https://test.sagepay.com/Simulator/VSPFormGateway.asp', **kwargs)
Payment provider for sagepay.com
This backend implements payments using SagePay.com Form API.
This backend does not support fraud detection. Purchased items are not currently transferred.
- Parameters:
vendor – Your vendor code
encryption_key – Encryption key assigned by Sage Pay
endpoint – The API endpoint to use. For the production environment, use
'https://live.sagepay.com/gateway/service/vspform-register.vsp'
instead
Example:
# use simulator
PAYMENT_VARIANTS = {
'sage': (
'payments.sagepay.SagepayProvider',
{
'vendor': 'example',
'encryption_key': '1234567890abcdef',
'endpoint': 'https://test.sagepay.com/Simulator/VSPFormGateway.asp',
}
)
}
Sofort / Klarna
- class payments.sofort.SofortProvider(key, id, project_id, endpoint='https://api.sofort.com/api/xml', **kwargs)
Payment provider for Sofort.
This backend implements payments using sofort.com API.
This backend does not support fraud detection.
- Parameters:
key – Your secret key
id – Your sofort.com user id
project_id – Your sofort.com project id
endpoint – The API endpoint to use.
Example:
PAYMENT_VARIANTS = {
'sage': (
'payments.sofort.SofortProvider',
{
'id': '123456',
'key': '1234567890abcdef',
'project_id': '654321',
'endpoint': 'https://api.sofort.com/api/xml',
}
)
}
Stripe
- class payments.stripe.StripeProvider(public_key, secret_key, image='', name='', **kwargs)
Provider backend using Stripe.
This backend does not support fraud detection.
- Parameters:
secret_key – Secret key assigned by Stripe.
public_key – Public key assigned by Stripe.
name – A friendly name for your store.
image – Your logo.
Example:
# use sandbox
PAYMENT_VARIANTS = {
'stripe': (
'payments.stripe.StripeProvider',
{
'secret_key': 'sk_test_123456',
'public_key': 'pk_test_123456',
}
)
}
- class payments.stripe.StripeCardProvider(public_key, secret_key, image='', name='', **kwargs)
Provider backend using Stripe, form-based.
This backend implements payments using Stripe but the credit card data is collected by your site.
Parameters are the same as
StripeProvider
.
MercadoPago
- class payments.mercadopago.MercadoPagoProvider(access_token: str, sandbox: bool)
This backend implements payments using MercadoPago.
You’ll need to install with extra dependencies to use this:
pip install "django-payments[mercadopago]"
- Parameters:
access_token – The access token provided by MP.
sandbox – Whether to use sandbox more.
Example:
PAYMENT_VARIANTS: = {
"mercadopago": (
"payments.mercadopago.MercadoPagoProvider",
{
"access_token": "APP_USR-3453454363464444-645434-7f8da79f8da7f98ad7f98ad7f98df78e-454545466",
"sandbox": DEBUG,
},
),
}
Note that the API sandbox does not return Payment details, so all payments will seem unpaid.