Giter VIP home page Giter VIP logo

gocardless-pro-python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gocardless-pro-python's Issues

Invalid API usage error

When I test my gocardless integration using sandbox on my localhost, I have no issue processing the customer with the success redirect url: "http://localhost:8000/subscription/index". However when I use https it returns 'connection refused' with no error. And when I attempt to add the live key with the correct domain it returns "nginx 502 bad gateway" with the following stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/custodian/custodian/blueprints/billing/views/billing.py", line 316, in cardless
    "success_redirect_url" : "https://custodian.fund/subscription/index",
  File "/usr/local/lib/python3.6/site-packages/gocardless_pro/services/redirect_flows_service.py", line 39, in create
    retry_failures=True)
  File "/usr/local/lib/python3.6/site-packages/gocardless_pro/services/base_service.py", line 29, in _perform_request
    return self._attempt_request(method, path, params, headers)
  File "/usr/local/lib/python3.6/site-packages/gocardless_pro/services/base_service.py", line 43, in _attempt_request
    return self._api_client.post(path, body=params, headers=headers)
  File "/usr/local/lib/python3.6/site-packages/gocardless_pro/api_client.py", line 70, in post
    self._handle_errors(response)
  File "/usr/local/lib/python3.6/site-packages/gocardless_pro/api_client.py", line 127, in _handle_errors
    raise exception_class(error)
gocardless_pro.errors.InvalidApiUsageError: The access token you've used is not a valid live API access token

Does anyone know why the process is working with a http address but not https? This doesn't seem to be an invalid API issue.

code error resources.MandateRequestConstraints

v1.45.0 is affcted.

https://github.com/gocardless/gocardless-pro-python/blob/62fbef3a116b8ce5ad5f174f212c10a54698107c/gocardless_pro/services/mandate_request_constraints_service.py#L16C51-L16C51

python3.10-gocardless-pro>     RESOURCE_CLASS = resources.MandateRequestConstraints
python3.10-gocardless-pro> AttributeError: module 'gocardless_pro.resources' has no attribute 'MandateRequestConstraints'

It is effectively not exported. Seems like crank didn't run or make a mistake.

Malformed response received from server

gocardless-pro 1.42.0

When I used client.payments.create(params=params), throws error:
gocardless_pro.errors.MalformedResponseError: Malformed response received from server

Everything worked fine before

Publish 0.1.3?

The commits since 0.1.2 are backwards compatible and the resource changes since represent the current API. It would be great if the changes were published so that they can be used without installing directly from the repo with pip.

Proxy support

In our integration with GoCardless we need to be able to use a proxy to communicate with the API. Currently there is no option available in the library to do so. As the library uses requests it would be great if we could specify the proxies parameter that this function accepts. Would it be possible to add support for using a proxy?

idempotency-and-retries branch

What is the status of the idempotency-and-retries branch? It looks to be functional and is a feature we'd really like to utilize. We can switch to using the github hosted package, but we'd prefer to use the pypi hosted one.

ValidationFailedError: <unprintable ValidationFailedError object> on duplicate bank_account

Trying to create the same bank account twice with client.customer_bank_accounts.create raises an unprintable ValidationFailedError:

        error = response.json()['error']
        exception_class = errors.ApiError.exception_for(error['type'])
>       raise exception_class(error)
E       ValidationFailedError: <unprintable ValidationFailedError object>

Looking at errors.py it seems that it wants to format a field key in __str__ which is not returned by the API. The actual error JSON object is:

{u'reason': u'bank_account_exists', u'message': u'Bank account already exists', u'links': {u'customer_bank_account': u'BA0000G3T3J8XC'}}

Valid datetime in request returns invalid datetime error

import gocardless_pro as gp

client = gp.Client(
    access_token=ACCESS_TOKEN,
    environment='live',
)

start = datetime.datetime(2019, 4, 10)
assert isinstance(start, datetime.datetime)

client.events.list(
    params={
        'limit': 50,
        'after': None,
        'created_at[gte]': start,
    }
)

Gives me the following error

gocardless_pro.errors.InvalidApiUsageError: One of your parameters was incorrectly typed (2019-04-10 00:00:00 is not a valid date-time.)

