Merge pull request #1108 from rishabhs95/stripe

Online payment feature - direct stripe integration
This commit is contained in:
Hernán Schmidt 2016-08-18 16:04:11 +02:00 committed by GitHub
commit 32019a11e1
35 changed files with 523 additions and 110 deletions

View file

@ -3,7 +3,7 @@
.page-header
%h1 Tickets
%p.text-muted
Tickets to purchase during registration
Tickets to get during registration
- if @conference.tickets.any?
.row
.col-md-12

View file

@ -5,7 +5,7 @@
Support
=@conference.short_title
%p.lead
To support our event you can purchase these tickets
To support our event you can get these tickets
- @conference.tickets.each_slice(4) do |slice|
.row.row-centered
- slice.each do |ticket|
@ -20,6 +20,6 @@
= markdown(ticket.description)
%p.text-center
= link_to(conference_tickets_path(@conference.short_title), class: 'btn btn-success') do
Buy Ticket
Get Ticket
= humanized_money_with_symbol ticket.price

View file

@ -85,33 +85,31 @@
- if @conference.tickets.any?
.row
.col-md-12
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-ticket.fa-stack-1x
Tickets
-if @tickets.any?
= "(#{@total_price} #{@tickets.first.price.symbol})"
-if @tickets.any?
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-ticket.fa-stack-1x
Ticket Purchases
= "(#{@tickets.first.price.symbol}#{humanized_money @total_price})"
%ul
- @tickets.each do |ticket|
%li
= ticket.quantity
= ticket.title
= word_pluralize(ticket.quantity, 'Ticket')
for
= humanized_money ticket.price
= ticket.price.symbol
= link_to conference_ticket_purchase_path(@conference.short_title, ticket.id), method: :delete,
id: "ticket-#{ticket.id}-delete",
class: 'btn btn-danger btn-xs',
data: { confirm: "Do you really want to delete the #{ticket.title} ticket for #{@conference.title}?" } do
%i.fa.fa-trash-o
%li
- if @tickets.any?
= link_to 'Buy more tickets', conference_tickets_path(@conference.short_title)
- else
You haven't bought any tickets.
= link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title)
.col-md-12
- @ticket_payments.each_pair do |ticket_id, tickets|
%li
= @total_quantity[ticket_id]
= tickets.first.title
= word_pluralize(@total_quantity[ticket_id], 'Ticket')
for
= tickets.first.price.symbol
= humanized_money tickets.first.price
%br
- if @tickets.any?
= link_to 'Get more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default"
- else
You haven't bought any tickets.
= link_to 'Please get some tickets to support us!', conference_tickets_path(@conference.short_title)
%p
(Your participation won't be valid without getting a ticket)
.row
.col-md-12

View file

@ -0,0 +1,27 @@
.div
.col-md-12.table-responsive
%table.table.table-hover
%thead
%tr
%th Ticket
%th Quantity
%th Price
%th Total
%tbody
- @unpaid_ticket_purchases.each do |ticket|
%tr
%td
= ticket.title
%td
= ticket.quantity
%td
= humanized_money_with_symbol ticket.price
%td
= humanized_money_with_symbol ticket.quantity * ticket.price
= form_tag conference_payments_path do
%script.stripe-button{ src: "https://checkout.stripe.com/checkout.js",
data: { amount: @total_amount_to_pay.cents, label: "Pay #{humanized_money_with_symbol @total_amount_to_pay}",
email: current_user.email, currency: @total_amount_to_pay.currency, name: ENV['OSEM_NAME'] || 'OSEM',
description: "book your tickets", key: Rails.application.secrets.stripe_publishable_key, locale: "auto"}}
= link_to 'Edit Purchase', conference_tickets_path(@conference.short_title), class: 'btn btn-default'

View file

@ -0,0 +1,14 @@
.container
.row
.col-xs-6.col-xs-offset-3
%h1
Payment Summary :
= humanized_money_with_symbol @total_amount_to_pay
.col-xs-8.col-xs-offset-2.well
= render partial: 'payment'
.row
.col-md-13
%p.text-muted.text-center
%small
All payments are handled securely by our payment processor,
= link_to 'Stripe', 'https://stripe.com', target: '_blank'

View file

@ -8,12 +8,8 @@
- unless ticket.description.blank?
= markdown(ticket.description)
%td.col-sm-1.col-md-1
- if ticket.bought?(current_user)
= text_field_tag("tickets[][#{ticket.id}]", ticket.quantity_bought_by(current_user),
= text_field_tag("tickets[][#{ticket.id}]", 0,
type: 'number', min: 0, class: "form-control quantity", 'data-id' => ticket.id)
- else
= text_field_tag("tickets[][#{ticket.id}]", 0, type: 'number', min: 0,
class: "form-control quantity", 'data-id' => ticket.id)
%td.col-sm-1.col-md-1.text-center
= ticket.price.symbol
%span{id: "price_#{ticket.id}"}

View file

@ -5,10 +5,10 @@
%h1
Tickets
%p.lead
If you like, support
Please choose your tickets for
%strong
= @conference.title
by buying a ticket*
here*
=form_tag(conference_ticket_purchases_path, method: :post) do |f|
%table.table.table-hover
%thead
@ -35,12 +35,11 @@
.pull-right
.btn-group-vertical
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
Support
Continue
%i.fa.fa-shopping-cart
= link_to 'Continue without a Ticket!', conference_conference_registration_path(@conference.short_title),
class: 'btn btn-danger btn-sm'
= link_to 'Cancel registration', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-sm'
.row
.col-md-13
%p.text-muted.text-center
%small
* Buying a ticket is not mandatory. Checkout will be at the conference registration.
* Getting a ticket is mandatory. Your participation will not be valid until you get a ticket.