-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crea ticket desde carro, sin asignar numero de orden
- Loading branch information
Showing
4 changed files
with
90 additions
and
15 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 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 |
---|---|---|
@@ -1,10 +1,81 @@ | ||
import json | ||
from collections import OrderedDict | ||
|
||
from django import forms | ||
# Register your receivers here | ||
from django.dispatch import receiver | ||
|
||
from pretix.base.signals import register_payment_providers | ||
from pretix.base.forms import SecretKeySettingsField | ||
from pretix.base.signals import ( | ||
logentry_display, register_global_settings, register_payment_providers, | ||
requiredaction_display, | ||
) | ||
|
||
|
||
@receiver(register_payment_providers, dispatch_uid="payment_mercadopago") | ||
def register_payment_provider(sender, **kwargs): | ||
from .payment import Mercadopago | ||
return Mercadopago | ||
|
||
|
||
|
||
@receiver(signal=logentry_display, dispatch_uid="mercadopago_logentry_display") | ||
def pretixcontrol_logentry_display(sender, logentry, **kwargs): | ||
if logentry.action_type != 'pretix.plugins.mercadopago.event': | ||
return | ||
|
||
data = json.loads(logentry.data) | ||
event_type = data.get('event_type') | ||
text = None | ||
plains = { | ||
'PAYMENT.SALE.COMPLETED': _('Payment completed.'), | ||
'PAYMENT.SALE.DENIED': _('Payment denied.'), | ||
'PAYMENT.SALE.REFUNDED': _('Payment refunded.'), | ||
'PAYMENT.SALE.REVERSED': _('Payment reversed.'), | ||
} | ||
|
||
if event_type in plains: | ||
text = plains[event_type] | ||
else: | ||
text = event_type | ||
|
||
if text: | ||
return _('MercadoPago reported an event: {}').format(text) | ||
|
||
@receiver(signal=requiredaction_display, dispatch_uid="mercadopago_requiredaction_display") | ||
def pretixcontrol_action_display(sender, action, request, **kwargs): | ||
if not action.action_type.startswith('pretix.plugins.mercadopago'): | ||
return | ||
|
||
data = json.loads(action.data) | ||
|
||
# if action.action_type == 'pretix.plugins.paypal.refund': | ||
# template = get_template('pretixplugins/paypal/action_refund.html') | ||
# elif action.action_type == 'pretix.plugins.paypal.overpaid': | ||
# template = get_template('pretixplugins/paypal/action_overpaid.html') | ||
# elif action.action_type == 'pretix.plugins.paypal.double': | ||
# template = get_template('pretixplugins/paypal/action_double.html') | ||
|
||
ctx = {'data': data, 'event': sender, 'action': action} | ||
return template.render(ctx, request) | ||
|
||
@receiver(register_global_settings, dispatch_uid='mercadopago_global_settings') | ||
def register_global_settings(sender, **kwargs): | ||
return OrderedDict([ | ||
('payment_mercadopago_connect_client_id', forms.CharField( | ||
label=_('MercadoPago Connect: Client ID'), | ||
required=False, | ||
)), | ||
('payment_mercadopago_connect_secret_key', SecretKeySettingsField( | ||
label=_('MercadoPago Connect: Secret key'), | ||
required=False, | ||
)), | ||
('payment_mercadopago_connect_endpoint', forms.ChoiceField( | ||
label=_('MercadoPago Connect Endpoint'), | ||
initial='live', | ||
choices=( | ||
('live', 'Live'), | ||
('sandbox', 'Sandbox'), | ||
), | ||
)), | ||
]) |
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 |
---|---|---|
|
@@ -34,13 +34,13 @@ def run(self): | |
author='Manuel Retamozo', | ||
author_email='[email protected]', | ||
license='Apache', | ||
|
||
install_requires=['mercadopago'], | ||
packages=find_packages(exclude=['tests', 'tests.*']), | ||
include_package_data=True, | ||
cmdclass=cmdclass, | ||
entry_points=""" | ||
[pretix.plugin] | ||
pretix-mercadopago=pretix_mercadopago:PluginMeli | ||
pretix.plugins.mercadopago=pretix_mercadopago:PretixPluginMeta | ||
""", | ||
) | ||
|