Skip to content

/subscribe/payments/onetime 기능 추가 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions iamport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def _cancel(self, payload):
url = '{}payments/cancel'.format(self.imp_url)
return self._post(url, payload)

def pay_onetime(self, **kwargs):
url = '{}subscribe/payments/onetime'.format(self.imp_url)
for key in ['merchant_uid', 'amount', 'card_number', 'expiry', 'birth', 'pwd_2digit']:
if key not in kwargs:
raise KeyError('Essential parameter is missing!: %s' % key)

return self._post(url, kwargs)

def cancel_by_merchant_uid(self, merchant_uid, reason):
payload = {'merchant_uid': merchant_uid, 'reason': reason}
return self._cancel(payload)
Expand Down
33 changes: 33 additions & 0 deletions tests/test_pay_onetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from iamport import Iamport


def test_payOnetime(iamport):
# Without 'card_number'
payload_notEnough = {
'merchant_uid': '00000000',
'amount': 5000,
'expiry': '2019-03',
'birth': '500203',
'pwd_2digit': '19'
}

try:
iamport.pay_onetime(**payload_notEnough)
except KeyError as e:
assert "Essential parameter is missing!: card_number" in str(e)

payload_full = {
'merchant_uid': '00000000',
'amount': 5000,
'card_number': '4092-0230-1234-1234',
'expiry': '2019-03',
'birth': '500203',
'pwd_2digit': '19'
}

try:
iamport.pay_onetime(**payload_full)
except Iamport.ResponseError as e:
assert e.code == -1
assert u'카드정보 인증에 실패하였습니다.' in e.message