pixelpay_sdk 1.0.2 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acc458f77dc08528d9e7a2b97dadb9a4ee5d31d2fad16bd614ff4d9cbc489b71
4
- data.tar.gz: 7577d6ee6549ee9dcb8fe5eabc513812908446e7cffcbece7e402b4f9db73e08
3
+ metadata.gz: 594dac058ce11835e6f1999b2214753ac5cb7ff8d47caeb628be1640bba2d749
4
+ data.tar.gz: cd484011f1f79aad821c0fe61d8dd182bd128d2e78fd3dbed3641ef53e9d19d9
5
5
  SHA512:
6
- metadata.gz: f4fc2e5dda0a61e715ab3e1d430bbb094577100dced9f58c093f55c6493c7cce74ec5fc938d2bbe65cdd17702f86fb6c2a7bc79397ae4bd814f2f2641773149b
7
- data.tar.gz: c054076b82f7385fac19b58e17fd2f3736fa0772739c4b99760ec9e1e24e3035c517a5b036656dea58158e23fbed7c32e6a7763790aa53e3bf8b0d3e30da467a
6
+ metadata.gz: 5b9e99e31e44d377952e0fd2d83de94ec2a4c9dde06054d209b66542db75b13575d2a8a10241e70037cbede8dd2c97f2b8d9c42059ece7532fb193c4062ff345
7
+ data.tar.gz: 5f18ccc435f62eb9a65506d8605b45f8895a3d3df4c662117c5f31a1d365f8dca7f966afe426d34386587dd19c699243a288d862b72868a1cea5da78278df0ce
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ El formato se basa en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  y este proyecto se adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
  Tipos de cambios: `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`.
7
7
 
8
+ ## [v1.0.4] - 2025-12-23
9
+ - Se agregó headers a settings
10
+
11
+ ## [v1.0.3] - 2025-06-04
12
+ ### Added
13
+ - Se agrego la configuración de router a las transacciones con `RouterManager`
14
+ - Campo source para `PaymentTransaction`
15
+ ### Fixed
16
+ - Dato de tarjeta actualizado para testing
17
+
8
18
  ## [v1.0.2] - 2024-02-27
9
19
  ### Fixed
10
20
  - Se arreglan códigos de estados en Nicaragua, Reino Unido, Estados Unidos, Guatemala, Panamá, Perú y Portugal
data/CONTRIBUTING.md CHANGED
@@ -21,4 +21,31 @@ rake test TEST=test/requests/test_sale_transaction.rb
21
21
  Ejecutar unit test en particular:
22
22
  ```bash
23
23
  rake test TEST=test/models/test_billing.rb TESTOPTS="--name=test_empty_billing"
24
- ```
24
+ ```
25
+
26
+ Otra opción para ejecutar test en particular:
27
+ ```bash
28
+ ruby test/services/test_transaction.rb -n test_success_sale_transaction
29
+ ```
30
+
31
+
32
+ ## Preparación de entorno
33
+
34
+ El sistema macOS ya trae una versión de **Ruby** instalada, pero es posible que no sea completamente compatible con el **SDK**. Por ello, es mejor instalar otra versión.
35
+
36
+ 1. Instalar Ruby Version Manager para gestionar versiones de Ruby: [RVM](https://rvm.io/).
37
+ 2. Instalar la versión de ruby: ```rvm install 2.7.6 --with-openssl-dir=$(brew --prefix openssl@1.1) ```
38
+ 3. Correr ```gem install bundler```
39
+
40
+ **Nota**: ```openssl@1.1``` ya deberia estar en homebrew. Revisar con ```brew list```. Si no está, instalarlo antes de ejecutar el paso 2.
41
+
42
+ **Opción alternativa**
43
+ Es posible que no se permita instalar ```openssl@1.1``` ya que fue deshabilitado por homebrew. En ese caso se puede utilizar otro manejador de versiones de **Ruby** como [rbenv](https://github.com/rbenv/rbenv).
44
+
45
+ Pasos de instalación:
46
+
47
+ 1. brew install rbenv
48
+ 2. rbenv install 2.7.6
49
+ 3. rbenv global 2.7.6 (Configura la versión de Ruby por defecto de la computadora)
50
+
51
+ **Nota** Si se intento la instalación previa de RVM y no se puedo debido al elemento de **openssl@1.1**, comentar en archivo de variables de entorno .zshrc los elementos de RVM.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelpay_sdk (1.0.2)
4
+ pixelpay_sdk (1.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -43,6 +43,7 @@ GEM
43
43
 
44
44
  PLATFORMS
45
45
  arm64-darwin-22
46
+ arm64-darwin-23
46
47
  ruby
47
48
  x64-mingw32
48
49
 
@@ -55,4 +56,4 @@ DEPENDENCIES
55
56
  simplecov
56
57
 
57
58
  BUNDLED WITH
58
- 2.4.12
59
+ 2.4.22
data/README.md CHANGED
@@ -5,12 +5,12 @@
5
5
  Para obtener la versión del SDK de PixelPay con Ruby puedes utilizar este comando para instalar directamente:
6
6
 
7
7
  ``` bash
8
- gem install pixelpay_sdk-1.0.2
8
+ gem install pixelpay_sdk-1.0.4
9
9
  ```
10
10
 
11
11
  O puedes colocar en el archivo Gemfile la siguiente línea:
12
12
  ``` bash
13
- gem 'pixelpay_sdk', '~> 1.0.2'
13
+ gem 'pixelpay_sdk', '~> 1.0.4'
14
14
  ```
15
15
 
16
16
  Y luego ejecutar:
@@ -64,7 +64,7 @@ class Response
64
64
  # Returns:
65
65
  # Any: data or nil.
66
66
  def get_data(key)
67
- return nil if @data.nil? && @data.key?(key.to_s)
67
+ return nil if @data.nil? || !@data.key?(key.to_s)
68
68
 
69
69
  @data[key.to_s]
70
70
  end
@@ -136,6 +136,12 @@ class ServiceBehaviour
136
136
 
137
137
  request["x-auth-user"] = @settings.auth_user if @settings.auth_user != ""
138
138
 
139
+ if @settings.headers
140
+ @settings.headers.each do |key, value|
141
+ request[key] = value
142
+ end
143
+ end
144
+
139
145
  request
140
146
  rescue StandardError => e
141
147
  exception_response(e)
@@ -103,9 +103,11 @@ class TransactionResult
103
103
  def self.from_response(response)
104
104
  entity = TransactionResult.new
105
105
 
106
- entity.instance_variables.each do |var_name|
107
- if response.data.key?(var_name.to_s.delete("@"))
108
- entity.instance_variable_set(var_name, response.data[var_name.to_s.delete("@")])
106
+ if response.respond_to?(:data) && response.data.is_a?(Hash)
107
+ entity.instance_variables.each do |var_name|
108
+ if response.data.key?(var_name.to_s.delete("@"))
109
+ entity.instance_variable_set(var_name, response.data[var_name.to_s.delete("@")])
110
+ end
109
111
  end
110
112
  end
111
113
 
@@ -0,0 +1,2 @@
1
+ class RunningTransactionException < StandardError
2
+ end
@@ -0,0 +1,52 @@
1
+ require "json"
2
+ require "base64"
3
+
4
+ require_relative "../services/Transaction"
5
+ require_relative "../request/PaymentTransaction"
6
+ require_relative "../request/SaleTransaction"
7
+ require_relative "../models/Settings"
8
+
9
+ class RouterManager
10
+ attr_accessor :transaction, :identifier
11
+
12
+ def initialize(request)
13
+ # Payment transaction
14
+ @transaction = request
15
+
16
+ #Payment transaction source
17
+ @transaction.source = 'router'
18
+
19
+ # PixelPay transaction authentication identifier
20
+ @identifier = nil
21
+ end
22
+
23
+ # Initialize manager
24
+ def init_manager(payload)
25
+ service = Transaction.new(parse_payload(payload))
26
+
27
+ if @transaction.is_a?(SaleTransaction)
28
+ return service.do_sale(@transaction);
29
+ else
30
+ return service.do_auth(@transaction)
31
+ end
32
+ end
33
+
34
+ # Parse the payload string to Object Settings
35
+ def parse_payload(payload)
36
+ decoded_payload = Base64.decode64(payload)
37
+ obj_payload = JSON.parse(decoded_payload)
38
+
39
+ settings = Settings.new
40
+
41
+ settings.setup_environment(obj_payload["env"])
42
+ settings.setup_credentials(obj_payload["auth_key"], obj_payload["auth_hash"])
43
+ settings.setup_endpoint(obj_payload["endpoint"]);
44
+ settings.setup_language(@transaction.lang);
45
+
46
+ if obj_payload["auth_user"]
47
+ settings.setup_platform_user(obj_payload["auth_user"])
48
+ end
49
+
50
+ return settings
51
+ end
52
+ end
@@ -4,7 +4,7 @@ require_relative "../base/Helpers"
4
4
  require_relative "../resources/Environment"
5
5
  # Settings represents the settings information for a request.
6
6
  class Settings
7
- attr_accessor :auth_key, :auth_hash, :auth_user, :endpoint, :environment, :lang
7
+ attr_accessor :auth_key, :auth_hash, :auth_user, :endpoint, :environment, :lang, :headers
8
8
 
9
9
  # Initialize model
10
10
  def initialize
@@ -25,6 +25,10 @@ class Settings
25
25
 
26
26
  # Settings response messages language
27
27
  @lang = nil
28
+
29
+ # Request headers
30
+ @headers = nil
31
+
28
32
  end
29
33
 
30
34
  # Setup API endpoint URL.
@@ -75,7 +79,7 @@ class Settings
75
79
 
76
80
  # Setup defaults to Sandbox credentials.
77
81
  def setup_sandbox
78
- @endpoint = "https://pixel-pay.com"
82
+ @endpoint = "https://pixelpay.dev"
79
83
  @auth_key = "1234567890"
80
84
  @auth_hash = Helpers.hash("MD5", "@s4ndb0x-abcd-1234-n1l4-p1x3l")
81
85
  @environment = Environment::SANDBOX
@@ -91,4 +95,15 @@ class Settings
91
95
 
92
96
  self
93
97
  end
98
+
99
+ # Setup request headers
100
+ # Args:
101
+ # headers (Hash): request headers to be used.
102
+ # Returns:
103
+ # Settings: self
104
+ def setup_headers(headers)
105
+ @headers = headers
106
+
107
+ self
108
+ end
94
109
  end
@@ -9,7 +9,7 @@ class PaymentTransaction < RequestBehaviour
9
9
  :billing_country, :billing_state, :billing_city, :billing_zip, :billing_phone, :customer_name,
10
10
  :customer_email, :order_id, :order_currency, :order_amount, :order_tax_amount, :order_shipping_amount,
11
11
  :order_content, :order_extras, :order_note, :order_callback, :authentication_request,
12
- :authentication_identifier
12
+ :authentication_identifier, :source
13
13
 
14
14
  # Initialize request.
15
15
  def initialize
@@ -89,6 +89,9 @@ class PaymentTransaction < RequestBehaviour
89
89
 
90
90
  # Authentication transaction identifier
91
91
  @authentication_identifier = nil
92
+
93
+ # Internal processing flow of the transaction (e.g. router, proxy, etc)
94
+ @source = nil
92
95
  end
93
96
 
94
97
  # Associate and mapping Card model properties to transaction.
@@ -6,7 +6,9 @@ require_relative "../request/StatusTransaction"
6
6
  require_relative "../request/AuthTransaction"
7
7
  require_relative "../request/CaptureTransaction"
8
8
  require_relative "../request/VoidTransaction"
9
+ require_relative "../libraries/RouterManager"
9
10
  require_relative "../exceptions/InvalidTransactionTypeException"
11
+ require_relative "../exceptions/RunningTransactionException"
10
12
 
11
13
  # Transaction provides a specific structure for a transaction to be performed.
12
14
  class Transaction < ServiceBehaviour
@@ -34,7 +36,15 @@ class Transaction < ServiceBehaviour
34
36
  err = eval_authentication_transaction(transaction)
35
37
  raise InvalidTransactionTypeException, err.message if err.instance_of?(InvalidTransactionTypeException)
36
38
 
37
- post("api/v2/transaction/sale", transaction)
39
+ response = post("api/v2/transaction/sale", transaction)
40
+
41
+ if response.instance_of?(PayloadResponse)
42
+ if response.data["transaction_type"] == "router"
43
+ return RouterManager.new(transaction).init_manager(response.data["payload"])
44
+ end
45
+ end
46
+
47
+ return response
38
48
  rescue StandardError => e
39
49
  e
40
50
  end
@@ -50,7 +60,15 @@ class Transaction < ServiceBehaviour
50
60
  err = eval_authentication_transaction(transaction)
51
61
  raise InvalidTransactionTypeException, err.message if err.instance_of?(InvalidTransactionTypeException)
52
62
 
53
- post("api/v2/transaction/auth", transaction)
63
+ response = post("api/v2/transaction/auth", transaction)
64
+
65
+ if response.instance_of?(PayloadResponse)
66
+ if response.data["transaction_type"] == "router"
67
+ return RouterManager.new(transaction).init_manager(response.data["payload"])
68
+ end
69
+ end
70
+
71
+ return response
54
72
  rescue StandardError => e
55
73
  e
56
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PixelpaySdk
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelpay_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sonia Villeda
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-03-05 00:00:00.000000000 Z
12
+ date: 2026-01-05 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -40,6 +40,8 @@ files:
40
40
  - lib/pixelpay_sdk/entities/TransactionResult.rb
41
41
  - lib/pixelpay_sdk/exceptions/InvalidCredentialsException.rb
42
42
  - lib/pixelpay_sdk/exceptions/InvalidTransactionTypeException.rb
43
+ - lib/pixelpay_sdk/exceptions/RunningTransactionException.rb
44
+ - lib/pixelpay_sdk/libraries/RouterManager.rb
43
45
  - lib/pixelpay_sdk/models/Billing.rb
44
46
  - lib/pixelpay_sdk/models/Card.rb
45
47
  - lib/pixelpay_sdk/models/Item.rb