spree_paypal_adaptive_payment 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,18 +9,18 @@ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
9
9
  def capture(payment)
10
10
  authorization = find_authorization(payment)
11
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
12
+ ap_response = payment.payment_method.provider.capture((100 * payment.amount).to_i, authorization.params["transaction"]["0"][".id"])
13
+ if ap_response.success?
14
+ record_log payment, ap_response
15
15
  payment.complete
16
16
  else
17
- gateway_error(ppx_response.message)
17
+ gateway_error(ap_response.message)
18
18
  end
19
19
 
20
20
  end
21
21
 
22
22
  def can_capture?(payment)
23
- !echeck?(payment) && payment.state == "pending"
23
+ !echeck?(payment) && payment.state == "PENDING"
24
24
  end
25
25
 
26
26
  def credit(payment, amount=nil)
@@ -28,21 +28,20 @@ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
28
28
 
29
29
  amount = payment.credit_allowed >= payment.order.outstanding_balance.abs ? payment.order.outstanding_balance : payment.credit_allowed
30
30
 
31
- ppx_response = payment.payment_method.provider.credit(amount.nil? ? (100 * amount).to_i : (100 * amount).to_i, authorization.params['transaction_id'])
31
+ ap_response = payment.payment_method.provider.credit(amount.nil? ? (100 * amount).to_i : (100 * amount).to_i, authorization.params["transaction"]["0"][".id"])
32
32
 
33
- if ppx_response.success?
34
- record_log payment, ppx_response
33
+ if ap_response.success?
34
+ record_log payment, ap_response
35
35
  payment.update_attribute(:amount, payment.amount - amount)
36
36
  payment.complete
37
37
  payment.order.update!
38
38
  else
39
- gateway_error(ppx_response.message)
39
+ gateway_error(ap_response.message)
40
40
  end
41
41
  end
42
42
 
43
43
  def can_credit?(payment)
44
- return false unless payment.state == "completed"
45
- return false unless payment.order.payment_state == "credit_owed"
44
+ return false unless payment.state == "COMPLETED"
46
45
  payment.credit_allowed > 0
47
46
  !find_capture(payment).nil?
48
47
  end
@@ -56,7 +55,7 @@ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
56
55
  logs = payment.log_entries.all(:order => 'created_at DESC')
57
56
  logs.each do |log|
58
57
  details = YAML.load(log.details) # return the transaction details
59
- if details.params['payment_type'] == 'echeck'
58
+ if details.params['type'] == 'echeck'
60
59
  return true
61
60
  end
62
61
  end
@@ -72,7 +71,7 @@ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
72
71
  logs = payment.log_entries.all(:order => 'created_at DESC')
73
72
  logs.each do |log|
74
73
  details = YAML.load(log.details) # return the transaction details
75
- if (details.params['payment_status'] == 'Pending' && details.params['pending_reason'] == 'authorization')
74
+ if (details.params['status'] == 'PENDING')
76
75
  return details
77
76
  end
78
77
  end
@@ -84,8 +83,8 @@ class PaypalAdaptivePaymentAccount < ActiveRecord::Base
84
83
  logs = payment.log_entries.all(:order => 'created_at DESC')
85
84
  logs.each do |log|
86
85
  details = YAML.load(log.details) # return the transaction details
87
- if details.params['payment_status'] == 'Completed'
88
- return details
86
+ if details.params['status'] == 'COMPLETED'
87
+ RETURN details
89
88
  end
90
89
  end
91
90
  return nil
@@ -10,7 +10,6 @@ Rails.application.routes.draw do
10
10
  end
11
11
  end
12
12
 
13
- match '/checkout/paypal_adaptive_payment_finish' => 'checkout#paypal_adaptive_payment_finish', :via => [:get, :post]
14
13
  match '/paypal_adaptive_payment_notify' => 'paypal_adaptive_payment_callbacks#notify', :via => [:get, :post]
15
14
 
16
15
  namespace :admin do
@@ -1,6 +1,6 @@
1
- class CreatePaypalAccounts < ActiveRecord::Migration
1
+ class CreatePaypalAdaptivePaymentAccounts < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :paypal_accounts do |t|
3
+ create_table :paypal_adaptive_payment_accounts do |t|
4
4
  t.string :email
5
5
  t.string :payer_id
6
6
  t.string :appid
@@ -10,6 +10,6 @@ class CreatePaypalAccounts < ActiveRecord::Migration
10
10
  end
11
11
 
12
12
  def self.down
13
- drop_table :paypal_accounts
13
+ drop_table :paypal_adaptive_payment_accounts
14
14
  end
15
15
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = 'spree_paypal_adaptive_payment'
4
- s.version = '0.1.0'
4
+ s.version = '0.1.1'
5
5
  s.summary = 'Add PayPal Adaptive Payments to Spree store'
6
6
  s.homepage = 'https://github.com/jpablobr/spree_paypal_adaptive_payment'
7
7
  s.author = 'Jose Pablo Barrantes'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_paypal_adaptive_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-24 00:00:00.000000000Z
12
+ date: 2011-10-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
- requirement: &14882820 !ruby/object:Gem::Requirement
16
+ requirement: &20746840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.40.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14882820
24
+ version_requirements: *20746840
25
25
  description:
26
26
  email: xjpalobrx@gmail.com
27
27
  executables: []
@@ -29,7 +29,9 @@ extensions: []
29
29
  extra_rdoc_files: []
30
30
  files:
31
31
  - .gitignore
32
+ - .rvmrc
32
33
  - Gemfile
34
+ - Gemfile.lock
33
35
  - MIT-LICENSE.txt
34
36
  - README.markdown
35
37
  - Rakefile
@@ -103,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  version: '0'
104
106
  requirements: []
105
107
  rubyforge_project:
106
- rubygems_version: 1.8.8
108
+ rubygems_version: 1.8.10
107
109
  signing_key:
108
110
  specification_version: 3
109
111
  summary: Add PayPal Adaptive Payments to Spree store
110
112
  test_files: []
111
- has_rdoc: false