effective_orders 5.9.3 → 5.9.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
  SHA256:
3
- metadata.gz: 9c21ba05da7239366ba59d58f08bc997193192c6b9cb83c93caade90b61072bd
4
- data.tar.gz: 965fe919c2c7a6537dd7b15427291cef1119c768ccd38cf1fdbcaf282b1fd95a
3
+ metadata.gz: 35bd45132852365a2cc570b4b6a7fbbf5cc62d42cd9f506710da80a0c77daf82
4
+ data.tar.gz: e97f9869c710bdfb91cfa35b6b0bc091b429b175cdc7af9b066283d02d90bac6
5
5
  SHA512:
6
- metadata.gz: 344e2cdaa0de66f512335a2c9da024de369713f34c84480a1b813b59874343bc4fc2ac81579f35ce718153346eb9e53826f46e657a5def99a6ff266b0f0aa45e
7
- data.tar.gz: 51f49f85b475d26fea9cfc593f627ed4e1c1761075d6fb508264419246485035995272e638da63cb5ed99635a9d7ff4b1aad0c1c34b8bc7c385e26eda737f069
6
+ metadata.gz: 02036ff52d79eaa0c47e6f2353f23b33d6168222abe6337a77880fb7c48d0c7de7b1960235ed2b2dcb9e304aac36b8bddbbf0f1132fee7395bed3638be80c2bd
7
+ data.tar.gz: 1929601f0588f3cefde7eec8ceec3f796b03822406e9ae1533507a783c3f0867a5c408f21a9954c12eaa225c912817044102c869d1a334660f328a80a9381a2c
@@ -13,7 +13,7 @@ module Effective
13
13
 
14
14
  payment = validate_stripe_payment(stripe_params[:payment_intent_id])
15
15
 
16
- if payment.blank? || !payment.kind_of?(Hash)
16
+ if payment.blank?
17
17
  return order_declined(payment: payment, provider: 'stripe', declined_url: stripe_params[:declined_url])
18
18
  end
19
19
 
@@ -37,36 +37,35 @@ module Effective
37
37
  end
38
38
 
39
39
  def validate_stripe_payment(payment_intent_id)
40
- begin
41
- intent = EffectiveOrders.with_stripe { ::Stripe::PaymentIntent.retrieve(payment_intent_id) }
42
-
43
- raise('status is not succeeded') unless intent.status == 'succeeded'
44
- raise('charges are not present') unless intent.charges.present?
45
-
46
- charge = intent.charges.data.first
47
- raise('charge not succeeded') unless charge.status == 'succeeded'
48
-
49
- card = charge.payment_method_details.try(:card) || {}
50
- active_card = "**** **** **** #{card['last4']} #{card['brand']} #{card['exp_month']}/#{card['exp_year']}" if card.present?
51
-
52
- {
53
- charge_id: charge.id,
54
- payment_method_id: charge.payment_method,
55
- payment_intent_id: intent.id,
56
-
57
- active_card: active_card,
58
- card: card['brand'],
59
-
60
- amount: charge.amount,
61
- created: charge.created,
62
- currency: charge.currency,
63
- customer: charge.customer,
64
- status: charge.status
65
- }.compact
66
-
67
- rescue => e
68
- e.message
69
- end
40
+ intent = EffectiveOrders.with_stripe { ::Stripe::PaymentIntent.retrieve(payment_intent_id) }
41
+ raise('expected stripe intent to be present') if intent.blank?
42
+ return unless intent.status == 'succeeded'
43
+
44
+ # Stripe API version 2022-11-15 and 2022-08-01
45
+ charge_id = intent.try(:latest_charge) || (intent.charges.data.first.id rescue nil)
46
+ raise('expected stripe charge_id to be present') if charge_id.blank?
47
+
48
+ charge = EffectiveOrders.with_stripe { ::Stripe::Charge.retrieve(charge_id) }
49
+ raise('expected stripe charge to be present') if charge.blank?
50
+ return unless charge.status == 'succeeded'
51
+
52
+ card = charge.payment_method_details.try(:card) || {}
53
+ active_card = "**** **** **** #{card['last4']} #{card['brand']} #{card['exp_month']}/#{card['exp_year']}" if card.present?
54
+
55
+ {
56
+ charge_id: charge.id,
57
+ payment_method_id: charge.payment_method,
58
+ payment_intent_id: intent.id,
59
+
60
+ active_card: active_card,
61
+ card: card['brand'],
62
+
63
+ amount: charge.amount,
64
+ created: charge.created,
65
+ currency: charge.currency,
66
+ customer: charge.customer,
67
+ status: charge.status
68
+ }.compact
70
69
  end
71
70
 
72
71
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.9.3'.freeze
2
+ VERSION = '5.9.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.3
4
+ version: 5.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2022-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails