Ejemplo n.º 1
0
def test_paddle_api_key_not_set(unset_api_key):
    with pytest.raises(ValueError):
        PaddleClient(vendor_id=1)
    try:
        PaddleClient(vendor_id=1)
    except ValueError as error:
        assert str(error) == 'API key not set'
Ejemplo n.º 2
0
def test_paddle_vendor_id_not_set(unset_vendor_id):
    with pytest.raises(ValueError):
        PaddleClient(api_key='test')
    try:
        PaddleClient(api_key='test')
    except ValueError as error:
        assert str(error) == 'Vendor ID not set'
Ejemplo n.º 3
0
def test_paddle_vendor_id_not_int(set_vendor_id_to_invalid):
    with pytest.raises(ValueError):
        PaddleClient(api_key='test')
    try:
        PaddleClient(api_key='test')
    except ValueError as error:
        assert str(error) == 'Vendor ID must be a number'
Ejemplo n.º 4
0
def test_paddle__manual_vendor_id_and_api_key(unset_vendor_id, unset_api_key):
    with pytest.raises(ValueError):
        PaddleClient(api_key='test')
    try:
        PaddleClient(api_key='test')
    except ValueError as error:
        assert str(error) == 'Vendor ID not set'
Ejemplo n.º 5
0
def test_init_ignore_env_vars(set_vendor_id, set_api_key, set_sandbox):
    vendor_id = 9999
    api_key = 'not-env-var'
    sandbox = False
    client = PaddleClient(
        vendor_id=vendor_id,
        api_key=api_key,
        sandbox=sandbox,
    )
    assert client.vendor_id == vendor_id
    assert client.api_key == api_key
    assert client.sandbox == sandbox
Ejemplo n.º 6
0
def paddle_client():
    """
    Paddle client details are for the [email protected] sandbox
    account. If these details do not work or you require access to this
    account please raise a GitHub issue.
    """
    paddle = PaddleClient(
        vendor_id=1468,
        api_key="2ab9a716510da54fefa9b708b0e5b94f8145dcd8ba983bfab3",
        sandbox=True,
    )
    return paddle
Ejemplo n.º 7
0
def paddle_client():
    paddle = PaddleClient()
    return paddle
Ejemplo n.º 8
0
def test_api_key_not_set(unset_vendor_id, unset_api_key):
    with pytest.raises(ValueError) as error:
        PaddleClient(vendor_id=1)
    error.match('API key not set')
Ejemplo n.º 9
0
def test_vendor_id_not_int(set_vendor_id_to_invalid):
    with pytest.raises(ValueError) as error:
        PaddleClient(api_key='test')
    error.match('Vendor ID must be a number')
Ejemplo n.º 10
0
def test_vendor_id_not_set(unset_vendor_id, unset_api_key):
    with pytest.raises(ValueError) as error:
        PaddleClient(api_key='test')
    error.match('Vendor ID not set')
Ejemplo n.º 11
0
def test_sandbox_env_var(set_sandbox):
    client = PaddleClient(vendor_id=1, api_key='test')
    assert client.sandbox is True
Ejemplo n.º 12
0
def test_api_key_env_var(set_api_key):
    client = PaddleClient(vendor_id=1)
    assert client.api_key == os.environ['PADDLE_API_KEY']
Ejemplo n.º 13
0
def test_vendor_id_env_var(set_vendor_id):
    client = PaddleClient(api_key='test')
    assert client.vendor_id == int(os.environ['PADDLE_VENDOR_ID'])
Ejemplo n.º 14
0
def test_get_user_history_with_vendor_id(unset_vendor_id):  # NOQA: F811
    email = '*****@*****.**'
    vendor_id = 11
    paddle = PaddleClient(vendor_id=vendor_id)
    response = paddle.get_user_history(email=email, vendor_id=vendor_id)
    assert response == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.'  # NOQA: E501
Ejemplo n.º 15
0
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from paddle import PaddleClient

from . import settings, signals
from .fields import PaddleCurrencyCodeField
from .utils import PADDLE_DATETIME_FORMAT

log = logging.getLogger("djpaddle")

paddle_client = PaddleClient(
    vendor_id=settings.DJPADDLE_VENDOR_ID, api_key=settings.DJPADDLE_API_KEY
)


class PaddleBaseModel(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class Plan(PaddleBaseModel):
    """
    'Plan' represents a Paddle subscription plan.
    """
Ejemplo n.º 16
0
from django.conf import settings as djsettings
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from paddle import PaddleClient

from . import settings, signals, mappers
from .fields import PaddleCurrencyCodeField
from .utils import PADDLE_DATETIME_FORMAT, PADDLE_DATE_FORMAT

log = logging.getLogger("djpaddle")

paddle_client = PaddleClient(
    vendor_id=settings.DJPADDLE_VENDOR_ID,
    api_key=settings.DJPADDLE_API_KEY,
    sandbox=settings.DJPADDLE_SANDBOX,
)


class PaddleBaseModel(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class Plan(PaddleBaseModel):
    """
    'Plan' represents a Paddle subscription plan.