Skip to content

Commit

Permalink
fixes (#2)
Browse files Browse the repository at this point in the history
* setup.py, minor fixes to create() and refund() and package security update.

* passing only source to source builder instead of the whole payment object
  • Loading branch information
nuhamozaini authored and ecleel committed Mar 4, 2019
1 parent 159e308 commit 1a05390
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
2 changes: 0 additions & 2 deletions moyasar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import base64

import requests
import json
from moyasar.payment import Payment
Expand Down
2 changes: 1 addition & 1 deletion moyasar/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Create(Constructor):
def __init__(self, data):
super().__init__(data)
super().__init__(**data)

@classmethod
def create_url(cls):
Expand Down
15 changes: 8 additions & 7 deletions moyasar/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

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

@classmethod
def source_to_creditcard(cls, data):
Expand All @@ -37,8 +37,9 @@ class Sadad(Source):
class Payment(Resource, Refund):
def __init__(self, data):
super().__init__(data)
Source.build(self)
self.source = Source.build(self.source)

def refund(self, amount=None):
super().refund(amount)
__class__.build(self)
self.source = Source.build(self.source)
return self
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ py==1.8.0
py-bcrypt==0.4
Pygments==2.3.1
pytest==4.3.0
PyYAML==3.13
PyYAML==4.2b1
requests==2.21.0
six==1.12.0
smmap2==2.0.5
Expand Down
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import setuptools

with open("README.rst", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="moyasar-python",
version="0.6",
author="Moyasar",
author_email="developer@moyasar.com",
description="Moyasar Python language wrapper",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/moyasar/moyasar-python",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: MIT License",
"Operating System :: OS Independent",
],
)

0 comments on commit 1a05390

Please sign in to comment.