Skip to content

Commit

Permalink
add missing attribute in checkout && fix makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
tarek-berkane committed Feb 13, 2024
1 parent 33dcbe3 commit b70a745
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 13 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: test

test:
python -m unittest discover -s tests -p 'test_*.py'

build:
python -m build

publish:
python -m twine upload dist/*
10 changes: 0 additions & 10 deletions makefile

This file was deleted.

2 changes: 2 additions & 0 deletions src/chargily_pay/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Checkout:
customer_id: str = None
description: str = None
locale: str = None
payment_method:str=None
webhook_endpoint:str=None
pass_fees_to_customer: bool = None
metadata: list[dict] = field(default_factory=list)

Expand Down
46 changes: 43 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from itertools import product
import os
import unittest

Expand Down Expand Up @@ -235,6 +234,49 @@ def test_create_checkout(self):
)
self.assertEqual(type(checkout), dict)

def test_create_checkout_with_webhook(self):
product = Product(
name="Product name",
description="Product description",
)
response = self.chargily.create_product(product)
product_id = response["id"]
price = self.chargily.create_price(
Price(amount=100, currency="dzd", product_id=product_id)
)
price_id = price["id"]
checkout = self.chargily.create_checkout(
Checkout(
items=[{"price": price_id, "quantity": 1}],
success_url="https://example.com/success",
failure_url="https://example.com/failure",
webhook_endpoint="https://example.com/webhook",
)
)
self.assertEqual(type(checkout), dict)
self.assertEqual(checkout["webhook_endpoint"], "https://example.com/webhook")

def test_create_checkout_with_payment_method(self):
product = Product(
name="Product name",
description="Product description",
)
response = self.chargily.create_product(product)
product_id = response["id"]
price = self.chargily.create_price(
Price(amount=100, currency="dzd", product_id=product_id)
)
price_id = price["id"]
checkout = self.chargily.create_checkout(
Checkout(
items=[{"price": price_id, "quantity": 1}],
success_url="https://example.com/success",
payment_method="cib",
)
)
self.assertEqual(type(checkout), dict)
self.assertEqual(checkout["payment_method"], "cib")

def test_create_checkout_with_amount(self):
checkout = self.chargily.create_checkout(
Checkout(
Expand All @@ -245,8 +287,6 @@ def test_create_checkout_with_amount(self):
)
self.assertEqual(type(checkout), dict)



def test_create_checkout_with_customer(self):
product = Product(
name="Product name",
Expand Down

0 comments on commit b70a745

Please sign in to comment.