It is being passed a valid datetime. I have also tried passing strings, timedeltas, dates etc, with no luck.

Thanks

Malformed response when deleting a customer

I am using pip gocardless-pro 1.31.0 release. Python version 3.10.0.

The error occures when deleting a client. The client is succesfully deleted however the request then throws MalformedResponseError. I've also tried to use earlier pip versions, the result is the same. The client returns 204 which also indicates successful operation. For now I am just expecting MalformedResponseError on my tests. I am using gocardless sandbox environment for all my tests.

gocardless_pro/api_client.py
line 117:
image

Here is full test output:
image

JSONDecodeError when removing a customer

gocardless-pro==1.49.0

When I delete a customer, the delete works, but the return fails.

Traceback (most recent call last):
  File ".../lib/python3.10/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
  File ".../lib/python3.10/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
  File ".../lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
  File ".../lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".../vendors_api.py", line 129, in <module>
    client.customers.remove(identity=bank_account.links.customer)
  File ".../lib/python3.10/site-packages/gocardless_pro/services/customers_service.py", line 149, in remove
    return self._resource_for(response)
  File ".../lib/python3.10/site-packages/gocardless_pro/services/base_service.py", line 68, in _resource_for
    data = api_response.body[self._envelope_key()]
  File ".../lib/python3.10/site-packages/gocardless_pro/api_response.py", line 24, in body
    return self._response.json()
  File ".../lib/python3.10/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I checked the response I get in customers_service.py line 147 and that looks fine: status_code=204 and empty content as the docs state it should look like.

Mandate Number is None for all payments returned by client.payout_items.list

Hello,

I'm experiencing an issue where the payments returned by client.payout_items.list().records have none type for their links.mandate attribute. This is happening for all payments in all payouts within our account.

For example, a payment that I'm expecting to have a mandate of 'MD0008J11AXXXX' is None.

I can get the mandate by querying each payment using its ID. However we can have > 1000 payments per day and we'd quickly reach our api limit.

Please can you tell me if this is a known issue. If not, can you advise on what I'm doing wrong.

Thanks in advance,

#Code

from datetime import datetime, timedelta 
import pandas as pd 
import numpy as np 
import gocardless_pro
import logging 

class GoCardless(object):
  
  def __init__(self, token, env):
    
    self.client = gocardless_pro.Client(access_token=token,
                                        environment=env)
  
  def get_payments(self, payout_id):    

    response = self.client.payout_items.list(params={'payout':payout_id, 'limit':999999})
    
    payments = []
    if response.api_response.status_code in [200, 204]:
      
      for payment in response.records:
        payment =  {"amount":payment.amount,
                    "payment_type":payment.type,
                    "mandate_number":payment.links.mandate}
        payments.append(payment)
      payments = pd.DataFrame(payments)
 
    else:
      logging.error("Request payments from payout {} failed. \
                     see status code {} for more details".\
                     format(payout_id, response.api_response.status_code))
    
    return payments 
    


Add specific type Errors

The API documentation has a ton of errors listed, would it be possible to have these exact errors/exceptions be raised by the library? Currently we have to check for the errors inside of the Error's error (that sentence is a bit ridiculous, but it makes it clear).

We end up with the following constantly:

try:
    instance.from_api(
        instance.api.create,
        params=given
    )
except GoCardlessProError as e:
    raise DjangoGoCardlessException.from_gocardless_exception(e)
instance.save(*args, **kwargs)

The DjangoGoCardlessException.from_gocardless_exception(e) would raise the exception that should've been raised by the library.

Instead of that something like this:

try:
    instance.from_api(
        instance.api.create,
        params=given
    )
except AccessTokenNotFound as e:
    # Perhaps not catch it here, but elsewhere.

Allow for custom retry amount, delay, and timeout.

Lately our calls to GoCardless are taking an excessive amount of time and are even causing timeouts in our wsgi. Calls to BaseService._perform_request are all using hardcoded settings, e.g: RedirectFlowsService.create. It would be appreciated if we could configure these ourselves somehow and also configure a timeout. The library uses requests internally which allows you to pass a timeout, it would be neat if we could pass all this data ourselves and handle the timeout and other exceptions ourselves.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.