No momento estou fazendo da primeira forma
py
class PaymentService:
def __init__(self):
certificado_path = os.path.join(settings.BASE_DIR, os.getenv('EFI_CERTIFICADO'))
env = os.getenv('ENV_TYPE') if os.getenv('ENV_TYPE') else 'dev'
sandbox = False if env == 'prod' else True
options = {
"client_id": os.getenv('EFI_CLIENT_ID'),
"client_secret": os.getenv('EFI_CLIENT_SECRET'),
"sandbox": sandbox,
"certificate": certificado_path,
}
self.sdk = EfiPay(options)
e na minha view eu faço
py
@method_decorator(csrf_exempt, name='dispatch')
class ProcessPayment(generic.View):
def post(self, request, args, kwargs):
payment_service = PaymentService()