Skip to content

Commit

Permalink
Add applepay and stcpay sources (#13)
Browse files Browse the repository at this point in the history
* Support ApplePay and STCPay

* update packages

* update version
  • Loading branch information
ecleel authored Jul 15, 2020
1 parent dd39a64 commit aa8716a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
36 changes: 16 additions & 20 deletions moyasar/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,38 @@
from moyasar.actions.refund import Refund
from moyasar.actions.capture import Capture
from moyasar.actions.void import Void
from moyasar.helpers import Constructor
from moyasar.helpers import Format
from moyasar.helpers import Constructor, Format


class Source(Constructor, Format):

@classmethod
def build(cls, source):
if source['type'] == "creditcard":
source = Source.source_to_creditcard(source)
else:
source = Source.source_to_sadad(source)
return source

@classmethod
def source_to_creditcard(cls, data):
data.pop('type')
return CreditCard(data)

@classmethod
def source_to_sadad(cls, data):
data.pop('type')
return Sadad(data)
source_klass = sources[source.pop('type')]
return source_klass(source)


class CreditCard(Source):
def __str__(self):
return json.dumps(self.__dict__)


class Sadad(Source):
pass

class ApplePay(Source):
pass

class Payment(Resource, Refund, Capture, Void, Format):
class STCPay(Source):
pass

sources = {
'creditcard': CreditCard,
'sadad': Sadad,
'applepay': ApplePay,
'stcpay': STCPay,
}


class Payment(Resource, Refund, Capture, Void, Format):
def __init__(self, data):
super().__init__(data)
self.source = Source.build(self.source)
Expand Down
2 changes: 1 addition & 1 deletion moyasar/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


class Resource(Fetch, List, Update):
pass
pass
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ idna==2.8
isort==4.3.4
jsonrpclib==0.1.7
lazy-object-proxy==1.3.1
markdown2==2.3.7
markdown2==2.3.9
mccabe==0.6.1
more-itertools==6.0.0
pbr==5.1.2
Expand All @@ -23,10 +23,10 @@ py-bcrypt==0.4
Pygments==2.3.1
pytest==4.3.0
PyYAML==4.2b1
requests==2.21.0
requests==2.24.0
six==1.12.0
smmap2==2.0.5
stevedore==1.30.0
tornado==4.3
urllib3==1.24.2
urllib3==1.25.7
wrapt==1.11.1
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

with open("README.rst", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="moyasar",
version="0.6.5",
version="0.7.0",
author="Moyasar",
author_email="[email protected]",
description="Moyasar Python language wrapper",
Expand All @@ -24,5 +25,5 @@
'httpretty',
'pytest'
],
download_url='https://github.com/moyasar/moyasar-python/archive/v0.6.1.tar.gz'
download_url="https://github.com/moyasar/moyasar-python/archive/v{0}.tar.gz".format(version)
)
1 change: 0 additions & 1 deletion tests/moyasar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
def test_that_it_has_a_version_number():
assert moyasar.api_version is not ''


def test_should_accept_api_key():
moyasar.api_key = 'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
assert moyasar.api_key is not ''
Expand Down

0 comments on commit aa8716a

Please sign in to comment.