Exemple #1
0
        })

    form = SermepaPaymentForm(initial=sermepa_dict)

    return HttpResponse(
        render_to_response('form.html', {
            'form': form,
            'debug': settings.DEBUG
        }))


def end(request):
    return HttpResponse(render_to_response('end.html', {}))


def payment_ok(sender, **kwargs):
    pass


def payment_ko(sender, **kwargs):
    pass


def sermepa_ipn_error(sender, **kwargs):
    pass


payment_was_successful.connect(payment_ok)
payment_was_error.connect(payment_ko)
signature_error.connect(sermepa_ipn_error)
    elif trans_type == '3': #Devolución
        # order = suscripcion.idreferencia #Primer idtpv, 10 dígitos
        order = ''
        merchant_parameters.update({
            "Ds_Merchant_Order": order,
            "Ds_Merchant_TransactionType": trans_type,
            #"Ds_Merchant_AuthorisationCode": pedido.Ds_AuthorisationCode, #Este valor sale
            "Ds_Merchant_AuthorisationCode": '',
            # de la SermepaResponse obtenida del cobro que se quiere devolver.
        })

    form = SermepaPaymentForm(merchant_parameters=merchant_parameters)
    
    return HttpResponse(render_to_response('form.html', {'form': form, 'debug': settings.DEBUG}))
    
def end(request):
    return HttpResponse(render_to_response('end.html', {}))
    
def payment_ok(sender, **kwargs):
    pass

def payment_ko(sender, **kwargs):
    pass

def sermepa_ipn_error(sender, **kwargs):
    pass

payment_was_successful.connect(payment_ok)
payment_was_error.connect(payment_ko)
signature_error.connect(sermepa_ipn_error)
        "Ds_Merchant_UrlKO":
        "%s%s" % (settings.SITE_DOMAIN, reverse('cancel_url')),
    }

    form = SermepaPaymentForm(initial=sermepa_dict)
    if settings.DEBUG:
        rendered_form = form.sandbox()
    else:
        rendered_form = form.render()
    return rendered_form


def confirm_payment(sender, **kwargs):
    #print sender
    try:
        order = Order.objects.get(uid=sender.Ds_Order)
    except:
        return
    #order = Order.objects.get(uid=sender.invoice)
    order.status = Order.PAYED
    order.pay_date = sender.creation_date
    a = str(sender.Ds_Amount)  #".".join((str(p)[:-2],str(p)[-2:]))
    order.pay_total = ".".join((a[:-2], a[-2:]))
    order.pay_id = sender.Ds_AuthorisationCode
    order.save()
    email_notification(order)


#payment_was_successful
payment_was_successful.connect(confirm_payment)
        "Ds_Merchant_UrlKO": "%s%s" % (settings.SITE_DOMAIN, reverse('cancel_url')),
    }
    

    form = SermepaPaymentForm(initial=sermepa_dict)
    if settings.DEBUG:
        rendered_form = form.sandbox()
    else:
        rendered_form = form.render()
    return rendered_form


def confirm_payment(sender, **kwargs):
        #print sender
        try:
            order = Order.objects.get(uid=sender.Ds_Order)
        except:
            return
        #order = Order.objects.get(uid=sender.invoice)
        order.status = Order.PAYED
        order.pay_date = sender.creation_date
        a = str(sender.Ds_Amount) #".".join((str(p)[:-2],str(p)[-2:]))
        order.pay_total = ".".join( (a[:-2],a[-2:]) )
        order.pay_id = sender.Ds_AuthorisationCode
        order.save()
        email_notification(order)
    
    
#payment_was_successful
payment_was_successful.connect(confirm_payment)