Skip to main content

Basic Stripe configuration.

Project description

dj-DoCodeStripe (Django-App)

N|Solid

Build Status

DoCodeStripees una aplicacion para configurar stripe dentro de un proyecto hecho en Django

Tecnologia

DoCodeStripe se implementa con las siguientes librerias previamente instaladas:

  • Django - Python base framework (v2.2)

Instalacion

Instalar por medio de pip

$ pip install dj-DoCodeStripe

Estructura de la App

La aplicacion tiene una estructura comun de una app Django

DoCodeStripe/
    procesos
    templates
    admin.py
    apps.py
    models.py
    urls.py
    views.py

Configuracion:

Agregar la App a "INSTALLED_APPS" dentro de los settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'DoCodeStripe',
]

Agregar las claves de Stripe en settings.py (clave publicable y clave secreta) Configurar claves de API activas cuando DEBUG=False y la aplicación se encuentre en produccion.

# Configuracion de Stripe
if DEBUG:
    # Test Keys
    STRIPE_SECRET_KEY = ''
    STRIPE_PUBLISHABLE_KEY = ''
else:
    # Production Mode
    STRIPE_SECRET_KEY = ''
    STRIPE_PUBLISHABLE_KEY = ''

Uso:

urls.py

Crear una vista para el proceso de pago con el nombre urlPago

path('urlPago', views.urlPago, name='urlPago')

views.py

Se crea la vista en base a la url urlPago

# Vista para realizar el pago
def urlPago(request):
    contexto = pago.realizar_pago(request,80,"Pago realizado con exito")
    
    # Se verifica si el pago fue exitoso para mostrar templates personalizados
    if contexto['pagado']:
        return render(request, 'pagado.html', context=contexto)
    else:
        return render(request, 'noPagado.html', context=contexto)

Definir el pago dentro de la vista utilizando la libreria: definir_pago(tituloPago,descr,cantidad,logo)

  • tituloPago = Nombre del pago
  • descr = Descripción del pago (concatena cantidad)
  • cantidad = Monto a pagar (MXN)
  • logo = Logo personalizado (formato 'static' ej. 'img/logo.png')
from DoCodeStripe.procesos import pago

def vista(request):
    context = {
      'titulo' : titulo,
    }
    # Definir el pago y agregar al contexto existente
    context_pagos = pago.definir_pago("PagoUnico","Cobrar",80,None)
    context.update(context_pagos)
    
    return context

template.html

Implementar el boton para realizar los pagos en el template

{% include 'btnStripe_cardpay.html' %}

Configuracion basica del tamplate pagado.html

<!-- template pagado.html -->
<h2>Estatus de tu pago <strong>${{cantidad}}.00 MXN</strong>!</h2>

<h3>Informacion de Pago:</h3>
<p>{{nombre}}</p>
<p>{{cantidad}}</p>
<p>Pagado: {{pagado}}</p>
<p>{{recibo}}</p>

Actualizacion v1.1.2

  • Se implementa template para agregar boton

Actualizacion v1.1.1

  • Se implementa boton basico para uso de stripe

Licencia


MIT License

Copyright (c) 2020 DoCode

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj-DoCodeStripe-1.1.2.tar.gz (687.1 kB view details)

Uploaded Source

File details

Details for the file dj-DoCodeStripe-1.1.2.tar.gz.

File metadata

  • Download URL: dj-DoCodeStripe-1.1.2.tar.gz
  • Upload date:
  • Size: 687.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.2

File hashes

Hashes for dj-DoCodeStripe-1.1.2.tar.gz
Algorithm Hash digest
SHA256 ba5097a0452a2d7dd73784643bec1d8f82cb8decd9b36d08ac9711314427fd1d
MD5 7a0de061ff0f3a71e903c0a831078f3f
BLAKE2b-256 2cef8fcc192703201b8ff59dc96083fcd283b73f856cc919c636038c8e381f57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page