Skip to content

Commit d04277b

Browse files
committed
PaypalProvider: allow to make also get requests
1 parent 4d8e67e commit d04277b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

payments/paypal/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ def _get_links(self, payment):
114114
return extra_data.get("links", {})
115115

116116
@authorize
117-
def post(self, payment, *args, **kwargs):
117+
def http_request(self, payment, *args, http_method=None, **kwargs):
118118
kwargs["headers"] = {
119119
"Content-Type": "application/json",
120120
"Authorization": self.access_token,
121121
}
122122
if "data" in kwargs:
123123
kwargs["data"] = json.dumps(kwargs["data"])
124-
response = requests.post(*args, **kwargs)
124+
response = http_method(*args, **kwargs)
125125
try:
126126
data = response.json()
127127
except ValueError:
@@ -144,6 +144,12 @@ def post(self, payment, *args, **kwargs):
144144
self.set_response_data(payment, data)
145145
return data
146146

147+
def post(self, payment, *args, **kwargs):
148+
return self.post(payment, http_method=requests.post, *args, **kwargs)
149+
150+
def get(self, payment, *args, **kwargs):
151+
return self.post(payment, http_method=requests.get, *args, **kwargs)
152+
147153
def get_last_response(self, payment, is_auth=False):
148154
extra_data = json.loads(payment.extra_data or "{}")
149155
if is_auth:

0 commit comments

Comments
 (0)