pixelpay_sdk 1.0.0.pre.beta.1
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 +7 -0
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +19 -0
- data/Rakefile +16 -0
- data/bitbucket-pipelines.yml +27 -0
- data/lib/pixelpay_sdk/assets/countries.json +247 -0
- data/lib/pixelpay_sdk/assets/formats.json +982 -0
- data/lib/pixelpay_sdk/assets/states.json +3944 -0
- data/lib/pixelpay_sdk/base/Helpers.rb +92 -0
- data/lib/pixelpay_sdk/base/RequestBehaviour.rb +31 -0
- data/lib/pixelpay_sdk/base/Response.rb +78 -0
- data/lib/pixelpay_sdk/base/ServiceBehaviour.rb +237 -0
- data/lib/pixelpay_sdk/entities/CardResult.rb +79 -0
- data/lib/pixelpay_sdk/entities/TransactionResult.rb +104 -0
- data/lib/pixelpay_sdk/exceptions/InvalidCredentialsException.rb +6 -0
- data/lib/pixelpay_sdk/exceptions/InvalidTransactionTypeException.rb +6 -0
- data/lib/pixelpay_sdk/models/Billing.rb +27 -0
- data/lib/pixelpay_sdk/models/Card.rb +36 -0
- data/lib/pixelpay_sdk/models/Item.rb +36 -0
- data/lib/pixelpay_sdk/models/Order.rb +93 -0
- data/lib/pixelpay_sdk/models/Settings.rb +93 -0
- data/lib/pixelpay_sdk/request/AuthTransaction.rb +7 -0
- data/lib/pixelpay_sdk/request/CaptureTransaction.rb +19 -0
- data/lib/pixelpay_sdk/request/CardTokenization.rb +97 -0
- data/lib/pixelpay_sdk/request/PaymentTransaction.rb +179 -0
- data/lib/pixelpay_sdk/request/SaleTransaction.rb +7 -0
- data/lib/pixelpay_sdk/request/StatusTransaction.rb +16 -0
- data/lib/pixelpay_sdk/request/VoidTransaction.rb +19 -0
- data/lib/pixelpay_sdk/resources/Environment.rb +9 -0
- data/lib/pixelpay_sdk/resources/Locations.rb +44 -0
- data/lib/pixelpay_sdk/responses/ErrorResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/FailureResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/InputErrorResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/NetworkFailureResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/NoAccessResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/NotFoundResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/PayloadResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/PaymentDeclinedResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/PreconditionalResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/SuccessResponse.rb +8 -0
- data/lib/pixelpay_sdk/responses/TimeoutResponse.rb +8 -0
- data/lib/pixelpay_sdk/services/Tokenization.rb +65 -0
- data/lib/pixelpay_sdk/services/Transaction.rb +108 -0
- data/lib/pixelpay_sdk/version.rb +5 -0
- data/lib/pixelpay_sdk.rb +20 -0
- data/pixelpay_sdk.gemspec +38 -0
- data/sig/pixelpay_sdk.rbs +4 -0
- metadata +97 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../base/Helpers"
|
4
|
+
require_relative "../base/ServiceBehaviour"
|
5
|
+
require_relative "../base/RequestBehaviour"
|
6
|
+
require_relative "../models/Settings"
|
7
|
+
|
8
|
+
BASE_CARD_PATH = "api/v2/tokenization/card"
|
9
|
+
|
10
|
+
# Tokenization provides a specific structure for a tokenization to be performed.
|
11
|
+
class Tokenization < ServiceBehaviour
|
12
|
+
# Vault credit/debit card and obtain a token card identifier (T-* format).
|
13
|
+
# Args:
|
14
|
+
# card (CardTokenization): input card.
|
15
|
+
# Returns:
|
16
|
+
# Response: processed response.
|
17
|
+
def vault_card(card)
|
18
|
+
Helpers.verify_type(TypeError, CardTokenization, card.instance_of?(CardTokenization))
|
19
|
+
|
20
|
+
post(BASE_CARD_PATH, card)
|
21
|
+
rescue StandardError => e
|
22
|
+
e
|
23
|
+
end
|
24
|
+
|
25
|
+
# Update credit/debit card by token card identifier.
|
26
|
+
# Args:
|
27
|
+
# token (string): input token.
|
28
|
+
# card (CardTokenization): input card.
|
29
|
+
# Returns:
|
30
|
+
# Response: processed response.
|
31
|
+
def update_card(token, card)
|
32
|
+
Helpers.verify_type(TypeError, CardTokenization, card.instance_of?(CardTokenization))
|
33
|
+
|
34
|
+
put("#{BASE_CARD_PATH}/#{token}", card)
|
35
|
+
rescue StandardError => e
|
36
|
+
e
|
37
|
+
end
|
38
|
+
|
39
|
+
# Show credit/debit card metadata by token card identifier.
|
40
|
+
# Args:
|
41
|
+
# token (string): input token.
|
42
|
+
# Returns:
|
43
|
+
# Response: processed response.
|
44
|
+
def show_card(token)
|
45
|
+
get("#{BASE_CARD_PATH}/#{token}", RequestBehaviour.new)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Show multiple credit/debit cards metadata by token card identifiers.
|
49
|
+
# Args:
|
50
|
+
# tokens (array): input token.
|
51
|
+
# Returns:
|
52
|
+
# Response: processed response.
|
53
|
+
def show_cards(tokens)
|
54
|
+
get("#{BASE_CARD_PATH}/#{tokens.join(":")}", RequestBehaviour.new)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Delete credit/debit card metadata by token card identifier.
|
58
|
+
# Args:
|
59
|
+
# token (string): input token.
|
60
|
+
# Returns:
|
61
|
+
# Response: processed response.
|
62
|
+
def delete_card(token)
|
63
|
+
delete("#{BASE_CARD_PATH}/#{token}", RequestBehaviour.new)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../base/Helpers"
|
4
|
+
require_relative "../base/ServiceBehaviour"
|
5
|
+
require_relative "../request/StatusTransaction"
|
6
|
+
require_relative "../exceptions/InvalidTransactionTypeException"
|
7
|
+
|
8
|
+
# Transaction provides a specific structure for a transaction to be performed.
|
9
|
+
class Transaction < ServiceBehaviour
|
10
|
+
# Evaluate if 3DS transactions is enable.
|
11
|
+
# Args:
|
12
|
+
# transaction (PaymentTransaction) : input.
|
13
|
+
def eval_authentication_transaction(transaction)
|
14
|
+
Helpers.verify_type(TypeError, PaymentTransaction, transaction.is_a?(PaymentTransaction))
|
15
|
+
|
16
|
+
if transaction.authentication_request
|
17
|
+
raise InvalidTransactionTypeException, "This platform does not support 3DS transactions."
|
18
|
+
end
|
19
|
+
rescue StandardError => e
|
20
|
+
e
|
21
|
+
end
|
22
|
+
|
23
|
+
# Send and proccesing SALE transaction.
|
24
|
+
# Args:
|
25
|
+
# transaction (SaleTransaction): input.
|
26
|
+
# Returns:
|
27
|
+
# Response: processed response.
|
28
|
+
def do_sale(transaction)
|
29
|
+
Helpers.verify_type(TypeError, SaleTransaction, transaction.instance_of?(SaleTransaction))
|
30
|
+
|
31
|
+
err = eval_authentication_transaction(transaction)
|
32
|
+
raise InvalidTransactionTypeException, err.message if err.instance_of?(InvalidTransactionTypeException)
|
33
|
+
|
34
|
+
post("api/v2/transaction/sale", transaction)
|
35
|
+
rescue StandardError => e
|
36
|
+
e
|
37
|
+
end
|
38
|
+
|
39
|
+
# Send and proccesing AUTH transaction.
|
40
|
+
# Args:
|
41
|
+
# transaction (AuthTransaction): input.
|
42
|
+
# Returns:
|
43
|
+
# Response: processed response.
|
44
|
+
def do_auth(transaction)
|
45
|
+
Helpers.verify_type(TypeError, AuthTransaction, transaction.instance_of?(AuthTransaction))
|
46
|
+
|
47
|
+
err = eval_authentication_transaction(transaction)
|
48
|
+
raise InvalidTransactionTypeException, err.message if err.instance_of?(InvalidTransactionTypeException)
|
49
|
+
|
50
|
+
post("api/v2/transaction/auth", transaction)
|
51
|
+
rescue StandardError => e
|
52
|
+
e
|
53
|
+
end
|
54
|
+
|
55
|
+
# Send and proccesing CAPTURE transaction.
|
56
|
+
# Args:
|
57
|
+
# transaction (CaptureTransaction): input.
|
58
|
+
# Returns:
|
59
|
+
# Response: processed response.
|
60
|
+
def do_capture(transaction)
|
61
|
+
Helpers.verify_type(TypeError, CaptureTransaction, transaction.instance_of?(CaptureTransaction))
|
62
|
+
|
63
|
+
post("api/v2/transaction/capture", transaction)
|
64
|
+
rescue StandardError => e
|
65
|
+
e
|
66
|
+
end
|
67
|
+
|
68
|
+
# Send and proccesing VOID transaction.
|
69
|
+
# Args:
|
70
|
+
# transaction (VoidTransaction): input.
|
71
|
+
# Returns:
|
72
|
+
# Response: processed response.
|
73
|
+
def do_void(transaction)
|
74
|
+
Helpers.verify_type(TypeError, VoidTransaction, transaction.instance_of?(VoidTransaction))
|
75
|
+
|
76
|
+
post("api/v2/transaction/void", transaction)
|
77
|
+
rescue StandardError => e
|
78
|
+
e
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get transaction status
|
82
|
+
# Args:
|
83
|
+
# transaction (StatusTransaction): input.
|
84
|
+
# Returns:
|
85
|
+
# Response: processed response.
|
86
|
+
def get_status(transaction)
|
87
|
+
Helpers.verify_type(TypeError, StatusTransaction, transaction.instance_of?(StatusTransaction))
|
88
|
+
|
89
|
+
post("api/v2/transaction/status", transaction)
|
90
|
+
rescue StandardError => e
|
91
|
+
e
|
92
|
+
end
|
93
|
+
|
94
|
+
# Verifies a payment hash and returns true if payment response has not been modified.
|
95
|
+
# Args:
|
96
|
+
# hash (string): the hash that will be compared with the order hash.
|
97
|
+
# orderId (string): parameter represents the order hash to look up.
|
98
|
+
# secret (string): parameter is a key used to verify the payment hash.
|
99
|
+
# Returns:
|
100
|
+
# bool: true or false.
|
101
|
+
def verify_payment_hash(hash, order_id, secret)
|
102
|
+
values = []
|
103
|
+
values.append(order_id.to_s, settings.auth_key.to_s, secret.to_s)
|
104
|
+
chain = values.join("|")
|
105
|
+
|
106
|
+
hash.to_s.upcase == Helpers.hash("MD5", chain).upcase
|
107
|
+
end
|
108
|
+
end
|
data/lib/pixelpay_sdk.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "pixelpay_sdk/models/Billing"
|
4
|
+
require_relative "pixelpay_sdk/models/Card"
|
5
|
+
require_relative "pixelpay_sdk/models/Item"
|
6
|
+
require_relative "pixelpay_sdk/models/Order"
|
7
|
+
require_relative "pixelpay_sdk/models/Settings"
|
8
|
+
|
9
|
+
require_relative "pixelpay_sdk/request/AuthTransaction"
|
10
|
+
require_relative "pixelpay_sdk/request/CaptureTransaction"
|
11
|
+
require_relative "pixelpay_sdk/request/CardTokenization"
|
12
|
+
require_relative "pixelpay_sdk/request/PaymentTransaction"
|
13
|
+
require_relative "pixelpay_sdk/request/StatusTransaction"
|
14
|
+
require_relative "pixelpay_sdk/request/VoidTransaction"
|
15
|
+
|
16
|
+
require_relative "pixelpay_sdk/services/Tokenization"
|
17
|
+
require_relative "pixelpay_sdk/services/Transaction"
|
18
|
+
|
19
|
+
require_relative "pixelpay_sdk/entities/CardResult"
|
20
|
+
require_relative "pixelpay_sdk/entities/TransactionResult"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/pixelpay_sdk/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "pixelpay_sdk"
|
7
|
+
spec.version = PixelpaySdk::VERSION
|
8
|
+
spec.authors = ["Sonia Villeda", "Oscar Gómez"]
|
9
|
+
spec.email = ["sonia@pixel.hn", "oscar@pixel.hn"]
|
10
|
+
|
11
|
+
spec.summary = "PixelPay SDK toolkit."
|
12
|
+
spec.homepage = "https://pixel.hn"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
# Uncomment to register a new dependency of your gem
|
34
|
+
# spec.add_dependency "json", "~> 2.6", ">= 2.6.3"
|
35
|
+
|
36
|
+
# For more information and examples about making a new gem, check out our
|
37
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pixelpay_sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.beta.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sonia Villeda
|
8
|
+
- Oscar Gómez
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- sonia@pixel.hn
|
17
|
+
- oscar@pixel.hn
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".rubocop.yml"
|
23
|
+
- CHANGELOG.md
|
24
|
+
- CONTRIBUTING.md
|
25
|
+
- Gemfile
|
26
|
+
- Gemfile.lock
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- bitbucket-pipelines.yml
|
31
|
+
- lib/pixelpay_sdk.rb
|
32
|
+
- lib/pixelpay_sdk/assets/countries.json
|
33
|
+
- lib/pixelpay_sdk/assets/formats.json
|
34
|
+
- lib/pixelpay_sdk/assets/states.json
|
35
|
+
- lib/pixelpay_sdk/base/Helpers.rb
|
36
|
+
- lib/pixelpay_sdk/base/RequestBehaviour.rb
|
37
|
+
- lib/pixelpay_sdk/base/Response.rb
|
38
|
+
- lib/pixelpay_sdk/base/ServiceBehaviour.rb
|
39
|
+
- lib/pixelpay_sdk/entities/CardResult.rb
|
40
|
+
- lib/pixelpay_sdk/entities/TransactionResult.rb
|
41
|
+
- lib/pixelpay_sdk/exceptions/InvalidCredentialsException.rb
|
42
|
+
- lib/pixelpay_sdk/exceptions/InvalidTransactionTypeException.rb
|
43
|
+
- lib/pixelpay_sdk/models/Billing.rb
|
44
|
+
- lib/pixelpay_sdk/models/Card.rb
|
45
|
+
- lib/pixelpay_sdk/models/Item.rb
|
46
|
+
- lib/pixelpay_sdk/models/Order.rb
|
47
|
+
- lib/pixelpay_sdk/models/Settings.rb
|
48
|
+
- lib/pixelpay_sdk/request/AuthTransaction.rb
|
49
|
+
- lib/pixelpay_sdk/request/CaptureTransaction.rb
|
50
|
+
- lib/pixelpay_sdk/request/CardTokenization.rb
|
51
|
+
- lib/pixelpay_sdk/request/PaymentTransaction.rb
|
52
|
+
- lib/pixelpay_sdk/request/SaleTransaction.rb
|
53
|
+
- lib/pixelpay_sdk/request/StatusTransaction.rb
|
54
|
+
- lib/pixelpay_sdk/request/VoidTransaction.rb
|
55
|
+
- lib/pixelpay_sdk/resources/Environment.rb
|
56
|
+
- lib/pixelpay_sdk/resources/Locations.rb
|
57
|
+
- lib/pixelpay_sdk/responses/ErrorResponse.rb
|
58
|
+
- lib/pixelpay_sdk/responses/FailureResponse.rb
|
59
|
+
- lib/pixelpay_sdk/responses/InputErrorResponse.rb
|
60
|
+
- lib/pixelpay_sdk/responses/NetworkFailureResponse.rb
|
61
|
+
- lib/pixelpay_sdk/responses/NoAccessResponse.rb
|
62
|
+
- lib/pixelpay_sdk/responses/NotFoundResponse.rb
|
63
|
+
- lib/pixelpay_sdk/responses/PayloadResponse.rb
|
64
|
+
- lib/pixelpay_sdk/responses/PaymentDeclinedResponse.rb
|
65
|
+
- lib/pixelpay_sdk/responses/PreconditionalResponse.rb
|
66
|
+
- lib/pixelpay_sdk/responses/SuccessResponse.rb
|
67
|
+
- lib/pixelpay_sdk/responses/TimeoutResponse.rb
|
68
|
+
- lib/pixelpay_sdk/services/Tokenization.rb
|
69
|
+
- lib/pixelpay_sdk/services/Transaction.rb
|
70
|
+
- lib/pixelpay_sdk/version.rb
|
71
|
+
- pixelpay_sdk.gemspec
|
72
|
+
- sig/pixelpay_sdk.rbs
|
73
|
+
homepage: https://pixel.hn
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata:
|
77
|
+
homepage_uri: https://pixel.hn
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.6.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.3.1
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.1.6
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: PixelPay SDK toolkit.
|
97
|
+
test_files: []
|