spree_komoju 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb49e7926e73b422ef5265abb5fff354a2a9c4aa
4
- data.tar.gz: cc33f0b3f7852687708ada96fb1d7c42fd8363f9
3
+ metadata.gz: 4caf7c8b13c00f6893b7bc2af9a292cf25a867a8
4
+ data.tar.gz: e72a32999a83abfcd6db71cecd74a74e4a993be0
5
5
  SHA512:
6
- metadata.gz: c9a991202fbd2c1c0ab2de087d2f9bb64d1fcf4acafd02850e552d0247328d9cc4f8b310f1dce7ea09a1213bd07b57c706510ac6756d5b2e919c49af53a3e090
7
- data.tar.gz: b170a98fe37a3dad419ab1c058b13fc1ccc5e045e585a53cca48f0497bb33c496227dc8217ecbf9e4d3d6995c7bc70654f68106ac1f6b326560b441e0df93f0d
6
+ metadata.gz: 3ba55860027e52f8813c8eb1853ba8c603b09cbf03fb8a88e389e2d7d78a2edec94624e97874224d9d1086e5b54ebd2d4eeb190d070829c3dc8e68abdb3996e7
7
+ data.tar.gz: ed4021bfd231af61e80e834c073285c61c4b3fb66c909e3c1c72635f6812294a82e79177be855409476676c71cdb5c4b0690fa9a61ebd47caba4c325d04913c7
data/Gemfile CHANGED
@@ -4,5 +4,7 @@ gem 'spree', github: 'spree/spree', branch: '3-0-stable'
4
4
  gem 'activemerchant', github: "komoju/active_merchant", branch: "add-komoju-gateway"
5
5
  # Provides basic authentication functionality for testing parts of your engine
6
6
  gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
7
9
 
8
10
  gemspec
@@ -4,6 +4,11 @@ module Spree
4
4
  true
5
5
  end
6
6
 
7
+ def credit(money, source, response_code, gateway_options)
8
+ money = cents_to_dollar(money) if gateway_options[:currency] == "JPY"
9
+ provider.refund(money, response_code, {})
10
+ end
11
+
7
12
  def purchase(money, source, options)
8
13
  options = change_options_to_dollar(options) if options[:currency] == "JPY"
9
14
  if profile_id = source.gateway_payment_profile_id || source.gateway_customer_profile_id
@@ -41,5 +46,11 @@ module Spree
41
46
  def payment_profiles_supported?
42
47
  true
43
48
  end
49
+
50
+ private
51
+
52
+ def cents_to_dollar(amount)
53
+ amount / 100.0
54
+ end
44
55
  end
45
56
  end
@@ -49,6 +49,24 @@ describe Spree::Gateway::KomojuCreditCard, type: :model do
49
49
  end
50
50
  end
51
51
 
52
+ describe "#credit" do
53
+ let(:cent_amount) { 10000 }
54
+ let(:response_code) { "external_payment_id" }
55
+ let(:source) { double("credit card") }
56
+
57
+ it "receives cents amount" do
58
+ expect(komoju_gateway).to receive(:refund).with(cent_amount, response_code, {})
59
+ subject.credit(cent_amount, source, response_code, {})
60
+ end
61
+
62
+ context "when currency is JPY" do
63
+ it "receives dollar amount" do
64
+ expect(komoju_gateway).to receive(:refund).with(100.0, response_code, {})
65
+ subject.credit(cent_amount, source, response_code, {currency: "JPY"})
66
+ end
67
+ end
68
+ end
69
+
52
70
  describe "#create_profile" do
53
71
  let(:payment) { double("payment", source: source) }
54
72
  let(:details) { double("payment details") }
data/spree_komoju.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_komoju'
5
- s.version = '0.0.6'
5
+ s.version = '0.0.7'
6
6
  s.summary = 'Spree Komoju Payment Gateway'
7
7
  s.description = 'Spree Payment gateway for Komoju payment gateway'
8
8
  s.authors = ['Masahiro Saito', 'Chris Salzberg', 'Richard Ramsden']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_komoju
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Saito
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-17 00:00:00.000000000 Z
13
+ date: 2015-12-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: spree_core