gocardless / gocardless-pro-python Goto Github PK
View Code? Open in Web Editor NEWGoCardless Pro Python Client
License: MIT License
GoCardless Pro Python Client
License: MIT License
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.
v1.45.0 is affcted.
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.
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
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.
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?
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.
# WARNING: Do not edit by hand, this file was generated by Crank:
#
# https://github.com/gocardless/crank
This repository doesn't seem to exist or is private?
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'}}
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
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==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.
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
Pypi package defines the homepage of the project to https://gocardless.com/docs/python/merchant_client_guide which leads to a 404 for me.
Please add tests for Python 3.8 and Python 3.9 and check they all pass.
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.
When running 'nosetest' under Python 3.10, tests fail due to 'nose' not working with Python 3.10
Right now the tests
directory gets installed as a top-level python package i.e. under python/site-packages/
.
Tests should either be under python/site-packages/gocardless_pro
or not be in the python package at all.
Hi Everyone,
I was wondering if there are plans to integrate the oauth flow in the python library.
Thanks,
Akshat
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.