Skip to content

Commit

Permalink
Merge pull request #36 from iamport/feature/issue-35
Browse files Browse the repository at this point in the history
모든 POST요청은 application/json 방식으로 변환합니다
  • Loading branch information
jangbora authored Mar 15, 2020
2 parents 3a223d7 + b489be9 commit 3ea7e07
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions iamport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get_token(self):
url = '{}users/getToken'.format(self.imp_url)
payload = {'imp_key': self.imp_key,
'imp_secret': self.imp_secret}
response = self.requests_session.post(url, data=payload)
response = self.requests_session.post(url, headers={'Content-Type': 'application/json'}, data=json.dumps(payload))
return self.get_response(response).get('access_token')

def get_headers(self):
Expand All @@ -54,7 +54,8 @@ def _get(self, url, payload=None):

def _post(self, url, payload=None):
headers = self.get_headers()
response = self.requests_session.post(url, headers=headers, data=payload)
headers['Content-Type'] = 'application/json'
response = self.requests_session.post(url, headers=headers, data=json.dumps(payload))
return self.get_response(response)

def find_by_merchant_uid(self, merchant_uid):
Expand Down Expand Up @@ -126,8 +127,7 @@ def pay_schedule(self, **kwargs):
if key not in schedules:
raise KeyError('Essential parameter is missing!: %s' % key)

response = self.requests_session.post(url, headers=headers, data=json.dumps(kwargs))
return self.get_response(response)
return self._post(url, kwargs)

def pay_unschedule(self, **kwargs):
url = '{}subscribe/payments/unschedule'.format(self.imp_url)
Expand Down

0 comments on commit 3ea7e07

Please sign in to comment.