From a377ec9900fd3f2d56d28a800f87e8ea20f5ea06 Mon Sep 17 00:00:00 2001 From: Aleksandar Yalnazov Date: Tue, 17 Nov 2015 10:04:42 +0200 Subject: [PATCH 1/2] Some field descriptions fixed. --- paymill/services/checksum_service.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/paymill/services/checksum_service.py b/paymill/services/checksum_service.py index 1cc5252..2dd8de4 100644 --- a/paymill/services/checksum_service.py +++ b/paymill/services/checksum_service.py @@ -19,16 +19,15 @@ def create(self, checksum_type, amount, currency, return_url, cancel_url, descri fee_amount=None, fee_payment=None, fee_currency=None, checkout_options=None, require_reusable_payment=None, reusable_payment_description=None, items=None, shipping_address=None, billing_address=None, app_id=None): """Creates new transaction/payment Checksum - :param str checksum_type : Type of request verified by this checksum + :param str checksum_type: Type of request verified by this checksum :param int amount: Amount (in cents) which will be charged :param str currency: ISO 4217 formatted currency code - :param str return_url: The identifier of a client - :param int cancel_url: Fee included in the transaction amount (set by a connected app). + :param str return_url: URL to redirect customers to after checkout has completed. + :param int cancel_url: URL to redirect customers to after they have canceled the checkout. :param str description: A short description for the transaction - :param str checksum_action: The identifier of the payment from which the fee will be charged + :param str checksum_action: enum(transaction, payment) or null_ Requested action verified by this checksum (default: transaction) :param int fee_amount: Fee included in the transaction amount (set by a connected app). Mandatory if fee_payment is set. :param str fee_payment: The identifier of the payment from which the fee will be charged (Payment object). - :param str fee_currency: The currency of the fee (e.g. EUR, USD). If it´s not set, the currency of the transaction is used. We suggest to always use as it might cause problems, if your account does not support the same currencies as your merchants accounts. :param list checkout_options: Various options that determine behavior before/during/after checkout such as editability of address fields. @@ -36,7 +35,7 @@ def create(self, checksum_type, amount, currency, return_url, cancel_url, descri If the buyer accepts, the resulting payment can be reused for transactions and subscriptions without additional interaction. :param str reusable_payment_description: Description appears at the acquirers checkout page (e.g. PayPal) when you request permission for a reusable payment, max. 127 characters. :param list of ShoppingCartItem items: Shopping cart items purchased with this transaction. - :param Address shipping_address: Billing address for this transaction. + :param Address shipping_address: Shipping address for this transaction. :param Address billing_address: Billing address for this transaction. :params str app_id: App (ID) that created this payment or null if created by yourself. :return Checksum: the created Checksum object From e3bb4583ad175d4b33acbf0aa29126e402a3c06f Mon Sep 17 00:00:00 2001 From: Aleksandar Yalnazov Date: Wed, 18 Nov 2015 17:05:38 +0200 Subject: [PATCH 2/2] httplib debugging not enabled by default. --- paymill/paymill_context.py | 4 ++-- paymill/utils/http_client.py | 20 +++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/paymill/paymill_context.py b/paymill/paymill_context.py index 84f5087..a182ed1 100644 --- a/paymill/paymill_context.py +++ b/paymill/paymill_context.py @@ -17,14 +17,14 @@ class PaymillContext(object): Use the getter methods in order to access the required PAYMILL service. """ - def __init__(self, api_key): + def __init__(self, api_key, http_debug_enabled=False): """ :param str api_key: your PAYMILL private key :rtype : PaymillContext """ self.api_url = 'https://api.paymill.com/v2.1' self.api_key = api_key - self.http_client = http_client.HTTPClient(self.api_url, api_key, "") + self.http_client = http_client.HTTPClient(self.api_url, api_key, "", http_debug_enabled) self.client_service = client_service.ClientService(self.http_client) self.offer_service = offer_service.OfferService(self.http_client) self.payment_service = payment_service.PaymentService(self.http_client) diff --git a/paymill/utils/http_client.py b/paymill/utils/http_client.py index 2e6834a..cf941ae 100644 --- a/paymill/utils/http_client.py +++ b/paymill/utils/http_client.py @@ -3,22 +3,15 @@ from requests import Session from ..utils import abstract_http_client from .pm_error import PMError -import logging -# these two lines enable debugging at httplib level (requests->urllib3->httplib) -# you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA. -# the only thing missing will be the response.body which is not logged. -from six.moves import http_client -http_client.HTTPConnection.debuglevel = 1 - -logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests -logging.getLogger().setLevel(logging.INFO) -requests_log = logging.getLogger("requests.packages.urllib3") -requests_log.setLevel(logging.ERROR) -requests_log.propagate = True +def http_debug(enabled=False): + if enabled: + # these two lines enable debugging at httplib level (requests->urllib3->httplib) + from six.moves import http_client + http_client.HTTPConnection.debuglevel = 1 class HTTPClient(abstract_http_client.AbstractHTTPClient): - def __init__(self, base_url, user_name, user_pass=''): + def __init__(self, base_url, user_name, user_pass='', http_debug_enabled=False): """Initialize a new paymill interface connection. Requires a private key.""" self.base_url = base_url self.session = Session() @@ -27,6 +20,7 @@ def __init__(self, base_url, user_name, user_pass=''): self.operations = dict(GET=self.get, POST=self.post, PUT=self.put, DELETE=self.delete) #for internal usage self.response = None + http_debug(enabled=http_debug_enabled) def __call__(self, request_type, params, url, return_type): try: