effective_orders 5.4.4 → 5.5.0

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: 34d5d843d5364c956719f1e8a7dcc07425bb70cc04420e73e519dd4445fec4c7
4
- data.tar.gz: 64e70e869ab4150b7ee68954403b0f028fe6cabf650656f22ecc49f42b3d904e
3
+ metadata.gz: 9c608a4f1f72b5f82b0afe786bcc71ba8b951ff22e121ae2e2492afa08410966
4
+ data.tar.gz: fd836b344d52cb4cc9047aecc243dc2bf43d2b7b69bc0524331449e005e49789
5
5
  SHA512:
6
- metadata.gz: 591f04007fc784eacc6ed40ed74daf242de37930a9738dda370ce56edf6e21df8670cf5fc04765987970f69c2006841c2f9bcbb16fefb4e9412fb93da6443c75
7
- data.tar.gz: 017b2cee8f4425ced8d0ba7e375653816bb74bfb24b78e4b26ec8862e8ffa78dab0d04212466a11cee1de10bc1a953782ff95c76a3c53f91d815a7f20534bd10
6
+ metadata.gz: 4b7a575224a3cfbcbc271dcbce0f6e4b8d4943995696a3a57372356747faea7b454df6a2202d6c0b9a1ec55b8296ae78511665111841117066f4d2f4366881a4
7
+ data.tar.gz: d84ada9221fb3c57d2d92254e9925641a53a5bf772b143373616e239f22c4d52b88d131d9983d94a2d57e81cbdccf761a33e0e99d5da0941c7f462eff78307a1
@@ -335,6 +335,18 @@ module Effective
335
335
  else payment_card.to_s
336
336
  end
337
337
 
338
+ # Try again
339
+ if card == 'none' && payment['card_type'].present?
340
+ card = case payment['card_type'].to_s.downcase.gsub(' ', '').strip
341
+ when '' then nil
342
+ when 'v', 'visa' then 'Visa'
343
+ when 'm', 'mc', 'master', 'mastercard' then 'MasterCard'
344
+ when 'a', 'ax', 'american', 'americanexpress' then 'American Express'
345
+ when 'd', 'discover' then 'Discover'
346
+ else payment_card.to_s
347
+ end
348
+ end
349
+
338
350
  last4 = if payment[:active_card] && payment[:active_card].include?('**** **** ****')
339
351
  payment[:active_card][15,4]
340
352
  end
@@ -486,14 +498,18 @@ module Effective
486
498
 
487
499
  # Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
488
500
  def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false, skip_quickbooks: false)
501
+ return true if purchased?
502
+
489
503
  # Assign attributes
490
- self.state = EffectiveOrders::PURCHASED
491
- self.skip_buyer_validations = skip_buyer_validations
504
+ assign_attributes(
505
+ state: EffectiveOrders::PURCHASED,
506
+ skip_buyer_validations: skip_buyer_validations,
492
507
 
493
- self.payment_provider ||= provider
494
- self.payment_card ||= (card.presence || 'none')
495
- self.purchased_at ||= Time.zone.now
496
- self.payment = payment_to_h(payment) if self.payment.blank?
508
+ payment_provider: provider,
509
+ payment_card: (card.presence || 'none'),
510
+ purchased_at: Time.zone.now,
511
+ payment: payment_to_h(payment)
512
+ )
497
513
 
498
514
  begin
499
515
  Effective::Order.transaction do
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.4.4'.freeze
2
+ VERSION = '5.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.4
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect