Last active
August 16, 2017 18:49
-
-
Save jackboot7/07b12019b97bb1d7b26e1d193f6eb67f to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
import base64 | |
import os | |
from django.conf import settings | |
from zeep import Client as ZeepClient | |
from suds.client import Client as SudsClient | |
from pac_gateway.cfd.models import Location | |
USERNAME = settings.FINKOK_USERNAME | |
PASSWORD = settings.FINKOK_PASSWORD | |
FINKOK_APP_URL = os.environ.get('FINKOK_APP_URL', | |
'http://demo-facturacion.finkok.com') | |
CANCEL_WSDL = '{}/servicios/soap/cancel.wsdl'.format(FINKOK_APP_URL) | |
def cancel_cfd(location_id, cfdi_uuid): | |
_cancel_srv = SudsClient(CANCEL_WSDL, cache=None) | |
cancel_srv = _cancel_srv.service | |
finkok_ticket = _cancel_srv.factory.create('UUIDS') | |
finkok_ticket.uuid = [cfdi_uuid] | |
location = Location.objects.get(pk=location_id) | |
rfc = location.default_rfc.rfc | |
cer_pem = location.default_certificate.pem() | |
key_pem = location.default_certificate.key_pem() | |
cer_file = base64.encodebytes(cer_pem.encode()).decode() | |
key_file = base64.encodebytes(key_pem.encode()).decode() | |
return cancel_srv.cancel( | |
finkok_ticket, | |
USERNAME, | |
PASSWORD, | |
rfc, | |
cer_file, | |
key_file | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment