<form action="/init/pay/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-email="...@gmail.com"
data-key="pk_test_..."
data-amount="30000"
data-name="UKI TMS"
data-description="Trials in 2017 ($300)"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-panel-label="Pay {{amount}} for 2017"
data-locale="auto">
</script>
</form>
From the deafening silence, apparently this was not enough detail for anyone to even ask what other details I need to provide, so I'll do it myself: what other info do I need to provide to get some kind of response?- Scott
On Wednesday, March 22, 2017 at 6:29:38 PM UTC-7, Scott Hunter wrote:From the deafening silence, apparently this was not enough detail for anyone to even ask what other details I need to provide, so I'll do it myself: what other info do I need to provide to get some kind of response?- Scott
I suspect that Stripe users here are in the minority of the minority. There are people here handling payments through similar sites, judging by the occasional post here, and there's the info in the book. Saying that pretty near exhausts what I know about the subject, although I've been at presentations about the role of OAUTH2 in some of the implementations.
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I use the attached modules/stripeform.py, which is mostly based upon the contrib/stripe.py
It imports the python stripe module : https://github.com/stripe/stripe-python.git
I use it like :
@auth.requires_login(otherwise=lambda: helper.flash(
T("You need to log in to extend your subscription")))
def buy():
from stripeform import clean_stripe_session
clean_stripe_session() #To prevent reuse of idempotent uuid for stripe transactions
form = SQLFORM.factory(
# snipped …
)
form = form.process(keepvalues=True)
if form.accepted:
# error logic
else:
session.buyvars = form.vars
redirect(URL('pay'))
elif form.errors: # pragma: no branch
response.flash = T('form has errors')
return dict(form=form)
@auth.requires_login(otherwise=lambda: helper.flash(
T("You need to log in to extend your subscription")))
def pay():
if not session.buyvars:
redirect(URL('buy'))
from stripeform import StripeForm
total = # TODO calculate total from session.buyvars content
cart_form = TABLE(
# snipped : table displaying what is buyed (from session.buyvars
)
payment_id = db.payments.insert(amount=total)
form = StripeForm(
pk=STRIPE_PUBLISHABLE_KEY,
sk=STRIPE_SECRET_KEY,
amount=total, # (amount is in cents)
currency='eur',
currency_symbol='€',
description="…",
more = { 'metadata': {'payment_id':payment_id}}
).process()
if form.accepted:
pi = form.response
from datetime import datetime
import pytz
db.payments[payment_id]= dict(…) # Update db with buyed items if necessary
session.flash = T("Thank you!")
redirect(URL(c='default', f='index'))
elif form.errors: # pragma: no branch
response.flash = form.response.errors
del db.payments[payment_id]
return dict(cart_form=cart_form, form=form)
And the views for pay looks like:
{{extend 'layout.html'}}
<div class="container">
<div class="row">
<h2>{{=T("Payment")}}</h2>
<div class="col-md-7 col-sm-12 col-md-push-5">
<h3>{{=T("Cart Content")}}</h3>
<div class="table-responsive" id="payment">
{{=cart_form}}
</div>
</div>
<div class="col-md-5 col-md-pull-7 col-sm-12">
{{=form}}
</div>
…
--
<form action="/pay" method="POST">
<script
src="https://checkout.stripe.com/checkout.js"
class="stripe-button"
data-key="pk_test_XXXXXXXXXXXXXXXXXXXXX"
data-amount="999"
data-name="XXXXXXXXXXX"
data-description="Widget"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-zip-code="true"
data-currency="nzd">
</script>
</form>
def pay():
from gluon.contrib.stripe import StripeForm
amount = 1000
#1000 is $10 in cents
description ="Example charge"
form = StripeForm(
pk=STRIPE_PUBLISHABLE_KEY,
sk=STRIPE_SECRET_KEY,
amount=int(100*amount),
description=description).process()
if form.accepted:
#can also add stuff to update my records and allow them access and that. Also send them an email. But me, I’ll probably do that on the TU page itself.
redirect(URL('thank_you'))
elif form.errors:
redirect(URL('pay_error'))
return dict(form=form)
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Token is created using Stripe.js or Checkout!
# Get the payment token submitted by the form:
token = request.POST['stripeToken'] # Using Flask
# Charge the user's card:
charge = stripe.Charge.create(
amount=1000,
currency="nzd",
description="Example charge",
source=token,
)
OK,I'm down to just this now:
def pay(): from gluon.contrib.stripe import StripeForm
form = StripeForm( pk='pk_test_xxxxxxxxxxxxxxxxxx', sk='sk_test_xxxxxxxxxxxxxxxxxx', amount=1000, description="Example charge").process()
if form.accepted: #can also add stuff to update my records and allow them access and that. Also send them an email. But me, I’ll probably do that on the TU page itself. redirect(URL('thank_you')) elif form.errors: redirect(URL('pay_error')) return dict(form=form)
(stripeToken = form.vars.stripeToken)