-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:ghimiresdp/nepali-wallets-python in…
…to feature/khalti
- Loading branch information
Showing
5 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# Instructions for contributors | ||
# Instruction for contributors | ||
|
||
> **Note**: _The project strictly uses `poetry` package manager so do not push | ||
> any `requirements.txt` file or other package management files._ | ||
Rules to contribute to projects: | ||
|
||
- The main goal of this project is to unify payment process so we must inherit | ||
abstract classes for creating a new payment method. | ||
|
||
- Do not use highly offensive or racist words anywhere including variable names, | ||
examples, and requirement specification. | ||
|
||
- The solution should be capable of running on all operating systems. | ||
If not, mention in the respective section in documentation | ||
|
||
|
||
## Placeholders | ||
Placeholders are not strict and we may use any name for them, but please try to | ||
name them so that everyone who understands English can understand them properly. | ||
|
||
We may use name of fictional characters of Sci-fi movies too | ||
but we should make sure that those names should not impact sentiments of people | ||
of any region, race, or gender. | ||
|
||
Examples of some placeholders: | ||
|
||
1. **Person**: `John Doe` `Darth Vader`, `Sheldon`, `Iron Man`, `Yoda`, etc. | ||
2. **Place**: `High Street`, `Wakanda`, `Vulkan`, `Tatooine`, etc. | ||
3. **Organization**: `Ace`, `Galactic Republic`, `Jedi`, `Enterprise`, ``, etc. | ||
4. **Domain Names** `example.com`, `starwars.com`, `johndoe.com`, etc. | ||
|
||
|
||
> **Note**: All of the above guidelines are created just for the reference and | ||
> may not be used as a proof for any legal actions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,30 @@ def test_khali_intent__success(self): | |
} | ||
) | ||
assert intent.id is not None | ||
assert 'pidx' in intent.data | ||
|
||
def test_khalti_intent__status(self, khalti__intent): | ||
print(khalti__intent.id) | ||
data = khalti_client.verify_payment(khalti__intent) | ||
print(data.text) | ||
|
||
def test_khalti__payment(self, khalti__intent): | ||
""" | ||
To run this test case, you must provide -s argument since this test case needs user interaction | ||
example 1: pytest -s | ||
example 2: pytest -s -k khalti__payment | ||
Once this test starts, the payment intent is created, at the time, you need to click the link generated | ||
by khalti and complete payment with credentials as follows: | ||
phone: 9800000000 / 9800000001 ... 9800000005 | ||
mpin: 1111 | ||
OTP: 987654 | ||
""" | ||
print(khalti__intent.data) | ||
print("Click the link, pay and continue") | ||
intent = input(f'intent id [{khalti__intent.id}]: ') | ||
data = khalti_client.verify_payment(intent or khalti__intent) | ||
assert data.json()['status'] == 'Completed' | ||
|
||
def test_khalti_intent__duplicate_order(self): | ||
current_timestamp = datetime.now().timestamp() | ||
data = { | ||
'amount': 1000, | ||
'order_id': f'test_order_{current_timestamp}', | ||
'order_name': f"Test Order {current_timestamp}", | ||
'customer_info': { | ||
'name': 'John Doe', | ||
'email': '[email protected]', | ||
} | ||
} | ||
khalti_client.create_intent(**data) | ||
intent = khalti_client.create_intent(**data) | ||
assert intent.id is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ | |
from datetime import datetime | ||
|
||
__all__ = [ | ||
'intent__khalti', | ||
'khalti__intent', | ||
] | ||
|
||
|
||
@pytest.fixture | ||
def intent__khalti(): | ||
def khalti__intent(): | ||
current_timestamp = datetime.now().timestamp() | ||
intent_response = khalti_client.create_intent( | ||
intent = khalti_client.create_intent( | ||
amount=1000, | ||
order_id=f'order_{current_timestamp}', | ||
order_name="Test Order", | ||
|
@@ -19,4 +20,4 @@ def intent__khalti(): | |
'email': '[email protected]', | ||
} | ||
) | ||
return intent_response | ||
return intent |