bckbn 2.1.1 → 3.0.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: 17f59a2d0a76520c2ce364ef1bcfd8ca46e9a20f51026cb2613f9d66482ae278
4
- data.tar.gz: 51458c020327baffec1803bb3dc0fe6b8e890c771a9dd4cd7d604940b26f0aed
3
+ metadata.gz: b29620743a992dbae744097543537e4b165ec0fd41f4d4f42d7bb26b90b96bd6
4
+ data.tar.gz: 1d76d4b980d2470b902d7056bf43ddb36d213b0e0702f0f6a43c17b7463e3a11
5
5
  SHA512:
6
- metadata.gz: 63c67a32658b11f8b6f05cae841cf3feca56863a9528c158b29ec74e852f259f7fa0832112dbc0bdf611132d2207a7b9dcc8762ac972ab247194b1b4c5ac9dcd
7
- data.tar.gz: f5fe4a59cd73013bef9277a4c3f5255a6a89e934fa25fe643d4f5747d8e310a06f1865ffcb80d71c97a8d7affdb4ec2fcb7b942197a22da581def1465063429d
6
+ metadata.gz: f83c6a4af4dcb967b86ddad8763622c30736ea7f882161f3cfe194e21d2c0630903b39b621923277cfb25b78da37809611e67f1281d6e9e2401571db57ea10b7
7
+ data.tar.gz: 05dd64aaca218e3d786ab0b86433e7b443d5c0860d1171ffb4b03d59ad94df27587408460f545f2428ee41a7f400e9b8d5467921bd6112a534e9c6276dd629d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bckbn (2.1.1)
4
+ bckbn (3.0.0)
5
5
  addressable (~> 2.8.5)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -20,7 +20,7 @@ require "bckbn"
20
20
 
21
21
  Bckbn.api_base = "..."
22
22
  Bckbn.access_token = "..."
23
- Bckbn.merchant_id = "..."
23
+ Bckbn.worldpay_merchant_id = "..."
24
24
 
25
25
  Bckbn::Transaction.capture({
26
26
  litle_txn_id: "13254123434",
@@ -36,7 +36,7 @@ require "bckbn"
36
36
 
37
37
  api_base = "..."
38
38
  access_token = "..."
39
- merchant_id = "..."
39
+ worldpay_merchant_id = "..."
40
40
  idempotency_key = "..."
41
41
 
42
42
  Bckbn::Transaction.capture(
@@ -48,7 +48,7 @@ Bckbn::Transaction.capture(
48
48
  {
49
49
  api_base: api_base,
50
50
  access_token: access_token,
51
- merchant_id: merchant_id,
51
+ worldpay_merchant_id: worldpay_merchant_id,
52
52
  idempotency_key: idempotency_key
53
53
  }
54
54
  )
@@ -7,7 +7,7 @@ module Bckbn
7
7
  api_version
8
8
  api_base
9
9
  log_level
10
- merchant_id
10
+ worldpay_merchant_id
11
11
  source_ip_address
12
12
  idempotency_key
13
13
  ].freeze
@@ -16,11 +16,13 @@ module Bckbn
16
16
  HttpBadRequest = Class.new(BaseHttpError)
17
17
  HttpInternalServerError = Class.new(BaseHttpError)
18
18
  HttpServiceUnavailable = Class.new(BaseHttpError)
19
+ HttpGatewayTimeout = Class.new(BaseHttpError)
19
20
 
20
21
  ERRORS = {
21
- Net::HTTPBadRequest => HttpBadRequest,
22
- Net::HTTPInternalServerError => HttpInternalServerError,
23
- Net::HTTPServiceUnavailable => HttpServiceUnavailable
22
+ Net::HTTPBadRequest => HttpBadRequest, # 400
23
+ Net::HTTPInternalServerError => HttpInternalServerError, # 500
24
+ Net::HTTPServiceUnavailable => HttpServiceUnavailable, # 503
25
+ Net::HTTPGatewayTimeout => HttpGatewayTimeout # 504
24
26
  }.freeze
25
27
 
26
28
  def initialize(per_req_config)
@@ -48,7 +50,7 @@ module Bckbn
48
50
  log(:debug, "\nResponse: #{data.to_json}")
49
51
  klass.new(**data, logs: @logs)
50
52
  else
51
- err_klass = ERRORS[response.class]
53
+ err_klass = ERRORS.fetch(response.class)
52
54
  message = "Error: #{rbody ? rbody["errors"] : "Unknown"}"
53
55
  log(:error, message)
54
56
  err = err_klass.new(message, @logs)
@@ -73,7 +75,7 @@ module Bckbn
73
75
  log(:debug, "\nResponse: #{data.to_json}")
74
76
  klass.new(**data, logs: @logs)
75
77
  else
76
- err_klass = ERRORS[response.class]
78
+ err_klass = ERRORS.fetch(response.class)
77
79
  message = "Error: #{rbody ? rbody["errors"] : "Unknown"}"
78
80
  log(:error, message)
79
81
 
@@ -105,6 +107,8 @@ module Bckbn
105
107
  ro.fraud_result = ::Bckbn::Transaction::FraudResult.new(**resp_obj.fraud_result)
106
108
  end
107
109
  end
110
+ rescue StandardError => e
111
+ raise e
108
112
  end
109
113
 
110
114
  def headers(config)
@@ -112,7 +116,7 @@ module Bckbn
112
116
  "Content-Type" => "application/json",
113
117
  "Authorization" => "Bearer #{config.access_token}",
114
118
  "X-Api-Version" => config.api_version,
115
- "X-Merchant-Id" => config.merchant_id,
119
+ "X-Worldpay-Merchant-Id" => config.worldpay_merchant_id,
116
120
  "X-Source-Ip-Address" => config.source_ip_address,
117
121
  "X-Idempotency-Key" => config.idempotency_key
118
122
  }
data/lib/bckbn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bckbn
4
- VERSION = "2.1.1"
4
+ VERSION = "3.0.0"
5
5
  end
data/lib/bckbn.rb CHANGED
@@ -33,7 +33,7 @@ module Bckbn
33
33
  def_delegators :@config, :api_version, :api_version=
34
34
  def_delegators :@config, :api_base, :api_base=
35
35
  def_delegators :@config, :log_level, :log_level=
36
- def_delegators :@config, :merchant_id, :merchant_id=
36
+ def_delegators :@config, :worldpay_merchant_id, :worldpay_merchant_id=
37
37
  def_delegators :@config, :source_ip_address, :source_ip_address=
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bckbn
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nikkypx
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable