spree_paypal_adaptive_payment 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +22 -0
  2. data/Gemfile +34 -0
  3. data/MIT-LICENSE.txt +20 -0
  4. data/README.markdown +3 -0
  5. data/Rakefile +14 -0
  6. data/TAGS +64 -0
  7. data/Versionfile +1 -0
  8. data/app/models/billing_integration/paypal_adaptive_payment.rb +25 -0
  9. data/app/models/paypal_adaptive_payment_account.rb +99 -0
  10. data/app/views/admin/payments/source_forms/_paypal_adaptive_payments.html.erb +9 -0
  11. data/app/views/admin/payments/source_views/_paypal_adaptive_payments.html.erb +110 -0
  12. data/app/views/admin/paypal_adaptive_payments/refund.html.erb +15 -0
  13. data/app/views/checkout/_confirm.html.erb +11 -0
  14. data/app/views/checkout/_delivery.html.erb +25 -0
  15. data/app/views/checkout/_payment.html.erb +30 -0
  16. data/app/views/checkout/edit.html.erb +18 -0
  17. data/app/views/checkout/payment/_check.html.erb +0 -0
  18. data/app/views/checkout/payment/_gateway.html.erb +31 -0
  19. data/app/views/checkout/payment/_paypal_adaptive_payment.html.erb +3 -0
  20. data/app/views/checkout/payment/_paypaladaptivepayment.html.erb +3 -0
  21. data/app/views/checkout/registration.html.erb +20 -0
  22. data/app/views/shared/_paypal_adaptive_paymetns_checkout.html.erb +3 -0
  23. data/app/views/shared/paypal_adaptive_payments_confirm.html.erb +10 -0
  24. data/config/locales/en.yml +32 -0
  25. data/config/routes.rb +26 -0
  26. data/db/migrate/20100226133156_create_paypal_adaptive_payment_accounts.rb +15 -0
  27. data/doc/BillingIntegration/PaypalAdaptivePayment.html +263 -0
  28. data/doc/PaypalAdaptivePaymentAccount.html +683 -0
  29. data/doc/SpreePaypalAdaptivePayment/Engine.html +200 -0
  30. data/doc/SpreePaypalAdaptivePayment.html +106 -0
  31. data/doc/SpreePaypalAdaptivePaymentHooks.html +116 -0
  32. data/doc/_index.html +146 -0
  33. data/doc/class_list.html +47 -0
  34. data/doc/css/common.css +1 -0
  35. data/doc/css/full_list.css +53 -0
  36. data/doc/css/style.css +320 -0
  37. data/doc/file.README.html +69 -0
  38. data/doc/file_list.html +49 -0
  39. data/doc/frames.html +13 -0
  40. data/doc/index.html +69 -0
  41. data/doc/js/app.js +205 -0
  42. data/doc/js/full_list.js +150 -0
  43. data/doc/js/jquery.js +16 -0
  44. data/doc/method_list.html +134 -0
  45. data/doc/top-level-namespace.html +105 -0
  46. data/lib/spree_paypal_adaptive_payment.rb +24 -0
  47. data/lib/spree_paypal_adaptive_payment_hooks.rb +3 -0
  48. data/lib/tasks/spree_paypal_adaptive_payment.rake +26 -0
  49. data/public/images/paypal111.gif +0 -0
  50. data/spec/controllers/checkout_controller_spec.rb +278 -0
  51. data/spec/factories/address_factory.rb +13 -0
  52. data/spec/factories/order_factory.rb +11 -0
  53. data/spec/factories/state_factory.rb +5 -0
  54. data/spec/spec_helper.rb +40 -0
  55. data/spree_paypal_adaptive_payment.gemspec +17 -0
  56. metadata +111 -0
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC'
22
+ .yardoc/*
data/Gemfile ADDED
@@ -0,0 +1,34 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sqlite3-ruby', :require => 'sqlite3'
4
+
5
+ group :test do
6
+ gem 'rspec-rails', '= 2.4.1'
7
+ gem 'factory_girl', '= 1.3.3'
8
+ gem 'factory_girl_rails', '= 1.0.1'
9
+ gem 'rcov'
10
+ gem 'shoulda'
11
+ gem 'faker'
12
+ if RUBY_VERSION < "1.9"
13
+ gem "ruby-debug"
14
+ else
15
+ gem "ruby-debug19"
16
+ end
17
+ end
18
+
19
+ group :cucumber do
20
+ gem 'cucumber-rails'
21
+ gem 'database_cleaner', '~> 0.5.2'
22
+ gem 'nokogiri'
23
+ gem 'capybara'
24
+ gem 'factory_girl', '= 1.3.3'
25
+ gem 'factory_girl_rails', '= 1.0.1'
26
+ gem 'faker'
27
+ gem 'launchy'
28
+
29
+ if RUBY_VERSION < "1.9"
30
+ gem "ruby-debug"
31
+ else
32
+ gem "ruby-debug19"
33
+ end
34
+ end
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jose Pablo Barrantes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
17
+ NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,3 @@
1
+ # PayPal Adaptive Payment for Spree
2
+
3
+ Initial disclaimer! This mess is gonna get raw, like sushi. So, haters to the left.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'yard'
5
+ require "bundler/gem_tasks"
6
+
7
+ desc "Default Task"
8
+ task :default => :test
9
+
10
+ Rake::TestTask.new
11
+
12
+ YARD::Rake::YardocTask.new do |t|
13
+ t.options += ['--verbose', '--title', "PayPal Adaptive Payments to Spree store"]
14
+ end
data/TAGS ADDED
@@ -0,0 +1,64 @@
1
+
2
+ db/migrate/20100226133156_create_paypal_adaptive_payment_accounts.rb,128
3
+ class CreatePaypalAccounts < ActiveRecord::MigrationCreatePaypalAccounts1,0
4
+ def self.upup2,53
5
+ def self.downdown12,251
6
+
7
+ spec/spec_helper.rb,32
8
+ def self.globalglobal35,989
9
+
10
+ spec/controllers/checkout_controller_spec.rb,0
11
+
12
+ spec/factories/order_factory.rb,0
13
+
14
+ spec/factories/state_factory.rb,0
15
+
16
+ spec/factories/address_factory.rb,0
17
+
18
+ config/routes.rb,0
19
+
20
+ app/controllers/checkout_controller_decorator.rb,887
21
+ def paypal_adaptive_payment_confirmpaypal_adaptive_payment_confirm6,192
22
+ def paypal_adaptive_payment_detailspaypal_adaptive_payment_details87,3119
23
+ def paypal_adaptive_payment_finishpaypal_adaptive_payment_finish101,3628
24
+ def record_log(payment, response)record_log160,5556
25
+ def redirect_to_paypal_adaptive_payment_form_if_neededredirect_to_paypal_adaptive_payment_form_if_needed164,5660
26
+ def fixed_optsfixed_opts179,6256
27
+ def order_opts(order, payment_method, stage)order_opts209,7591
28
+ def address_options(order)address_options266,10332
29
+ def all_opts(order, payment_method, stage=nil)all_opts287,11108
30
+ def flat_rate_shipping_and_handling_options(order, stage)flat_rate_shipping_and_handling_options301,11591
31
+ def gateway_error(response)gateway_error324,12573
32
+ def payment_methodpayment_method338,12924
33
+ def paypal_gatewaypaypal_gateway342,13003
34
+
35
+ app/controllers/paypal_adaptive_payment_callbacks_controller.rb,191
36
+ class PaypalAdaptivePaymentCallbacksController < Spree::BaseControllerPaypalAdaptivePaymentCallbacksController1,0
37
+ def notifynotify7,184
38
+ def retrieve_detailsretrieve_details32,875
39
+
40
+ app/models/paypal_adaptive_payment_account.rb,596
41
+ class PaypalAdaptivePaymentAccount < ActiveRecord::BasePaypalAdaptivePaymentAccount2,89
42
+ def actionsactions5,183
43
+ def capture(payment)capture9,227
44
+ def can_capture?(payment)can_capture?22,585
45
+ def credit(payment, amount=nil)credit26,672
46
+ def can_credit?(payment)can_credit?43,1294
47
+ def payment_gatewaypayment_gateway51,1561
48
+ def echeck?(payment)echeck?55,1600
49
+ def record_log(payment, response)record_log66,1896
50
+ def find_authorization(payment)find_authorization71,2010
51
+ def find_capture(payment)find_capture82,2378
52
+ def gateway_error(text)gateway_error94,2762
53
+
54
+ app/models/billing_integration/paypal_adaptive_payment.rb,134
55
+ class BillingIntegration::PaypalAdaptivePayment < BillingIntegrationBillingIntegration1,0
56
+ def provider_classprovider_class9,300
57
+
58
+ lib/spree_paypal_adaptive_payment_hooks.rb,110
59
+ class SpreePaypalAdaptivePaymentHooks < Spree::ThemeSupport::HookListenerSpreePaypalAdaptivePaymentHooks1,0
60
+
61
+ lib/spree_paypal_adaptive_payment.rb,147
62
+ module SpreePaypalAdaptivePaymentSpreePaypalAdaptivePayment4,68
63
+ class Engine < Rails::EngineEngine5,102
64
+ def self.activateactivate9,187
data/Versionfile ADDED
@@ -0,0 +1 @@
1
+ "0.1.0" => { :branch => "master" }
@@ -0,0 +1,25 @@
1
+ class BillingIntegration::PaypalAdaptivePayment < BillingIntegration
2
+ preference :login, :string
3
+ preference :password, :password
4
+ preference :signature, :string
5
+ preference :appid, :string
6
+ preference :review, :boolean, :default => false
7
+ preference :no_shipping, :boolean, :default => false
8
+ preference :currency, :string, :default => 'USD'
9
+
10
+ def provider_class
11
+ # This relies on https://github.com/jpablobr/active_paypal_adaptive_payment
12
+ ActiveMerchant::Billing::PaypalAdaptivePayment
13
+ end
14
+
15
+ # Spree requires this method for the profiles implementation.
16
+ # http://spreecommerce.com/documentation/checkout.html#payment-profiles
17
+ # def create_profile(payment); end
18
+
19
+ # Set this to true in order to display the confirm state
20
+ # in the checkout process...
21
+ def payment_profiles_supported?
22
+ false
23
+ end
24
+
25
+ end
@@ -0,0 +1,99 @@
1
+ # https://github.com/spree/spree_paypal_express/blob/master/app/models/paypal_account.rb
2
+ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
3
+ has_many :payments, :as => :source
4
+
5
+ def actions
6
+ %w{capture credit}
7
+ end
8
+
9
+ def capture(payment)
10
+ authorization = find_authorization(payment)
11
+
12
+ ppx_response = payment.payment_method.provider.capture((100 * payment.amount).to_i, authorization.params["transaction_id"])
13
+ if ppx_response.success?
14
+ record_log payment, ppx_response
15
+ payment.complete
16
+ else
17
+ gateway_error(ppx_response.message)
18
+ end
19
+
20
+ end
21
+
22
+ def can_capture?(payment)
23
+ !echeck?(payment) && payment.state == "pending"
24
+ end
25
+
26
+ def credit(payment, amount=nil)
27
+ authorization = find_capture(payment)
28
+
29
+ amount = payment.credit_allowed >= payment.order.outstanding_balance.abs ? payment.order.outstanding_balance : payment.credit_allowed
30
+
31
+ ppx_response = payment.payment_method.provider.credit(amount.nil? ? (100 * amount).to_i : (100 * amount).to_i, authorization.params['transaction_id'])
32
+
33
+ if ppx_response.success?
34
+ record_log payment, ppx_response
35
+ payment.update_attribute(:amount, payment.amount - amount)
36
+ payment.complete
37
+ payment.order.update!
38
+ else
39
+ gateway_error(ppx_response.message)
40
+ end
41
+ end
42
+
43
+ def can_credit?(payment)
44
+ return false unless payment.state == "completed"
45
+ return false unless payment.order.payment_state == "credit_owed"
46
+ payment.credit_allowed > 0
47
+ !find_capture(payment).nil?
48
+ end
49
+
50
+ # fix for Payment#payment_profiles_supported?
51
+ def payment_gateway
52
+ false
53
+ end
54
+
55
+ def echeck?(payment)
56
+ logs = payment.log_entries.all(:order => 'created_at DESC')
57
+ logs.each do |log|
58
+ details = YAML.load(log.details) # return the transaction details
59
+ if details.params['payment_type'] == 'echeck'
60
+ return true
61
+ end
62
+ end
63
+ return false
64
+ end
65
+
66
+ def record_log(payment, response)
67
+ payment.log_entries.create(:details => response.to_yaml)
68
+ end
69
+
70
+ private
71
+ def find_authorization(payment)
72
+ logs = payment.log_entries.all(:order => 'created_at DESC')
73
+ logs.each do |log|
74
+ details = YAML.load(log.details) # return the transaction details
75
+ if (details.params['payment_status'] == 'Pending' && details.params['pending_reason'] == 'authorization')
76
+ return details
77
+ end
78
+ end
79
+ return nil
80
+ end
81
+
82
+ def find_capture(payment)
83
+ #find the transaction associated with the original authorization/capture
84
+ logs = payment.log_entries.all(:order => 'created_at DESC')
85
+ logs.each do |log|
86
+ details = YAML.load(log.details) # return the transaction details
87
+ if details.params['payment_status'] == 'Completed'
88
+ return details
89
+ end
90
+ end
91
+ return nil
92
+ end
93
+
94
+ def gateway_error(text)
95
+ msg = "#{I18n.t('gateway_error')} ... #{text}"
96
+ logger.error(msg)
97
+ raise Spree::GatewayError.new(msg)
98
+ end
99
+ end
@@ -0,0 +1,9 @@
1
+ <% content_for :head do %>
2
+ <script type="text/javascript">
3
+ jQuery(document).ready(function(){
4
+ $("label:contains('<%= payment_method.name %>')").hide();
5
+ $("label:contains('<%= payment_method.name %>') input").disable();
6
+ });
7
+ </script>
8
+ <% end %>
9
+
@@ -0,0 +1,110 @@
1
+ <fieldset>
2
+ <legend><%= t('paypal_account') %></legend>
3
+
4
+ <table class="index">
5
+ <tr>
6
+ <th colspan="6"><%= t('account_details') %></th>
7
+ </tr>
8
+ <tr>
9
+ <td><label><%= t("email") %>:</label></td>
10
+ <td>
11
+ <%= payment.source.email %>
12
+ </td>
13
+ <td><label><%= t("payer_id") %>:</label></td>
14
+ <td>
15
+ <%= payment.source.payer_id %>
16
+ </td>
17
+ <td><label><%= t("payer_country") %>:</label></td>
18
+ <td>
19
+ <%= payment.source.payer_country %>
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <td><label><%= t("payer_status") %>:</label></td>
24
+ <td colspan="5">
25
+ <%= payment.source.payer_status %>
26
+ </td>
27
+ </tr>
28
+ </table>
29
+ </fieldset>
30
+
31
+ <fieldset>
32
+ <legend><%= t('transactions') %></legend>
33
+
34
+ <% payment.log_entries.reverse.each do |log| %>
35
+ <% details = YAML.load(log.details) rescue "" %>
36
+ <table class="index">
37
+
38
+ <% if details.is_a? ActiveMerchant::Billing::PaypalExpressResponse %>
39
+ <tr>
40
+ <th colspan="6"><%= t('transaction') %> <%= details.params["transaction_id"] %> - <%= log.created_at.to_s(:date_time24) %></th>
41
+ </tr>
42
+ <tr>
43
+ <td width="12%;"><label><%= t('type') %>:</label></td>
44
+ <td width="20%;">
45
+ <%= details.params["transaction_type"] %>
46
+ </td>
47
+ <td width="8%;"><label><%= t("result") %>:</label></td>
48
+ <td width="20%;">
49
+ <%= details.message %>
50
+ </td>
51
+ <td width="15%;"><label><%= t("amount") %>:</label></td>
52
+ <td width="20%;">
53
+ <%= number_to_currency details.params["gross_amount"] %>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <td><label><%= t("comment") %>:</label></td>
58
+ <td colspan="3">
59
+ <%= details.params["message"] %>
60
+ </td>
61
+ <td><label><%= t("status") %>:</label></td>
62
+ <td>
63
+ <%= details.params["payment_status"] %>
64
+ </td>
65
+ </tr>
66
+ <% if details.params["payment_status"] == "Pending" %>
67
+ <tr>
68
+ <td><label><%= t("pending_reason") %>:</label></td>
69
+ <td colspan="5">
70
+ <%= details.params["pending_reason"] %>
71
+ </td>
72
+ </tr>
73
+ <% end %>
74
+ <% elsif details.is_a? ActiveMerchant::Billing::Integrations::Paypal::Notification %>
75
+ <tr>
76
+ <th colspan="6"><%= t('ipn_transaction') %> <%= details.params["txn_id"] %> - <%= log.created_at.to_s(:date_time24) %></th>
77
+ </tr>
78
+ <tr>
79
+ <td width="12%;"><label><%= t('type') %>:</label></td>
80
+ <td width="20%;">
81
+ <%= details.params["txn_type"] %>
82
+ </td>
83
+ <td width="8%;"><label><%= t("result") %>:</label></td>
84
+ <td width="20%;">
85
+ <%= details.params["payment_status"] %>
86
+ </td>
87
+ <td width="15%;"><label><%= t("amount") %>:</label></td>
88
+ <td width="20%;">
89
+ <%= number_to_currency details.params["mc_gross"] %>
90
+ </td>
91
+ </tr>
92
+ <tr>
93
+ <td><label><%= t("status") %>:</label></td>
94
+ <td colspan="5">
95
+ <%= details.params["payment_status"] %>
96
+ </td>
97
+ </tr>
98
+ <% else %>
99
+ <tr>
100
+ <th colspan="6"><%= t('unknown_transaction') %> - <%= log.created_at.to_s(:date_time24) %></th>
101
+ </tr>
102
+ <tr>
103
+ <td colspan="6"><pre style="overflow: hidden; width:600px;"><%= log.details %></pre></th>
104
+ </tr>
105
+
106
+ <% end %>
107
+ </table>
108
+ <% end %>
109
+
110
+ </fieldset>
@@ -0,0 +1,15 @@
1
+ <%= render :partial => 'admin/shared/order_tabs', :locals => {:current => "Payments"} %>
2
+
3
+ <% form_tag do %>
4
+
5
+ <h3><%= t('refund') %></h3>
6
+ <fieldset>
7
+ <p>
8
+ <label for="amount"><%= t("amount") %></label>
9
+ <%= text_field_tag :amount, @paypal_payment.amount %>
10
+ </p>
11
+ <p class="form-buttons">
12
+ <%= button t("make_refund") %>
13
+ </p>
14
+ </fieldset>
15
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <fieldset id="order_details">
2
+ <div class="clear"></div>
3
+ <legend><%= t(@order.state, :scope => :order_state).titleize %></legend>
4
+ <%= render :partial => 'shared/order_details', :locals => {:order => @order} %>
5
+ </fieldset>
6
+
7
+ <hr />
8
+
9
+ <div class="form-buttons">
10
+ <input type="submit" class="continue button primary" value="<%=t("place_order") %>"/>
11
+ </div>
@@ -0,0 +1,25 @@
1
+ <fieldset id='shipping_method'>
2
+ <legend><%= t("shipping_method") %></legend>
3
+ <div class="inner">
4
+ <div id="methods">
5
+ <p class="field radios">
6
+ <% @order.rate_hash.each do |shipping_method| %>
7
+ <label>
8
+ <%= radio_button(:order, :shipping_method_id, shipping_method[:id]) %>
9
+ <%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %>
10
+ </label><br />
11
+ <% end %>
12
+ </p>
13
+ </div>
14
+ <% if Spree::Config[:shipping_instructions] && @order.rate_hash.present? %>
15
+ <p id="minstrs">
16
+ <%= form.label :special_instructions, t("shipping_instructions") %><br />
17
+ <%= form.text_area :special_instructions, :cols => 40, :rows => 7 %>
18
+ </p>
19
+ <% end %>
20
+ </div>
21
+ </fieldset>
22
+
23
+ <div class="form-buttons">
24
+ <input type="submit" class="continue button primary" value="<%=t("save_and_continue") %>"/>
25
+ </div>
@@ -0,0 +1,30 @@
1
+ <fieldset id="payment">
2
+ <legend><%= t("payment_information") %></legend>
3
+ <div data-hook="checkout_payment_step">
4
+ <% @order.available_payment_methods.each do |method| %>
5
+ <p>
6
+ <label>
7
+ <%= radio_button_tag "order[payments_attributes][][payment_method_id]", method.id, method == @order.payment_method %>
8
+ <%= t(method.name, :scope => :payment_methods, :default => method.name) %>
9
+ </label>
10
+ </p>
11
+ <% end %>
12
+
13
+ <ul id="payment-methods">
14
+ <% @order.available_payment_methods.each do |method| %>
15
+ <li id="payment_method_<%= method.id %>" class="<%= 'last' if method == @order.available_payment_methods.last %>">
16
+ <fieldset>
17
+ <%= render "checkout/payment/#{method.method_type}", :payment_method => method %>
18
+ </fieldset>
19
+ </li>
20
+ <% end %>
21
+ </ul>
22
+ <br style='clear:both;' />
23
+ <div data-hook="coupon_code_field"></div>
24
+ </div>
25
+ </fieldset>
26
+
27
+ <hr class="space" />
28
+ <div class="form-buttons">
29
+ <input type="submit" class="continue button primary" value="<%=t("save_and_continue") %>" />
30
+ </div>
@@ -0,0 +1,18 @@
1
+ <% content_for :head do %>
2
+ <%= javascript_include_tag 'checkout', '/states' %>
3
+ <% end %>
4
+ <div id="checkout">
5
+ <h1><%= t("checkout")%></h1>
6
+ <%= checkout_progress %>
7
+ <br clear="left" />
8
+ <%= render "shared/error_messages", :target => @order %>
9
+ <% if @order.state != 'confirm' %>
10
+ <div id="checkout-summary" data-hook="checkout_summary_box">
11
+ <%= render 'summary', :order => @order %>
12
+ </div>
13
+ <% end %>
14
+ <%= form_for @order, :url => update_checkout_path(@order.state), :html => { :id => "checkout_form_#{@order.state}" } do |form| %>
15
+ <%= render @order.state, :form => form %>
16
+ <input id="post-final" type="submit" style="display:none"/>
17
+ <% end %>
18
+ </div>
File without changes
@@ -0,0 +1,31 @@
1
+ <%= image_tag "creditcards/creditcard.gif", :id => 'creditcard-image' %>
2
+ <% param_prefix = "payment_source[#{payment_method.id}]" %>
3
+
4
+ <p class="field">
5
+ <label for=""><%= t("card_number") %></label><br />
6
+ <% options_hash = Rails.env.production? ? {:autocomplete => "off"} : {} %>
7
+ <%= text_field_tag "#{param_prefix}[number]", '', options_hash.merge(:id => 'card_number', :class => 'required', :size => 19, :maxlength => 19) %>
8
+ <span class="req">*</span>
9
+ &nbsp;
10
+ <span id="card_type" style="display:none;">
11
+ ( <span id="looks_like" ><%= t('card_type_is') %> <span id="type"></span></span>
12
+ <span id="unrecognized"><%= t('unrecognized_card_type') %></span>
13
+ )
14
+ </span>
15
+ </p>
16
+ <p class="field">
17
+ <label for=""><%= t("expiration") %></label><br />
18
+ <%= select_month(Date.today, :prefix => param_prefix, :field_name => 'month', :use_month_numbers => true, :class => 'required') %>
19
+ <%= select_year(Date.today, :prefix => param_prefix, :field_name => 'year', :start_year => Date.today.year, :end_year => Date.today.year + 15, :class => 'required') %>
20
+ <span class="req">*</span>
21
+ </p>
22
+ <p class="field">
23
+ <label for=""><%= t("card_code") %></label><br />
24
+ <%= text_field_tag "#{param_prefix}[verification_value]", '', options_hash.merge(:id => 'card_code', :class => 'required', :size => 5) %>
25
+ <span class="req">*</span>
26
+ <a href="/content/cvv" target="_blank" onclick="window.open(this.href,'cvv_info','left=20,top=20,width=500,height=500,toolbar=0,resizable=0,scrollbars=1');return false">
27
+ (<%= t("whats_this") %>)
28
+ </a>
29
+ </p>
30
+ <%= hidden_field param_prefix, 'first_name', :value => @order.billing_firstname %>
31
+ <%= hidden_field param_prefix, 'last_name', :value => @order.billing_lastname %>
@@ -0,0 +1,3 @@
1
+ <a href="<%= paypal_adaptive_payment_order_checkout_url @order, :payment_method_id => payment_method %>" style="text-align: center;">
2
+ <img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/>
3
+ </a>
@@ -0,0 +1,3 @@
1
+ <a href="<%= paypal_adaptive_payment_order_checkout_url @order, :payment_method_id => payment_method %>" style="text-align: center;">
2
+ <img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/>
3
+ </a>
@@ -0,0 +1,20 @@
1
+ <%= render "shared/error_messages", :target => @user %>
2
+ <h2><%= t("registration")%></h2>
3
+ <div id="registration">
4
+ <div id="account">
5
+ <!-- TODO: add partial with registration form -->
6
+ </div>
7
+ <% if Spree::Config[:allow_guest_checkout] %>
8
+ <div id="guest_checkout">
9
+ <%= render "shared/error_messages", :target => @order %>
10
+ <h2><%= t(:guest_user_account) %></h2>
11
+ <%= form_for @order, :url => update_checkout_registration_path, :html => { :method => :put, :id => "checkout_form_registration"} do |f| %>
12
+ <p>
13
+ <%= f.label :email, t("email") %><br />
14
+ <%= f.text_field :email, :class => 'title' %>
15
+ </p>
16
+ <p><%= submit_tag t("continue"), :class => 'button primary' %></p>
17
+ <% end %>
18
+ </div>
19
+ <% end %>
20
+ </div>
@@ -0,0 +1,3 @@
1
+ <a href="<%= paypal_checkout_orders_checkout_url @checkout.order, :integration_id => integration %>" style="text-align: center;">
2
+ <img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/>
3
+ </a>
@@ -0,0 +1,10 @@
1
+ <h1><%= t("confirm") %></h1>
2
+ <p>
3
+ <%= raw t("order_not_yet_placed") %>
4
+ </p>
5
+
6
+ <%= render :partial => 'shared/order_details', :locals => {:order => @order} -%>
7
+ <div class="form-buttons">
8
+ <%= button_to t('place_order'), paypal_finish_order_checkout_url(@order, {:token => params[:token] , :PayerID => params[:PayerID], :payment_method_id =>
9
+ params[:payment_method_id] } ), :class => "button primary" %>
10
+ </div>
@@ -0,0 +1,32 @@
1
+ ---
2
+ en:
3
+ ipn_transaction: IPN Transaction
4
+ unknown_transaction: Unknown Transaction
5
+ edit_paypal_info: Edit Paypal Express Payment
6
+ paypal_payment: Paypal Express Payment
7
+ paypal_txn_id: Transaction Code
8
+ paypal_capture_complete: Paypal Transaction has been captured.
9
+ unable_to_capture_paypal: Unable to capture Paypal Transaction.
10
+ signature: Signature
11
+ order_not_yet_placed: "Your order has <strong>NOT</strong> been be placed, please review the details and click <strong>Place Order</strong> below to finalize your order."
12
+ paypal_payment_id: PayPal Payment ID
13
+ pending_reason: Pending Reason
14
+ result: Result
15
+ review: Review
16
+ no_shipping: No Shipping
17
+ paypal_account: PayPal Account
18
+ payer_id: Payer ID
19
+ payer_country: Country
20
+ payer_status: Status
21
+ comment: Comment
22
+ account_details: Account Details
23
+ finalize:
24
+ paypaladaptive_payment: Capture Payment
25
+ activerecord:
26
+ attributes:
27
+ paypal_payment:
28
+ amount: Amount
29
+ models:
30
+ paypal_payment:
31
+ one: PayPal Payment
32
+ other: PayPal Payments
data/config/routes.rb ADDED
@@ -0,0 +1,26 @@
1
+ Rails.application.routes.draw do
2
+ resources :orders do
3
+ resource :checkout, :controller => 'checkout' do
4
+ member do
5
+ get :paypal_adaptive_payment_checkout
6
+ get :paypal_adaptive_payment
7
+ get :paypal_adaptive_payment_confirm
8
+ post :paypal_adaptive_payment_finish
9
+ end
10
+ end
11
+ end
12
+
13
+ match '/checkout/paypal_adaptive_payment_finish' => 'checkout#paypal_adaptive_payment_finish', :via => [:get, :post]
14
+ match '/paypal_adaptive_payment_notify' => 'paypal_adaptive_payment_callbacks#notify', :via => [:get, :post]
15
+
16
+ namespace :admin do
17
+ resources :orders do
18
+ resources :paypal_adaptive_payments do
19
+ member do
20
+ get :refund
21
+ get :capture
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end