Skip to content

Commit

Permalink
- Fix checkout errors (#71)
Browse files Browse the repository at this point in the history
* - Fix checkout errors
- Fix checkout tests
- Delete unused methods

* fix failing test

* fix branch name github actions
  • Loading branch information
fcarrero authored Apr 17, 2023
1 parent d06c0bc commit 6b76c57
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 148 deletions.
25 changes: 25 additions & 0 deletions .github/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Python App Test

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
run: nosetests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ conekta/.DS_Store
build
conekta.egg-info
dist
.idea
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.6.2](https://github.com/conekta/conekta-python/releases/tag/v2.6.2) - 2023-04-17
### Change
- Fix checkout errors
- Fix checkout tests
- Delete unused methods

## [2.6.1](https://github.com/conekta/conekta-python/releases/tag/v2.6.1) - 2020-12-30
### Change
- Fix indentation error
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![banner](readme_files/banner.png)

# Conekta Python v2.6.1
# Conekta Python v2.6.2

![python badge](readme_files/python-badge.png)
![conekta badge](readme_files/conekta-badge.png)
Expand Down
21 changes: 6 additions & 15 deletions conekta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

API_VERSION = '2.0.0'

__version__ = '2.6.1'
__version__ = '2.6.2'
__author__ = 'Leo Fischer'

API_BASE = 'https://api.conekta.io/'
Expand Down Expand Up @@ -410,7 +410,7 @@ def charge(self, params, api_key=None):
return charge

def createShippingContact(self, params, api_key=None):
orders = self.update(params)
orders = self.update(params, api_key=api_key)
self.shipping_contact = ShippingContact(orders['shipping_contact'])
return self.shipping_contact

Expand Down Expand Up @@ -438,12 +438,6 @@ def createDiscountLine(self, params, api_key=None):
self.discount_lines.append(discount_line)
return discount_line

def createCheckout(self, params, api_key=None):
checkout = CheckoutOrder(DiscountLine.load_url(
"%s/orders" % self.instance_url(), 'POST', params, api_key=api_key))
self.checkout.append(checkout)
return checkout


class CustomerInfo(_UpdatableResource):
pass
Expand Down Expand Up @@ -525,17 +519,14 @@ class Checkout(_CreatableResource, _UpdatableResource, _DeletableResource, _Find
def __init__(self, *args, **kwargs):
super(Checkout, self).__init__(*args, **kwargs)

def create(self, params, api_key=None):
return self.load_via_http_request("%s/checkouts" % self.instance_url(), 'POST', params, api_key=api_key)

def cancel(self, params, api_key=None):
return self.load_via_http_request("%s/checkouts/cancel/%s" % (self.instance_url(), self.id), 'PUT', None, api_key=api_key)
return self.load_via_http_request("%s/cancel" % (self.instance_url()), 'PUT', None, api_key=api_key)

def sendEmail(self, params, api_key=None):
return self.load_via_http_request("%s/checkouts/email" % self.instance_url(), 'POST', params, api_key=api_key)
return self.load_via_http_request("%s/email" % self.instance_url(), 'POST', params, api_key=api_key)

def sendSms(self, params, api_key=None):
return self.load_via_http_request("%s/checkouts/sms" % self.instance_url(), 'POST', params, api_key=api_key)
return self.load_via_http_request("%s/sms" % self.instance_url(), 'POST', params, api_key=api_key)


class Event(_FindableResource):
Expand Down Expand Up @@ -577,7 +568,7 @@ class Payout(_CreatableResource, _FindableResource):
pass


class Pagination(_CreatableResource):
class Pagination(_CreatableResource, _FindableResource):
def next(self):
if not hasattr(self, 'next_page_url'):
return None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import setup, find_packages

version = "2.6.1"
version = "2.6.2"
author = "Conekta"

setup(
Expand Down
43 changes: 23 additions & 20 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
import random
import conekta
from datetime import datetime, timedelta


class BaseEndpointTestCase(unittest.TestCase):
Expand Down Expand Up @@ -119,7 +120,7 @@ class BaseEndpointTestCase(unittest.TestCase):
{'token_id': 'tok_test_visa_4242',
'type': 'card'},
{'token_id': 'tok_test_mastercard_5100',
'type': 'card'}
'type': 'card'}
],
"shipping_contacts": [{
"phone": "+525511223344",
Expand Down Expand Up @@ -281,7 +282,7 @@ class BaseEndpointTestCase(unittest.TestCase):
update_payment_source_object = {
"name": "Emiliano Cabrera",
"exp_month": "12",
"exp_year": "20",
"exp_year": "29",
"address": {
"street1": "Nuevo leon",
"city": "Monterrey",
Expand All @@ -308,7 +309,7 @@ class BaseEndpointTestCase(unittest.TestCase):
"name": "Payment Link Name",
"type": "PaymentLink",
"recurrent": False,
"expired_at": 1590882634,
"expired_at": int((datetime.today() + timedelta(days=1)).timestamp()),
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"needs_shipping_contact": True,
"monthly_installments_enabled": False,
Expand All @@ -329,10 +330,11 @@ class BaseEndpointTestCase(unittest.TestCase):
}

checkout_object_multiple = {
"payments_limit_count": 2,
"name": "Payment Link Name",
"type": "PaymentLink",
"recurrent": True,
"expired_at": 1590882634,
"expired_at": int((datetime.today() + timedelta(days=1)).timestamp()),
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"needs_shipping_contact": True,
"monthly_installments_enabled": False,
Expand All @@ -353,10 +355,11 @@ class BaseEndpointTestCase(unittest.TestCase):
}

checkout_object_msi = {
"payments_limit_count" : 2,
"name": "Payment Link Name",
"type": "PaymentLink",
"recurrent": True,
"expired_at": 1590882634,
"expired_at": int((datetime.today() + timedelta(days=1)).timestamp()),
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"needs_shipping_contact": True,
"monthly_installments_enabled": True,
Expand Down Expand Up @@ -411,24 +414,24 @@ class BaseEndpointTestCase(unittest.TestCase):
"monthly_installments_enabled": True,
"monthly_installments_options": [3, 6, 9, 12],
"order_template": {
"line_items": [{
"name": "Red Wine",
"unit_price": 1000,
"quantity": 10
}],
"line_items": [{
"name": "Red Wine",
"unit_price": 1000,
"quantity": 10
}],
"currency": "MXN",
"customer_info": {
"name": "Juan Perez",
"email": "[email protected]",
"phone": "5566982090"
"name": "Juan Perez",
"email": "[email protected]",
"phone": "5566982090"
}
}
}

checkout_order_object = {
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2o3FvMEBiKitVK1vQ"
"customer_id": "cus_2tgwCPgJZR56HvkKK"
},
"line_items": [{
"name": "Box of Cohiba S1s",
Expand All @@ -443,7 +446,7 @@ class BaseEndpointTestCase(unittest.TestCase):
"multifactor_authentication": False,
"monthly_installments_enabled": False,
"monthly_installments_options": [3, 6, 9, 12, 18],
"expires_at": 1609891200
"expired_at": int((datetime.today() + timedelta(days=1)).timestamp())
},
"shipping_contact": {
"phone": "+5215555555555",
Expand All @@ -458,7 +461,7 @@ class BaseEndpointTestCase(unittest.TestCase):
checkout_msi_order__object = {
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2o3FvMEBiKitVK1vQ"
"customer_id": "cus_2tgwCPgJZR56HvkKK"
},
"line_items": [{
"name": "Box of Cohiba S1s",
Expand Down Expand Up @@ -490,7 +493,7 @@ class BaseEndpointTestCase(unittest.TestCase):
checkout_order__redirect_object = {
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2o3FvMEBiKitVK1vQ"
"customer_id": "cus_2tgwCPgJZR56HvkKK"
},
"line_items": [{
"name": "Box of Cohiba S1s",
Expand All @@ -502,13 +505,13 @@ class BaseEndpointTestCase(unittest.TestCase):
}],
"checkout": {
"type": "HostedPayment",
"success_url": "testredirect.com",
"failure_url": "testredirect.com",
"success_url": "https://testredirect.com",
"failure_url": "https://testredirect.com",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"multifactor_authentication": False,
"monthly_installments_enabled": False,
"monthly_installments_options": [3, 6, 9, 12, 18],
"expires_at": 1609891200
"expired_at": int((datetime.today() + timedelta(days=1)).timestamp())
},
"shipping_contact": {
"phone": "+5215555555555",
Expand Down
Loading

0 comments on commit 6b76c57

Please sign in to comment.