Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cloudpayments/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import requests
from requests.auth import HTTPBasicAuth

from .enums import CultureName
from .errors import CloudPaymentsError, PaymentError
from .models import Transaction, Secure3d, Subscription, Order, Receipt
from .utils import format_datetime, format_date
Expand All @@ -11,13 +12,17 @@
class CloudPayments(object):
URL = 'https://api.cloudpayments.ru/'

def __init__(self, public_id, api_secret):
def __init__(self, public_id, api_secret, language=CultureName.RU_RU):
self.public_id = public_id
self.api_secret = api_secret
self.language = language

def _send_request(self, endpoint, params=None, headers=None):
params = params or {}
params.update({'CultureName': self.language})

auth = HTTPBasicAuth(self.public_id, self.api_secret)
response = requests.post(self.URL + endpoint, json=params, auth=auth,
response = requests.post(self.URL + endpoint, json=params, auth=auth,
headers=headers)
return response.json(parse_float=decimal.Decimal)

Expand Down
10 changes: 10 additions & 0 deletions cloudpayments/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ class CultureInfo(object):
EN_US = 'en-US'


class CultureName(object):
RU_RU = 'ru-RU'
EN_US = 'en-US'
LV = 'lv'
AZ = 'az'
KK = 'kk'
UK = 'uk'
PL = 'pl'


class ReceiptType(object):
INCOME = 'Income'
INCOME_RETURN = 'IncomeReturn'
Expand Down