pci_proxy 1.0.1 → 1.1.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: b3b3d7fc9150a054af99f760133f3f0e0c61b4101b9c9aaa6226697b2d19fa05
4
- data.tar.gz: 9f0a96730a817e58c296f5c27b338204ba6d8fc007e15b051fa8785670dfc18c
3
+ metadata.gz: e3809fc9d53de874082c4b1c7ffb7ad715adcfeb2fea22fef66266d4072d41bd
4
+ data.tar.gz: 176d0778aa1f90c0e6f95fc141da290fd951ace11c3a5232a617bc9db21ba474
5
5
  SHA512:
6
- metadata.gz: c48acd895516a36dc3d5d3980b22164db5711e79baec8f96a3268748dc73d00fa220013cd764480eeaf4702787495aeee904e22b86acaf8aa3e008e85f2d0fec
7
- data.tar.gz: 5cfaa045d5167aa2da4a5c6a477ccdc59ed34f7e05af5789fbbffced9d4536335cedf29d4371889d03b237114ed30383fb7f9ebd0764cb0ded29655c406bd468
6
+ metadata.gz: 154eb6fd451665825ba0eb146fa12c51448c815cfc13dd1dbea93a65f49c35053c2ae1ae9691622ba198770cfc8ddbed7e01030e13504445cdf255d8010ac9b0
7
+ data.tar.gz: 44975973ccded51daa015e25000291f7a992ec1ecd642119491a5c589bf16bf6e10f9a145c2164e344242425edf40de0b7f26fc6a64016bac3c67b94d104af97
@@ -2,4 +2,8 @@
2
2
 
3
3
  A simple client library for [PCI Proxy](https://pci-proxy.com)'s API
4
4
 
5
- v1.0.0 - 14th January 2020 - Initial release - covers the [Token API](https://docs.pci-proxy.com/collect-and-store-cards/capture-iframes/token-api)
5
+ v1.1.0 - 17th January 2020 - Return an instance of PciProxy::Model::TokenisedCard instead of plain Hash
6
+
7
+ v1.0.1 - 14th January 2020 - Relax dependency version requirements
8
+
9
+ v1.0.0 - 14th January 2020 - Initial release - covering the [Token API](https://docs.pci-proxy.com/collect-and-store-cards/capture-iframes/token-api)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pci_proxy (1.0.1)
4
+ pci_proxy (1.1.0)
5
5
  faraday (>= 0.8.9)
6
6
  multi_json (>= 1.10.0)
7
7
 
data/README.md CHANGED
@@ -35,10 +35,10 @@ And execute a token exchange like so:
35
35
  client.execute(transaction_id: '1234567890')
36
36
  ```
37
37
 
38
- In the event of a 200 OK response, the JSON response body is returned as a hash, for example:
38
+ In the event of a 200 OK response, an instance of PciProxy::Model::TokenisedCard is returned:
39
39
 
40
40
  ```ruby
41
- {"aliasCC"=>"411111GGCMUJ1111", "aliasCVV"=>"vCslSwP0SQ9JXJy-nDzLKHaS"}
41
+ #<PciProxy::Model::TokenisedCard:0x00007fda073453f8 @response={"aliasCC"=>"411111GGCMUJ1111", "aliasCVV"=>"b8XeAbhQQES6OVWTpOCaAscj", "paymentMethod"=>"VIS"}, @pan_token="411111GGCMUJ1111", @cvv_token="b8XeAbhQQES6OVWTpOCaAscj", @type_slug=:visa>
42
42
  ```
43
43
 
44
44
  In the event of an error, a subclass of ```PciProxyAPIError``` will be raised.
@@ -3,6 +3,7 @@ require "pci_proxy/version"
3
3
 
4
4
  require 'pci_proxy/base'
5
5
  require 'pci_proxy/token'
6
+ require 'pci_proxy/model/tokenised_card'
6
7
 
7
8
  module PciProxy
8
9
  PciProxyAPIError = Class.new(StandardError)
@@ -0,0 +1,43 @@
1
+ module PciProxy
2
+ module Model
3
+ class TokenisedCard
4
+
5
+ attr_reader :pan_token, :cvv_token, :type_slug, :response
6
+
7
+ def initialize(response)
8
+ @response = response
9
+ @pan_token = response["aliasCC"]
10
+ @cvv_token = response["aliasCVV"]
11
+ @type_slug = slug_for(response["paymentMethod"])
12
+ end
13
+
14
+ private
15
+
16
+ def slug_for(payment_method)
17
+ return nil if payment_method.nil?
18
+
19
+ case payment_method
20
+ when 'VIS'
21
+ :visa
22
+ when 'ECA'
23
+ :mastercard
24
+ when 'AMX'
25
+ :amex
26
+ when 'DIN'
27
+ :diners
28
+ when 'DIS'
29
+ :discovery
30
+ when 'JCB'
31
+ :jcb
32
+ when 'ELO'
33
+ :elo
34
+ when 'CUP'
35
+ :cup
36
+ else
37
+ :unknown
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -18,7 +18,8 @@ module PciProxy
18
18
  # @raise [PciProxyAPIError] in cases where the API responds with a non-200 response code
19
19
  # @return [Hash] result from PCI Proxy, decoded from JSON
20
20
  def execute(transaction_id:, return_payment_method: true, cvv_mandatory: false)
21
- request(params: { transactionId: transaction_id, returnPaymentMethod: return_payment_method, mandatoryAliasCVV: cvv_mandatory })
21
+ response = request(params: { transactionId: transaction_id, returnPaymentMethod: return_payment_method, mandatoryAliasCVV: cvv_mandatory })
22
+ PciProxy::Model::TokenisedCard.new(response)
22
23
  end
23
24
 
24
25
  end
@@ -1,3 +1,3 @@
1
1
  module PciProxy
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pci_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rory Sinclair
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - lib/pci_proxy.rb
102
102
  - lib/pci_proxy/base.rb
103
+ - lib/pci_proxy/model/tokenised_card.rb
103
104
  - lib/pci_proxy/token.rb
104
105
  - lib/pci_proxy/version.rb
105
106
  - pci_proxy.gemspec