Skip to content

Commit

Permalink
Merge pull request #30 from paypay/feature/version-check
Browse files Browse the repository at this point in the history
Add version check method and doc update
  • Loading branch information
Shreyansh Pandey authored Oct 9, 2020
2 parents 2a57fbc + fcc7c4c commit b5f8e67
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ client = paypayopa.Client(auth=(API_KEY, API_SECRET),
production_mode=False)
```

After setting up the client instance you can get the current PayPay SDK version using the following:

```py
print(client.get_version())
```

### Create a QR Code
In order to receive payments using this flow, first of all you will need to create a QR Code. Following are the important parameters that you can provide for this method:

Expand Down
12 changes: 12 additions & 0 deletions paypayopa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import uuid
import datetime

import pkg_resources
from pkg_resources import DistributionNotFound

from types import ModuleType
from .constants import URL, HTTP_STATUS_CODE, ERROR_CODE

Expand Down Expand Up @@ -55,6 +58,15 @@ def __init__(self,
for name, Klass in RESOURCE_CLASSES.items():
setattr(self, name, Klass(self))

def get_version(self):
version = ""
try:
version = pkg_resources.require("paypayopa")[0].version
except DistributionNotFound:
print('DistributionNotFound')
return version


def _set_base_url(self, **options):
if self.production_mode is False:
base_url = self.DEFAULTS['sandbox_base_url']
Expand Down
2 changes: 1 addition & 1 deletion paypayopa/constants/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class URL(object):
CODE = "/v2/codes"
PAYMENT = "/v2/payments"
ACCOUNT_LINK = "/v1/qr/sessions"
PENDING_PAYMENT = "/v1/requestOrder"
PENDING_PAYMENT = "/v1/requestOrder"
1 change: 0 additions & 1 deletion paypayopa/resources/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def create_continuous_payment(self, data=None, **kwargs):
"\x1b[0m for currency")
return self.post_url(url, data, **kwargs)


def revert_payment(self, data=None, **kwargs):
if data is None:
data = {}
Expand Down
2 changes: 1 addition & 1 deletion paypayopa/resources/pending.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ def refund_details(self, id=None, **kwargs):
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for merchantRefundId")
url = "{}/{}".format(self.base_url, id)
return self.fetch(None, url, **kwargs)
return self.fetch(None, url, **kwargs)

0 comments on commit b5f8e67

Please sign in to comment.