bckbn 1.0.0 → 2.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: ce377473db9fe443d1c56a5fddee4a3a0c054f7116ddec01c72a557a42444fc5
4
- data.tar.gz: 658740e19e499bb366b79c35be52dc679248c03bd07b752062b29be8b8ca4ca4
3
+ metadata.gz: a998e53954c06ebed88798f74e96ca31f07cc7101d0f6f2ef3977eeb993cbac5
4
+ data.tar.gz: 4e1650c6ba365f4fcf3f09fec35755593e7ee0c780c433f17495a9d43bf6cc6b
5
5
  SHA512:
6
- metadata.gz: 737a5f3f12a45a1324bf5da6808db9675dae182ec2c18161679711c94b32597aa3d6a978b38cc3244d89a6dd0fffd3187d069e916dff56dc419b930b8b18a121
7
- data.tar.gz: 1ffaf775d1abb53073328e3b11118bfba10bc5fa3065cbdb40cf00efb24cecec6cf90c806852c34307857a02664a8bd1c5129e109e92ba4726c7bc0d18d8b9cb
6
+ metadata.gz: 8046e28f4a9793a33049f63964b87afe600cc6e9fcbae5252d99789f00dde42e7a57a3bdea96019a4478ca93d0a0788b1f7e48994394018511f6749db9c81bf9
7
+ data.tar.gz: 5ceb54a6645ac7d44952b12bb5d5ca6c8d3cb385093666632a315d8d8a77f0370af8173634eb194030a1b45efd25e5a66c58781b90bbcff80c0610bdc639c790
data/.irbrc CHANGED
@@ -4,77 +4,75 @@ Bckbn.api_base = "http://localhost:8080"
4
4
  Bckbn.access_token = "foobar"
5
5
  Bckbn.merchant_id = "101"
6
6
 
7
- module Seeds
8
- AUTH = {
9
- amount: 5000,
10
- bill_to_address: {
11
- name: "John Doe",
12
- address_line_1: "123 Main St",
13
- city: "Boston",
14
- state: "MA",
15
- country: "US",
16
- zip: "12345",
17
- email: "jsmith@someaddress.com",
18
- phone: "555-123-4567"
19
- },
20
- card: {
21
- type: "MC",
22
- number: "{{1234567890123456}}",
23
- exp_date: "1223"
24
- },
25
- id: "12345",
26
- order_id: "5234234",
27
- order_source: "ecommerce",
28
- partial: false,
29
- report_group: "ABC Division"
30
- }.freeze
7
+ @auth_body = {
8
+ amount: 5000,
9
+ bill_to_address: {
10
+ name: "John Doe",
11
+ address_line_1: "123 Main St",
12
+ city: "Boston",
13
+ state: "MA",
14
+ country: "US",
15
+ zip: "12345",
16
+ email: "jsmith@someaddress.com",
17
+ phone: "555-123-4567"
18
+ },
19
+ card: {
20
+ type: "MC",
21
+ number: "{{1234567890123456}}",
22
+ exp_date: "1223"
23
+ },
24
+ id: "12345",
25
+ order_id: "5234234",
26
+ order_source: "ecommerce",
27
+ partial: false,
28
+ report_group: "ABC Division"
29
+ }.freeze
31
30
 
32
- SALE = {
33
- id: "12345",
34
- report_group: "ABC Division",
35
- amount: 5000,
36
- "card": {
37
- "type": "VI",
38
- "number": "{{1234567890123456}}",
39
- "exp_date": "1223",
40
- "card_validation_num": "123"
41
- },
42
- "bill_to_address": {
43
- "name": "John Doe",
44
- "address_line_1": "123 Main St",
45
- "city": "Boston",
46
- "state": "MA",
47
- "country": "US",
48
- "zip": "12345",
49
- "email": "jsmith@someaddress.com",
50
- "phone": "555-123-4567"
51
- },
52
- partial: false,
53
- order_id: "5234234",
54
- order_source: "ecommerce"
55
- }.freeze
31
+ @sale_body = {
32
+ id: "12345",
33
+ report_group: "ABC Division",
34
+ amount: 5000,
35
+ "card": {
36
+ "type": "VI",
37
+ "number": "{{1234567890123456}}",
38
+ "exp_date": "1223",
39
+ "card_validation_num": "123"
40
+ },
41
+ "bill_to_address": {
42
+ "name": "John Doe",
43
+ "address_line_1": "123 Main St",
44
+ "city": "Boston",
45
+ "state": "MA",
46
+ "country": "US",
47
+ "zip": "12345",
48
+ "email": "jsmith@someaddress.com",
49
+ "phone": "555-123-4567"
50
+ },
51
+ partial: false,
52
+ order_id: "5234234",
53
+ order_source: "ecommerce"
54
+ }.freeze
56
55
 
