コード例 #1
0
ファイル: paystack.py プロジェクト: Imuhammed24/CarRental
def paystack_button(context, button_id="django-paystack-button",
                    currency="ngn", plan="", button_class="",
                    amount=None, ref=None, metadata=None,
                    email=None, redirect_url=None):

    metadata = str(metadata)
    new_redirect_url = redirect_url
    old_amount = amount
    new_amount = int(amount) * 100
    ref = metadata
    if not new_redirect_url:
        new_redirect_url = "{}?amount={}".format(
            reverse("paystack:verify_payment", args=[ref]), new_amount
        )

    return {
        "button_class": button_class,
        "button_id": button_id,
        "paystack_public_key": settings.PAYSTACK_PUBLIC_KEY,
        "ref": ref,
        "email": email,
        "amount": new_amount,
        "old_amount": old_amount,
        "redirect_url": new_redirect_url,
        "currency": currency,
        "plan": plan,
        "js_url": get_js_script(),
    }
コード例 #2
0
def paystack_button(context,
                    button_id="django-paystack-button",
                    currency="ngn",
                    plan="",
                    button_class="",
                    amount=None,
                    ref=None,
                    email=None,
                    redirect_url=None,
                    icon="",
                    words="Pay Now"):
    new_ref = ref
    new_redirect_url = redirect_url
    new_amount = int(amount) * 100
    if not new_ref:
        new_ref = get_random_string().upper()
    if not new_redirect_url:
        new_redirect_url = "{}?amount={}".format(
            reverse('paystack:verify_payment', args=[new_ref]), new_amount)

    return {
        'button_class': button_class,
        'button_id': button_id,
        'key': settings.PAYSTACK_PUBLIC_KEY,
        'ref': new_ref,
        'email': email,
        'amount': new_amount,
        'icon': icon,
        'words': words,
        'redirect_url': new_redirect_url,
        'currency': currency,
        'plan': plan,
        'js_url': get_js_script()
    }
コード例 #3
0
def paystack_button(
    context,
    button_id="django-paystack-button",
    currency="ngn",
    plan="",
    button_class="",
    amount=None,
    ref=None,
    email=None,
    redirect_url=None,
):
    new_ref = ref
    new_redirect_url = redirect_url
    new_amount = int(amount) * 100
    if not new_ref:
        new_ref = get_random_string().upper()
    if not new_redirect_url:
        new_redirect_url = "{}?amount={}".format(
            reverse("paystack:verify_payment", args=[new_ref]), new_amount)
    return {
        "button_class": button_class,
        "button_id": button_id,
        "key": settings.PAYSTACK_PUBLIC_KEY,
        "ref": new_ref,
        "email": email,
        "amount": new_amount,
        "redirect_url": new_redirect_url,
        "currency": currency,
        "plan": plan,
        "js_url": get_js_script(),
    }
コード例 #4
0
def pay_donation(request):
    donor = DonationPart.objects.all()
    template = "sol/pay_donate.html"
    new_ref = get_random_string().upper()
    key = settings.PAYSTACK_PUBLIC_KEY
    context = None
    try:
        if 'email' in request.session and 'amount' in request.session:
            email = request.session.get('email')
            amount = request.session.get('amount')
            context = {
                "amount": amount,
                "email": email,
                "paystack_script": get_js_script(),
                "new_ref": new_ref,
                "key": key
            }
    except Exception as e:
        messages.error(request, 'Donation session expired please try again.')
    return render(request, template, context)