alpha_card 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/CHANGELOG.md +21 -3
  4. data/Gemfile +0 -2
  5. data/Gemfile.lock +6 -24
  6. data/README.md +115 -85
  7. data/ROADMAP.md +13 -9
  8. data/alpha_card.gemspec +3 -4
  9. data/lib/alpha_card.rb +44 -72
  10. data/lib/alpha_card/account.rb +51 -0
  11. data/lib/alpha_card/attribute.rb +337 -0
  12. data/lib/alpha_card/data/credit_card_codes.yml +54 -54
  13. data/lib/alpha_card/errors/invalid_attribute_format.rb +14 -0
  14. data/lib/alpha_card/errors/invalid_attribute_type.rb +14 -0
  15. data/lib/alpha_card/errors/invalid_attribute_value.rb +14 -0
  16. data/lib/alpha_card/errors/{invalid_object_error.rb → validation_error.rb} +1 -1
  17. data/lib/alpha_card/{alpha_card_object.rb → resource.rb} +14 -28
  18. data/lib/alpha_card/resources/billing.rb +29 -0
  19. data/lib/alpha_card/{objects → resources}/order.rb +8 -8
  20. data/lib/alpha_card/{objects → resources}/shipping.rb +15 -13
  21. data/lib/alpha_card/{alpha_card_response.rb → response.rb} +21 -6
  22. data/lib/alpha_card/transaction.rb +30 -0
  23. data/lib/alpha_card/transactions/auth.rb +18 -0
  24. data/lib/alpha_card/transactions/capture.rb +32 -0
  25. data/lib/alpha_card/transactions/credit.rb +18 -0
  26. data/lib/alpha_card/{objects → transactions}/refund.rb +9 -2
  27. data/lib/alpha_card/transactions/sale.rb +91 -0
  28. data/lib/alpha_card/transactions/update.rb +61 -0
  29. data/lib/alpha_card/transactions/validate.rb +21 -0
  30. data/lib/alpha_card/transactions/void.rb +26 -0
  31. data/lib/alpha_card/version.rb +1 -1
  32. data/spec/alpha_card/attribute_spec.rb +126 -0
  33. data/spec/alpha_card/response_spec.rb +8 -4
  34. data/spec/alpha_card/transactions/auth_spec.rb +43 -0
  35. data/spec/alpha_card/{objects → transactions}/capture_spec.rb +11 -12
  36. data/spec/alpha_card/transactions/credit_spec.rb +102 -0
  37. data/spec/alpha_card/{objects → transactions}/refund_spec.rb +4 -4
  38. data/spec/alpha_card/{objects → transactions}/sale_spec.rb +42 -41
  39. data/spec/alpha_card/{objects → transactions}/update_spec.rb +4 -4
  40. data/spec/alpha_card/transactions/validate_spec.rb +100 -0
  41. data/spec/alpha_card/{objects → transactions}/void_spec.rb +11 -11
  42. data/spec/spec_helper.rb +4 -0
  43. metadata +36 -47
  44. data/lib/alpha_card/errors/alpha_card_error.rb +0 -29
  45. data/lib/alpha_card/objects/account.rb +0 -48
  46. data/lib/alpha_card/objects/billing.rb +0 -31
  47. data/lib/alpha_card/objects/capture.rb +0 -51
  48. data/lib/alpha_card/objects/sale.rb +0 -82
  49. data/lib/alpha_card/objects/update.rb +0 -54
  50. data/lib/alpha_card/objects/void.rb +0 -45
  51. data/spec/alpha_card/objects/account_spec.rb +0 -20
  52. data/spec/alpha_card/objects/deprecated_methods_spec.rb +0 -32
@@ -1,54 +0,0 @@
1
- module AlphaCard
2
- ##
3
- # Implementation of Alpha Card Services Update transaction.
4
- # Transaction updates can be used to update previous transactions
5
- # with specific order information, such as a tracking number
6
- # and shipping carrier.
7
- class Update < Void
8
- # Total shipping amount.
9
- # Format: x.xx
10
- attribute :shipping, String
11
- attribute :shipping_postal, String
12
- attribute :ship_from_postal, String
13
- attribute :shipping_country, String
14
- # Values: 'ups', 'fedex', 'dhl', or 'usps'
15
- attribute :shipping_carrier, String
16
- # Format: YYYYMMDD
17
- attribute :shipping_date, String
18
- attribute :order_description, String
19
- attribute :order_date, String
20
- # Values: 'true' or 'false'
21
- attribute :customer_receipt, String
22
- attribute :po_number, String
23
- attribute :summary_commodity_code, String
24
- # Format: x.xx
25
- attribute :duty_amount, String
26
- # Format: x.xx
27
- attribute :discount_amount, String
28
- # Format: x.xx
29
- attribute :tax, String
30
- # Format: x.xx
31
- attribute :national_tax_amount, String
32
- # Format: x.xx
33
- attribute :alternate_tax_amount, String
34
- attribute :alternate_tax_id, String
35
- attribute :vat_tax_amount, String
36
- attribute :vat_tax_rate, String
37
- attribute :vat_invoice_reference_number, String
38
- attribute :customer_vat_registration, String
39
- attribute :merchant_vat_registration, String
40
-
41
- ##
42
- # Transaction type (default is 'update')
43
- #
44
- # @attribute [r] type
45
- attribute :type, String, default: 'update', writer: :private
46
-
47
- ##
48
- # Original AlphaCard transaction variables names
49
- ORIGIN_TRANSACTION_VARIABLES = {
50
- transaction_id: :transactionid,
51
- po_number: :ponumber
52
- }.freeze
53
- end
54
- end
@@ -1,45 +0,0 @@
1
- module AlphaCard
2
- ##
3
- # Implementation of Alpha Card Services Void transaction.
4
- class Void < AlphaCardObject
5
- attribute :transaction_id, String
6
-
7
- ##
8
- # Transaction type (default is 'void')
9
- #
10
- # @attribute [r] type
11
- attribute :type, String, default: 'void', writer: :private
12
-
13
- ##
14
- # Original AlphaCard transaction variables names
15
- ORIGIN_TRANSACTION_VARIABLES = {
16
- transaction_id: :transactionid
17
- }.freeze
18
-
19
- ##
20
- # Creates void transaction with the <code>AlphaCard::Account</code> credentials.
21
- #
22
- # @param [AlphaCard::Account] account
23
- # An <code>AlphaCard::Account</code> object.
24
- #
25
- # @return [Boolean]
26
- # True if transaction was created successfully.
27
- # Raise an AlphaCardError exception if some error occurred.
28
- #
29
- # @raise [AlphaCard::InvalidObjectError]
30
- # Exception if one of required attributes doesn't specified.
31
- #
32
- # @example
33
- # account = AlphaCard::Account.new('demo', 'password')
34
- # void = AlphaCard::Void.new(transaction_id: '981562')
35
- # void.create(account)
36
- #
37
- # #=> [true, #<AlphaCard::AlphaCardResponse:0x1a0fda ...>]
38
- def create(account)
39
- abort_if_attributes_blank!(:transaction_id)
40
-
41
- response = AlphaCard.request(account, attributes_for_request)
42
- [response.success?, response]
43
- end
44
- end
45
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AlphaCard::Account do
4
- let(:valid_account) { AlphaCard::Account.new('demo', 'password') }
5
- let(:invalid_account) { AlphaCard::Account.new('', '') }
6
-
7
- describe '#filled?' do
8
- context 'with filled credentials' do
9
- it 'returns true' do
10
- expect(valid_account.filled?).to be_truthy
11
- end
12
- end
13
-
14
- context 'with blank credentials' do
15
- it 'returns false' do
16
- expect(invalid_account.filled?).to be_falsey
17
- end
18
- end
19
- end
20
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'AlphaCard objects deprecated methods' do
4
- def warn_writer(old_method, new_method)
5
- "[DEPRECATION] #{old_method}= is deprecated! Please, use #{new_method}= instead\n"
6
- end
7
-
8
- def warn_reader(old_method, new_method)
9
- "[DEPRECATION] #{old_method} is deprecated! Please, use #{new_method} instead\n"
10
- end
11
-
12
- it 'warns with deprecation message for AlphaCard::Sale' do
13
- AlphaCard::Sale::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
14
- expect { AlphaCard::Sale.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
15
- expect { AlphaCard::Sale.new.send(old) }.to output(warn_reader(old, new)).to_stderr
16
- end
17
- end
18
-
19
- it 'warns with deprecation message for AlphaCard::Billing' do
20
- AlphaCard::Billing::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
21
- expect { AlphaCard::Billing.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
22
- expect { AlphaCard::Billing.new.send(old) }.to output(warn_reader(old, new)).to_stderr
23
- end
24
- end
25
-
26
- it 'warns with deprecation message for AlphaCard::Shipping' do
27
- AlphaCard::Shipping::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
28
- expect { AlphaCard::Shipping.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
29
- expect { AlphaCard::Shipping.new.send(old) }.to output(warn_reader(old, new)).to_stderr
30
- end
31
- end
32
- end