magnetik 0.0.3 → 0.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d2a41951a797368d04c1fc74b1d21d99a7758fb
|
4
|
+
data.tar.gz: 774b86a2abd008380b4b830856b3dd4dbf5f4e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a3ec948e1b15807794eba7bbf27b8bf692a1a713159b125bc625cd062a80c927fd32705208ddbe6ed075dc31520c0843a9387034743025ded54128c0c54fd9
|
7
|
+
data.tar.gz: 42f6f4b8df3bfd19b3f6497e8baf294cd361dd1f8920721998bb328dce42b60820058d436fc4ea3026e8dd9171be7d6601fb6a0e24d1da250b3e490e6b245992
|
@@ -12,7 +12,7 @@ module Magnetik
|
|
12
12
|
|
13
13
|
def create
|
14
14
|
@token = create_params[:token]
|
15
|
-
@use_case = CreateCreditCard.perform(
|
15
|
+
@use_case = CreateCreditCard.perform(customer, @token)
|
16
16
|
|
17
17
|
if @use_case.success?
|
18
18
|
render json: { credit_card: @use_case.local_card }, status: :ok
|
@@ -53,6 +53,10 @@ module Magnetik
|
|
53
53
|
@user ||= method(Magnetik.current_user_method).call
|
54
54
|
end
|
55
55
|
|
56
|
+
def customer
|
57
|
+
@customer ||= user
|
58
|
+
end
|
59
|
+
|
56
60
|
def collection
|
57
61
|
@credit_cards ||= user.credit_cards.limit(30)
|
58
62
|
end
|
@@ -4,14 +4,14 @@ module Magnetik
|
|
4
4
|
|
5
5
|
attr_reader :local_card
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@token
|
9
|
-
@
|
7
|
+
def initialize(actor, token)
|
8
|
+
@token = token
|
9
|
+
@actor = actor
|
10
10
|
@remote_customer = nil
|
11
11
|
end
|
12
12
|
|
13
13
|
def perform
|
14
|
-
if @
|
14
|
+
if @actor.has_stripe_customer?
|
15
15
|
fetch_customer
|
16
16
|
else
|
17
17
|
create_remote_customer
|
@@ -28,7 +28,7 @@ module Magnetik
|
|
28
28
|
attr_reader :remote_customer, :remote_card
|
29
29
|
|
30
30
|
def fetch_customer
|
31
|
-
@remote_customer = Stripe::Customer.retrieve(@
|
31
|
+
@remote_customer = Stripe::Customer.retrieve(@actor.stripe_customer_id)
|
32
32
|
end
|
33
33
|
|
34
34
|
def create_remote_customer
|
@@ -38,7 +38,7 @@ module Magnetik
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def create_local_customer
|
41
|
-
@
|
41
|
+
@actor.update_attributes(stripe_customer_id: remote_customer.id).tap do |success|
|
42
42
|
errors.add(:base, "User failed to save") unless success
|
43
43
|
end
|
44
44
|
end
|
@@ -52,7 +52,7 @@ module Magnetik
|
|
52
52
|
|
53
53
|
def create_local_card
|
54
54
|
@local_card = CreditCard.new({
|
55
|
-
customer: @
|
55
|
+
customer: @actor,
|
56
56
|
stripe_card_id: remote_card[:id],
|
57
57
|
last_4_digits: remote_card[:last4],
|
58
58
|
exp_month: remote_card[:exp_month],
|
data/lib/magnetik/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magnetik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Ivanopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|