alpha_card 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +21 -3
- data/Gemfile +0 -2
- data/Gemfile.lock +6 -24
- data/README.md +115 -85
- data/ROADMAP.md +13 -9
- data/alpha_card.gemspec +3 -4
- data/lib/alpha_card.rb +44 -72
- data/lib/alpha_card/account.rb +51 -0
- data/lib/alpha_card/attribute.rb +337 -0
- data/lib/alpha_card/data/credit_card_codes.yml +54 -54
- data/lib/alpha_card/errors/invalid_attribute_format.rb +14 -0
- data/lib/alpha_card/errors/invalid_attribute_type.rb +14 -0
- data/lib/alpha_card/errors/invalid_attribute_value.rb +14 -0
- data/lib/alpha_card/errors/{invalid_object_error.rb → validation_error.rb} +1 -1
- data/lib/alpha_card/{alpha_card_object.rb → resource.rb} +14 -28
- data/lib/alpha_card/resources/billing.rb +29 -0
- data/lib/alpha_card/{objects → resources}/order.rb +8 -8
- data/lib/alpha_card/{objects → resources}/shipping.rb +15 -13
- data/lib/alpha_card/{alpha_card_response.rb → response.rb} +21 -6
- data/lib/alpha_card/transaction.rb +30 -0
- data/lib/alpha_card/transactions/auth.rb +18 -0
- data/lib/alpha_card/transactions/capture.rb +32 -0
- data/lib/alpha_card/transactions/credit.rb +18 -0
- data/lib/alpha_card/{objects → transactions}/refund.rb +9 -2
- data/lib/alpha_card/transactions/sale.rb +91 -0
- data/lib/alpha_card/transactions/update.rb +61 -0
- data/lib/alpha_card/transactions/validate.rb +21 -0
- data/lib/alpha_card/transactions/void.rb +26 -0
- data/lib/alpha_card/version.rb +1 -1
- data/spec/alpha_card/attribute_spec.rb +126 -0
- data/spec/alpha_card/response_spec.rb +8 -4
- data/spec/alpha_card/transactions/auth_spec.rb +43 -0
- data/spec/alpha_card/{objects → transactions}/capture_spec.rb +11 -12
- data/spec/alpha_card/transactions/credit_spec.rb +102 -0
- data/spec/alpha_card/{objects → transactions}/refund_spec.rb +4 -4
- data/spec/alpha_card/{objects → transactions}/sale_spec.rb +42 -41
- data/spec/alpha_card/{objects → transactions}/update_spec.rb +4 -4
- data/spec/alpha_card/transactions/validate_spec.rb +100 -0
- data/spec/alpha_card/{objects → transactions}/void_spec.rb +11 -11
- data/spec/spec_helper.rb +4 -0
- metadata +36 -47
- data/lib/alpha_card/errors/alpha_card_error.rb +0 -29
- data/lib/alpha_card/objects/account.rb +0 -48
- data/lib/alpha_card/objects/billing.rb +0 -31
- data/lib/alpha_card/objects/capture.rb +0 -51
- data/lib/alpha_card/objects/sale.rb +0 -82
- data/lib/alpha_card/objects/update.rb +0 -54
- data/lib/alpha_card/objects/void.rb +0 -45
- data/spec/alpha_card/objects/account_spec.rb +0 -20
- data/spec/alpha_card/objects/deprecated_methods_spec.rb +0 -32
@@ -1,62 +1,62 @@
|
|
1
1
|
"AP": 'Approved or completed successfully'
|
2
|
-
"CALL AE": 'Refer to American Express
|
3
|
-
"CALL CB": 'Refer to Carte Blanche
|
4
|
-
"CALL DC": 'Refer to Diners Club
|
5
|
-
"CALL DISCOVER": 'Refer to Discover
|
6
|
-
"CALL JB": 'Refer to JBS
|
7
|
-
"CALL ND": 'Call your Visa/MasterCard Voice Authorization Center
|
8
|
-
"CALL TC": 'Refer to TeleCredit
|
9
|
-
"CALL TK": 'Refer to TeleCheck
|
10
|
-
"CALL WC": 'Refer to Worldcheck
|
11
|
-
"CALL XXXXXXXXXX": 'Call indicated number
|
12
|
-
"ISSUER UNAVAIL": 'NDC cannot contact issuing bank for authorization
|
13
|
-
"INVLD MERCH ID": 'Invalid Merchant ID
|
14
|
-
"PIC UP": 'Authorization declined
|
15
|
-
"DECLINE": 'Authorization declined
|
16
|
-
"REVERSED": 'Requested transaction reversal was successful
|
17
|
-
"AP WITH ID": 'Approved with positive ID. NDC Host does not capture this transaction
|
2
|
+
"CALL AE": 'Refer to American Express'
|
3
|
+
"CALL CB": 'Refer to Carte Blanche'
|
4
|
+
"CALL DC": 'Refer to Diners Club'
|
5
|
+
"CALL DISCOVER": 'Refer to Discover'
|
6
|
+
"CALL JB": 'Refer to JBS'
|
7
|
+
"CALL ND": 'Call your Visa/MasterCard Voice Authorization Center'
|
8
|
+
"CALL TC": 'Refer to TeleCredit'
|
9
|
+
"CALL TK": 'Refer to TeleCheck'
|
10
|
+
"CALL WC": 'Refer to Worldcheck'
|
11
|
+
"CALL XXXXXXXXXX": 'Call indicated number'
|
12
|
+
"ISSUER UNAVAIL": 'NDC cannot contact issuing bank for authorization'
|
13
|
+
"INVLD MERCH ID": 'Invalid Merchant ID'
|
14
|
+
"PIC UP": 'Authorization declined'
|
15
|
+
"DECLINE": 'Authorization declined'
|
16
|
+
"REVERSED": 'Requested transaction reversal was successful'
|
17
|
+
"AP WITH ID": 'Approved with positive ID. NDC Host does not capture this transaction'
|
18
18
|
"INVLD SERV ID": 'Service ID number is incorrect'
|
19
|
-
"INVALID REQUEST": 'Administrative message contains a syntax error
|
20
|
-
"INVLD TRAN CODE": 'Processing code entered is incorrect. Please refer to valid processing code
|
21
|
-
"INVLD AMOUNT": 'Amount entered is not valid
|
19
|
+
"INVALID REQUEST": 'Administrative message contains a syntax error'
|
20
|
+
"INVLD TRAN CODE": 'Processing code entered is incorrect. Please refer to valid processing code'
|
21
|
+
"INVLD AMOUNT": 'Amount entered is not valid'
|
22
22
|
"INVLD ACCT": 'Account number does not pass issuer’s edit checks'
|
23
|
-
"INVLD CODE ACCT": 'Valid account number matched with a transaction code for a different card type
|
24
|
-
"PLEASE RETRY": 'NDC’s user tables are set up incorrectly for this account
|
25
|
-
"INVLD EMP DATE": 'NDC GATEWAY requests a retry
|
26
|
-
"PIN INVALID": 'Expired date entered is incorrect
|
27
|
-
"UNAUTH TRANS": 'Incorrect PIN entered
|
28
|
-
"MAX PIN RETRIES": 'A transaction code was used for which you are not setup on the Merchant Master File
|
29
|
-
"AP DUPE": 'Maximum PIN number entry attempts exceeded
|
30
|
-
"IN ACCT MATCH": 'Transaction entered is a duplicate
|
31
|
-
"INV AMT MATCH": 'The account number entered during a void or adjustment transaction does not match the account number stored in the NDC Host for that item
|
32
|
-
"INV ITEM NUM": 'The item number entered for a void or adjustment transaction is incorrect
|
33
|
-
"ITEM VOIDED": 'An adjustment or item review was attempted on a transaction previously voided or reversed
|
34
|
-
"ITEM REVERSED": 'An adjustment or item review was attempted on a transaction previously voided or reversed
|
35
|
-
"MUST BALANCE NOW": 'Terminal has not been balanced within time specified in the NDC Merchant Master File for this merchant
|
36
|
-
"USE DUP THEN BAL": 'Terminal has not been balanced within time specified in the NDC Merchant Master File for this merchant, but merchant is set up to perform extra transactions before balancing
|
37
|
-
"NO DUP FOUND": 'Override transaction is at tempted on a non-duplicated transaction
|
38
|
-
"INVALID DATA": 'Format of the transaction is incorrect
|
39
|
-
"NO TRANS FOUND": 'Reversal transaction is attempted on a transaction that is not in the open batch on the host
|
23
|
+
"INVLD CODE ACCT": 'Valid account number matched with a transaction code for a different card type'
|
24
|
+
"PLEASE RETRY": 'NDC’s user tables are set up incorrectly for this account'
|
25
|
+
"INVLD EMP DATE": 'NDC GATEWAY requests a retry'
|
26
|
+
"PIN INVALID": 'Expired date entered is incorrect'
|
27
|
+
"UNAUTH TRANS": 'Incorrect PIN entered'
|
28
|
+
"MAX PIN RETRIES": 'A transaction code was used for which you are not setup on the Merchant Master File'
|
29
|
+
"AP DUPE": 'Maximum PIN number entry attempts exceeded'
|
30
|
+
"IN ACCT MATCH": 'Transaction entered is a duplicate'
|
31
|
+
"INV AMT MATCH": 'The account number entered during a void or adjustment transaction does not match the account number stored in the NDC Host for that item'
|
32
|
+
"INV ITEM NUM": 'The item number entered for a void or adjustment transaction is incorrect'
|
33
|
+
"ITEM VOIDED": 'An adjustment or item review was attempted on a transaction previously voided or reversed'
|
34
|
+
"ITEM REVERSED": 'An adjustment or item review was attempted on a transaction previously voided or reversed'
|
35
|
+
"MUST BALANCE NOW": 'Terminal has not been balanced within time specified in the NDC Merchant Master File for this merchant'
|
36
|
+
"USE DUP THEN BAL": 'Terminal has not been balanced within time specified in the NDC Merchant Master File for this merchant, but merchant is set up to perform extra transactions before balancing'
|
37
|
+
"NO DUP FOUND": 'Override transaction is at tempted on a non-duplicated transaction'
|
38
|
+
"INVALID DATA": 'Format of the transaction is incorrect'
|
39
|
+
"NO TRANS FOUND": 'Reversal transaction is attempted on a transaction that is not in the open batch on the host'
|
40
40
|
"AP NOT CAPTURED": 'Approved but not captured (applied to only credit card transactions).'
|
41
|
-
"AP AUTH-ONLY": 'Approved but this EDC merchant is not set up to capture this card type (applies only to credit card transactions)
|
42
|
-
"INV BANK": 'Acquiring Bank ID entered is incorrect
|
43
|
-
"TRAN TYPE INVLD": 'Transaction not supported by EFT network or EFT Group ID is incorrect
|
44
|
-
"APPROVED": 'Merchant is not set up for debit on NDC Merchant Master File
|
41
|
+
"AP AUTH-ONLY": 'Approved but this EDC merchant is not set up to capture this card type (applies only to credit card transactions)'
|
42
|
+
"INV BANK": 'Acquiring Bank ID entered is incorrect'
|
43
|
+
"TRAN TYPE INVLD": 'Transaction not supported by EFT network or EFT Group ID is incorrect'
|
44
|
+
"APPROVED": 'Merchant is not set up for debit on NDC Merchant Master File'
|
45
45
|
"DB UNAVAIL 02": 'NDC GATEWAY is down'
|
46
|
-
"DB UNAVAIL 03": 'NDC GATEWAY Link ID timed out
|
47
|
-
"DB UNAVAIL 04": 'NDC GATEWAY cannot contact EFT network or EFT Group ID is incorrect
|
48
|
-
"UNAUTH USER": 'Merchant is not set up for debit on NDC Merchant Master File
|
49
|
-
"INVALID CARD": 'Debit card not on issuer file
|
46
|
+
"DB UNAVAIL 03": 'NDC GATEWAY Link ID timed out'
|
47
|
+
"DB UNAVAIL 04": 'NDC GATEWAY cannot contact EFT network or EFT Group ID is incorrect'
|
48
|
+
"UNAUTH USER": 'Merchant is not set up for debit on NDC Merchant Master File'
|
49
|
+
"INVALID CARD": 'Debit card not on issuer file'
|
50
50
|
"DB ISSUER UNAVAIL": 'EFT network cannot contact issuer'
|
51
|
-
"INVALID POS CARD": 'Card is not eligible for POS
|
51
|
+
"INVALID POS CARD": 'Card is not eligible for POS'
|
52
52
|
"ACCT TYPE INVLD": 'Type of account entered cannot be accessed (checking, savings, etc.)'
|
53
|
-
"INVALID PREFIX": 'No sharing arrangement for this card
|
54
|
-
"INVALID FIID NDC GATEWAY": 'Financial Institution ID not set up
|
55
|
-
"VERIFY XXXXXXXXXX": 'Match on SCAN file. XXXXXXXXXX is routing/transit number on the negative file
|
56
|
-
"INVALID LIC": 'The license or ID number entered during a check authorization transaction is incorrect
|
57
|
-
"INVALID STATE CD": 'State code entered is incorrect
|
58
|
-
"EDC UNAVAILABLE": 'EDC application down, try later
|
59
|
-
"DB UNAVAIL 01": 'Problem at NDC routing transaction
|
60
|
-
"SCAN UNAVAILABLE": 'SCAN application is down, try later
|
61
|
-
"EXCEEDS MAX AMT": 'Exceeds withdrawal amount limit
|
53
|
+
"INVALID PREFIX": 'No sharing arrangement for this card'
|
54
|
+
"INVALID FIID NDC GATEWAY": 'Financial Institution ID not set up'
|
55
|
+
"VERIFY XXXXXXXXXX": 'Match on SCAN file. XXXXXXXXXX is routing/transit number on the negative file'
|
56
|
+
"INVALID LIC": 'The license or ID number entered during a check authorization transaction is incorrect'
|
57
|
+
"INVALID STATE CD": 'State code entered is incorrect'
|
58
|
+
"EDC UNAVAILABLE": 'EDC application down, try later'
|
59
|
+
"DB UNAVAIL 01": 'Problem at NDC routing transaction'
|
60
|
+
"SCAN UNAVAILABLE": 'SCAN application is down, try later'
|
61
|
+
"EXCEEDS MAX AMT": 'Exceeds withdrawal amount limit'
|
62
62
|
"EXCEEDS MAX USES": 'Exceeds withdrawal frequency limit'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# AlphaCard resource attributes format error
|
4
|
+
class InvalidAttributeFormat < StandardError
|
5
|
+
# Exception constructor. Returns an error with message about wrong
|
6
|
+
# attribute format.
|
7
|
+
#
|
8
|
+
# @param value [Object] current attribute value
|
9
|
+
# @param format [Regexp] required format
|
10
|
+
def initialize(value, format)
|
11
|
+
super("'#{value}' does not match the '#{format.inspect}' format")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# AlphaCard resource attributes value error
|
4
|
+
class InvalidAttributeType < StandardError
|
5
|
+
# Exception constructor. Returns an error with message about
|
6
|
+
# wrong attribute value type.
|
7
|
+
#
|
8
|
+
# @param value [Object] current attribute value
|
9
|
+
# @param types [Array] possible attribute types
|
10
|
+
def initialize(value, types)
|
11
|
+
super("'#{value}' must be an instance of #{types.join(', ')}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# AlphaCard resource attributes value error
|
4
|
+
class InvalidAttributeValue < StandardError
|
5
|
+
# Exception constructor. Returns an error with message about wrong value
|
6
|
+
# and possible values.
|
7
|
+
#
|
8
|
+
# @param value [Object] current attribute value
|
9
|
+
# @param values [Array] possible attribute values
|
10
|
+
def initialize(value, values)
|
11
|
+
super("'#{value}' is invalid attribute value. Use one from the following: #{values.join(', ')}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module AlphaCard
|
2
2
|
##
|
3
|
-
#
|
4
|
-
|
5
|
-
class AlphaCardObject
|
3
|
+
# Alpha Card resource base class.
|
4
|
+
class Resource
|
6
5
|
# Attributes DSL
|
7
|
-
include
|
6
|
+
include AlphaCard::Attribute
|
8
7
|
|
9
8
|
##
|
10
9
|
# Original AlphaCard transaction variables names
|
@@ -14,15 +13,16 @@ module AlphaCard
|
|
14
13
|
# Returns only filled attributes with the original Alpha Card Services
|
15
14
|
# transaction variables names.
|
16
15
|
#
|
17
|
-
# @param [Hash]
|
16
|
+
# @param attrs [Hash]
|
18
17
|
# Attributes that must be converted to AlphaCard request params/
|
19
18
|
# Default value is <code>filled_attributes</code>.
|
20
19
|
#
|
21
20
|
# @example
|
22
21
|
# order = AlphaCard::Order.new(id: '1', tax: nil, po_number: 'PO123')
|
23
|
-
# order.
|
22
|
+
# order.attributes_for_request
|
24
23
|
#
|
25
24
|
# #=> { orderid: '1', ponumber: 'PO123' }
|
25
|
+
#
|
26
26
|
def attributes_for_request(attrs = filled_attributes)
|
27
27
|
return attrs if self.class::ORIGIN_TRANSACTION_VARIABLES.empty?
|
28
28
|
|
@@ -31,22 +31,6 @@ module AlphaCard
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
##
|
35
|
-
# Deprecate old transaction variables names.
|
36
|
-
def self.deprecate_old_variables!
|
37
|
-
self::ORIGIN_TRANSACTION_VARIABLES.each do |new_attr, old_attr|
|
38
|
-
define_method "#{old_attr}=" do |value|
|
39
|
-
warn "[DEPRECATION] #{old_attr}= is deprecated! Please, use #{new_attr}= instead"
|
40
|
-
self[new_attr] = value
|
41
|
-
end
|
42
|
-
|
43
|
-
define_method old_attr do
|
44
|
-
warn "[DEPRECATION] #{old_attr} is deprecated! Please, use #{new_attr} instead"
|
45
|
-
self[new_attr]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
34
|
protected
|
51
35
|
|
52
36
|
##
|
@@ -66,14 +50,16 @@ module AlphaCard
|
|
66
50
|
end
|
67
51
|
|
68
52
|
##
|
69
|
-
# Validate
|
53
|
+
# Validate required attributes to be filled. Raises an exception
|
70
54
|
# if one of the attribute is not specified.
|
71
55
|
#
|
72
|
-
# @
|
73
|
-
#
|
74
|
-
def
|
75
|
-
|
76
|
-
|
56
|
+
# @raise [AlphaCard::InvalidObjectError] error if required attributes not set
|
57
|
+
#
|
58
|
+
def validate_required_attributes!
|
59
|
+
unless required_attributes?
|
60
|
+
blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? }
|
61
|
+
|
62
|
+
raise ValidationError, "#{blank_attribute} can't be blank"
|
77
63
|
end
|
78
64
|
end
|
79
65
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# Implementation of Alpha Card Services order billing information.
|
4
|
+
# Contains all the billing information (customer name, email, email, etc).
|
5
|
+
class Billing < Resource
|
6
|
+
attribute :first_name, type: String
|
7
|
+
attribute :last_name, type: String
|
8
|
+
attribute :email, type: String
|
9
|
+
attribute :phone, type: String
|
10
|
+
attribute :company, type: String
|
11
|
+
attribute :address_1, type: String
|
12
|
+
attribute :address_2, type: String
|
13
|
+
attribute :city, type: String
|
14
|
+
attribute :state, type: String, format: /\A[A-Za-z]{2}\z/.freeze
|
15
|
+
attribute :zip, type: String
|
16
|
+
attribute :country, type: String, format: /\A[A-Za-z]{2}\z/.freeze
|
17
|
+
attribute :fax, type: String
|
18
|
+
attribute :website, type: String
|
19
|
+
|
20
|
+
##
|
21
|
+
# Original AlphaCard transaction variables names
|
22
|
+
ORIGIN_TRANSACTION_VARIABLES = {
|
23
|
+
first_name: :firstname,
|
24
|
+
last_name: :lastname,
|
25
|
+
address_1: :address1,
|
26
|
+
address_2: :address2
|
27
|
+
}.freeze
|
28
|
+
end
|
29
|
+
end
|
@@ -2,16 +2,16 @@ module AlphaCard
|
|
2
2
|
##
|
3
3
|
# Implementation of Alpha Card Services Order object.
|
4
4
|
# Contains all the information about order (id, description, etc).
|
5
|
-
class Order <
|
6
|
-
attribute :id
|
7
|
-
attribute :description, String
|
8
|
-
attribute :po_number, String
|
9
|
-
attribute :tax, String
|
5
|
+
class Order < Resource
|
6
|
+
attribute :id
|
7
|
+
attribute :description, type: String
|
8
|
+
attribute :po_number, type: String
|
9
|
+
attribute :tax, type: String
|
10
10
|
# Format: xxx.xxx.xxx.xxx
|
11
|
-
attribute :ip_address,
|
11
|
+
attribute :ip_address, format: /\A(?:[0-9]{1,3}\.){3}[0-9]{1,3}\z/.freeze
|
12
12
|
|
13
|
-
attribute :billing, AlphaCard::Billing
|
14
|
-
attribute :shipping, AlphaCard::Shipping
|
13
|
+
attribute :billing, type: AlphaCard::Billing
|
14
|
+
attribute :shipping, type: AlphaCard::Shipping
|
15
15
|
|
16
16
|
##
|
17
17
|
# Original AlphaCard transaction variables names
|
@@ -2,17 +2,19 @@ module AlphaCard
|
|
2
2
|
##
|
3
3
|
# Implementation of Alpha Card Services order shipping information.
|
4
4
|
# Contains all the shipping information (address, city, zip, etc).
|
5
|
-
class Shipping <
|
6
|
-
attribute :first_name, String
|
7
|
-
attribute :last_name, String
|
8
|
-
attribute :company, String
|
9
|
-
attribute :address_1, String
|
10
|
-
attribute :address_2, String
|
11
|
-
attribute :city, String
|
12
|
-
|
13
|
-
attribute :
|
14
|
-
attribute :
|
15
|
-
|
5
|
+
class Shipping < Resource
|
6
|
+
attribute :first_name, type: String
|
7
|
+
attribute :last_name, type: String
|
8
|
+
attribute :company, type: String
|
9
|
+
attribute :address_1, type: String
|
10
|
+
attribute :address_2, type: String
|
11
|
+
attribute :city, type: String
|
12
|
+
# Format: 'CC'
|
13
|
+
attribute :state, type: String, format: /\A[A-Za-z]{2}\z/.freeze
|
14
|
+
attribute :zip_code, type: String
|
15
|
+
# Format: 'CC'
|
16
|
+
attribute :country, type: String, format: /\A[A-Za-z]{2}\z/.freeze
|
17
|
+
attribute :email, type: String
|
16
18
|
|
17
19
|
##
|
18
20
|
# Original AlphaCard transaction variables names
|
@@ -23,7 +25,7 @@ module AlphaCard
|
|
23
25
|
address_2: :address2
|
24
26
|
}.freeze
|
25
27
|
|
26
|
-
|
28
|
+
protected
|
27
29
|
|
28
30
|
##
|
29
31
|
# Overloaded <code>filled_attributes</code> method from
|
@@ -35,7 +37,7 @@ module AlphaCard
|
|
35
37
|
# Only filled attributes of Shipping resource with "shipping_" prefix.
|
36
38
|
#
|
37
39
|
# @example
|
38
|
-
# shipping = AlphaCard::Shipping.new(
|
40
|
+
# shipping = AlphaCard::Shipping.new(first_name: 'John', state: 'NY')
|
39
41
|
# shipping.filled_attributes
|
40
42
|
#
|
41
43
|
# #=> { shipping_firstname: 'John', shipping_state: 'NY' }
|
@@ -3,7 +3,7 @@ module AlphaCard
|
|
3
3
|
# Implementation of Alpha Card Services response.
|
4
4
|
# Contains all the data, that Alpha Card Gateway
|
5
5
|
# returned for the request.
|
6
|
-
class
|
6
|
+
class Response
|
7
7
|
# Alpha Card Gateway response as a <code>Hash</code>.
|
8
8
|
# @attr_reader [Hash] data
|
9
9
|
attr_reader :data
|
@@ -25,17 +25,17 @@ module AlphaCard
|
|
25
25
|
RESPONSE_MESSAGES = YAML.load_file(File.expand_path('../data/response_messages.yml', __FILE__)).freeze
|
26
26
|
|
27
27
|
##
|
28
|
-
#
|
28
|
+
# Alpha Card Response constructor.
|
29
29
|
#
|
30
|
-
# @param [String]
|
30
|
+
# @param response_body [String]
|
31
31
|
# Alpha Card Gateway response body text
|
32
32
|
#
|
33
|
-
# @return [
|
33
|
+
# @return [Response] Alpha Card Response object
|
34
34
|
#
|
35
35
|
# @example
|
36
|
-
# AlphaCard::
|
36
|
+
# AlphaCard::Response.new('response=1&responsetext=Test')
|
37
37
|
#
|
38
|
-
# #=> #<AlphaCard::
|
38
|
+
# #=> #<AlphaCard::Response:0x00000003f2b568 @data={"response"=>"1", "responsetext"=>"Test"}>
|
39
39
|
def initialize(response_body)
|
40
40
|
@data = Rack::Utils.parse_query(response_body)
|
41
41
|
end
|
@@ -130,6 +130,21 @@ module AlphaCard
|
|
130
130
|
@data['authcode']
|
131
131
|
end
|
132
132
|
|
133
|
+
# Credit Card Authorization Message based on returned code in accordance with
|
134
|
+
# the Global Payment Systems Credit Card Authorization Codes (codes.yml).
|
135
|
+
#
|
136
|
+
# @return [String] auth message
|
137
|
+
#
|
138
|
+
# @example
|
139
|
+
#
|
140
|
+
# response = AlphaCardResponse.new("response_text=AP")
|
141
|
+
# response.credit_card_auth_message
|
142
|
+
#
|
143
|
+
# #=> 'Approved or completed successfully'
|
144
|
+
def credit_card_auth_message
|
145
|
+
AlphaCard::CREDIT_CARD_CODES[text]
|
146
|
+
end
|
147
|
+
|
133
148
|
##
|
134
149
|
# Indicate the state of the request to the
|
135
150
|
# Alpha Card Gateway. Returns <i>true</i> if
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# Base Alpha Card transaction object.
|
4
|
+
class Transaction < Resource
|
5
|
+
##
|
6
|
+
# Creates transaction.
|
7
|
+
#
|
8
|
+
# @param credentials [Hash]
|
9
|
+
# Alpha Card merchant account credentials.
|
10
|
+
#
|
11
|
+
# @return [AlphaCard::Response]
|
12
|
+
# AlphaCard Gateway response with all the information about transaction.
|
13
|
+
#
|
14
|
+
# @raise [AlphaCard::InvalidObjectError]
|
15
|
+
# Exception if one of required attributes doesn't specified.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# void = AlphaCard::Void.new(transaction_id: '981562')
|
19
|
+
# void.create
|
20
|
+
#
|
21
|
+
# #=> #<AlphaCard::Response:0x1a0fda ...>
|
22
|
+
def process(credentials = Account.credentials)
|
23
|
+
validate_required_attributes!
|
24
|
+
|
25
|
+
AlphaCard.request(attributes_for_request, credentials)
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :create, :process
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module AlphaCard
|
2
|
+
##
|
3
|
+
# Implementation of Alpha Card Services Authorization transaction.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# auth = AlphaCard::Auth.new(card_expiration_date: '0117', card_number: '4111111111111111', amount: '1.00')
|
7
|
+
# auth.create(order)
|
8
|
+
#
|
9
|
+
# #=> #<AlphaCard::Response:0x1a0fda ...>
|
10
|
+
#
|
11
|
+
class Auth < Sale
|
12
|
+
##
|
13
|
+
# Transaction type (default is 'auth')
|
14
|
+
#
|
15
|
+
# @attribute [r] type
|
16
|
+
attribute :type, default: 'auth', writable: false
|
17
|
+
end
|
18
|
+
end
|