57
- ECHECK_SALE = {
58
- "echeck": {
59
- "acc_type": "Checking",
60
- "acc_num": "5186005800001012",
61
- "routing_num": "000010101",
62
- "check_num": nil
63
- },
64
- "bill_to_address": {
65
- "name": "John Doe",
66
- "address_line_1": "123 Main St",
67
- "city": "Boston",
68
- "state": "MA",
69
- "country": "US",
70
- "zip": "12345",
71
- "email": "jsmith@someaddress.com",
72
- "phone": "555-123-4567"
73
- },
74
- "amount": 5000,
75
- "id": "12345",
76
- "report_group": "ABC Division",
77
- "order_id": "5234234",
78
- "order_source": "ecommerce"
79
- }.freeze
80
- end
56
+ @echeck_sale_body = {
57
+ "echeck": {
58
+ "acc_type": "Checking",
59
+ "acc_num": "5186005800001012",
60
+ "routing_num": "000010101",
61
+ "check_num": nil
62
+ },
63
+ "bill_to_address": {
64
+ "name": "John Doe",
65
+ "address_line_1": "123 Main St",
66
+ "city": "Boston",
67
+ "state": "MA",
68
+ "country": "US",
69
+ "zip": "12345",
70
+ "email": "jsmith@someaddress.com",
71
+ "phone": "555-123-4567"
72
+ },
73
+ "amount": 5000,
74
+ "id": "12345",
75
+ "report_group": "ABC Division",
76
+ "order_id": "5234234",
77
+ "order_source": "ecommerce"
78
+ }.freeze
data/CHANGELOG.md CHANGED
@@ -6,3 +6,7 @@
6
6
 
7
7
  - Update local config to override global config where both present
8
8
  - Add idempotency key header
9
+
10
+ ## 1.0.1
11
+
12
+ - Allow http scheme
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bckbn (1.0.0)
4
+ bckbn (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -9,6 +9,9 @@ gem install bckbn
9
9
  ```
10
10
 
11
11
  ## Configuration
12
+ Local configuration will override global configuration where
13
+ they conflict. Some config can only be set locally, like an
14
+ `idempotency_key`.
12
15
 
13
16
  ### Global
14
17
 
@@ -26,7 +29,7 @@ Bckbn::Transaction.capture({
26
29
  })
27
30
  ```
28
31
 
29
- ### Per Request
32
+ ### Local
30
33
 
31
34
  ```ruby
32
35
  require "bckbn"
@@ -34,6 +37,7 @@ require "bckbn"
34
37
  api_base = "..."
35
38
  access_token = "..."
36
39
  merchant_id = "..."
40
+ idempotency_key = "..."
37
41
 
38
42
  Bckbn::Transaction.capture(
39
43
  {
@@ -42,13 +46,19 @@ Bckbn::Transaction.capture(
42
46
  report_group: "ABC Division"
43
47
  },
44
48
  {
45
- api_base:,
46
- access_token:,
47
- merchant_id:
49
+ api_base: api_base,
50
+ access_token: access_token,
51
+ merchant_id: merchant_id,
52
+ idempotency_key: idempotency_key
48
53
  }
49
54
  )
50
55
  ```
51
56
 
57
+ ### Idempotency
58
+ An idempotency key can be added to allow retries without creating duplicate transactions.
59
+ Successful POST requests will return a cached response. New requests can be issued
60
+ by changing the request body or the idempotency key.
61
+
52
62
  ## Documentation
53
63
 
54
64
  ```
@@ -44,7 +44,7 @@ module Bckbn
44
44
  response_handler(url, request) do |response, rbody|
45
45
  case response
46
46
  when Net::HTTPSuccess
47
- data = rbody.dig("data", klass.name.split("::").last.underscore)
47
+ data = rbody.fetch("data")
48
48
  log(:debug, "\nResponse: #{data.to_json}")
49
49
  klass.new(**data, logs: @logs)
50
50
  else
@@ -64,7 +64,7 @@ module Bckbn
64
64
 
65
65
  def response_handler(url, request)
66
66
  http = Net::HTTP.new(url.host, url.port)
67
- http.use_ssl = true
67
+ http.use_ssl = url.scheme == "https"
68
68
 
69
69
  response, body = begin
70
70
  r = http.request(request)
@@ -3,14 +3,14 @@
3
3
  module Bckbn
4
4
  module Transaction
5
5
  ENDPOINTS = {
6
- authorization: "/transactions/authorization",
7
- capture: "/transactions/capture",
8
- credit: "/transactions/credit",
9
- sale: "/transactions/sale",
10
- void: "/transactions/void",
11
- echeck_credit: "/transactions/echeck_credit",
12
- echeck_sale: "/transactions/echeck_sale",
13
- echeck_void: "/transactions/echeck_void"
6
+ authorization: "/transaction/authorization",
7
+ capture: "/transaction/capture",
8
+ credit: "/transaction/credit",
9
+ sale: "/transaction/sale",
10
+ void: "/transaction/void",
11
+ echeck_credit: "/transaction/echeck_credit",
12
+ echeck_sale: "/transaction/echeck_sale",
13
+ echeck_void: "/transaction/echeck_void"
14
14
  }.freeze
15
15
  private_constant :ENDPOINTS
16
16
 
data/lib/bckbn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bckbn
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
5
5
  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: 1.0.0
4
+ version: 2.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: 2023-10-09 00:00:00.000000000 Z
11
+ date: 2023-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker