-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
388 additions
and
73 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), "tienda_pruebas")) | ||
TEMPLATES = [ | ||
{ | ||
"BACKEND": "django.template.backends.django.DjangoTemplates", | ||
"DIRS": [os.path.join(PROJECT_ROOT, "templates")], | ||
} | ||
] | ||
USE_TZ = True | ||
SECRET_KEY = "NOTREALLY" | ||
PAYMENT_HOST = "example.com" | ||
|
||
INSTALLED_APPS = ["payments", "django.contrib.sites"] |
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,5 +1,59 @@ | ||
from django_payments_chile.FlowProvider import FlowProvider | ||
from unittest import TestCase | ||
from unittest.mock import Mock | ||
from unittest.mock import patch | ||
|
||
from payments import PaymentStatus | ||
from payments import RedirectNeeded | ||
|
||
def test_provider_components(): | ||
assert FlowProvider == "2024.9.30" | ||
from django_payments_chile import FlowProvider | ||
|
||
API_KEY = "flow_test_key" | ||
API_SECRET = "flow_test_secret" | ||
|
||
|
||
class payment_attrs: | ||
session = dict | ||
|
||
|
||
class Payment(Mock): | ||
id = 1 | ||
description = "payment" | ||
currency = "CLP" | ||
delivery = 0 | ||
status = PaymentStatus.WAITING | ||
message = None | ||
tax = 0 | ||
total = 5000 | ||
captured_amount = 0 | ||
transaction_id = None | ||
billing_email = "correo@usuario.com" | ||
attrs = payment_attrs() | ||
|
||
def change_status(self, status, message=""): | ||
self.status = status | ||
self.message = message | ||
|
||
def get_failure_url(self): | ||
return "http://mi-app.cl/error" | ||
|
||
def get_process_url(self): | ||
return "http://mi-app.cl/process" | ||
|
||
def get_purchased_items(self): | ||
return [] | ||
|
||
def get_success_url(self): | ||
return "http://mi-app.cl/exito" | ||
|
||
|
||
class TestStripeProviderV3(TestCase): | ||
def test_provider_create_session_success(self): | ||
payment = Payment() | ||
provider = FlowProvider(api_key=API_KEY, api_secret=API_SECRET) | ||
return_value = {"url": "https://flow.cl", "token": "TOKEN_ID", "flowOrder": "ORDER_ID"} | ||
with patch("stripe.checkout.Session.create", return_value=return_value): | ||
with self.assertRaises(RedirectNeeded): | ||
provider.get_form(payment) | ||
self.assertTrue("url" in payment.attrs.session) | ||
self.assertTrue("token" in payment.attrs.session) | ||
self.assertEqual(payment.status, PaymentStatus.WAITING) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
3.10 |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../django_payments_chile |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[project] | ||
name = "tienda-pruebas" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
dependencies = ["django-payments>=2.0,<4.0"] |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.