payex 0.1.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87add971c273b10a05fd489a701184e47a414eca
4
+ data.tar.gz: 20605334607f26c3c2c4b57cda30b81d2f936cfb
5
+ SHA512:
6
+ metadata.gz: d36d402b2631b2fa06d160c3a5e14d64aef3fa0cbc1da2c34342e06936a862476ecd726db5d31462e276288f84938e2bc6614e7d3ca76b9e12c5f9a1cb2a81cf
7
+ data.tar.gz: 85e3655ff8a0d84df2560169831460a5a55f34c5899706f044f389d6ff4cf684b11910073104df74890432f7aef18a5a1439b0cb1beb5df03e046eb69ef5da1b
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ - jruby-head
7
+ - ruby-head
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
- source :rubygems
2
- ruby '1.9.3'
1
+ source 'https://rubygems.org'
3
2
  gemspec
3
+
4
+ platforms :jruby do
5
+ gem 'jruby-openssl', '~> 0.7'
6
+ end
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- payex (0.0.2)
4
+ payex (0.3)
5
+ httpclient (~> 2.2)
5
6
  nori (~> 1.1)
6
7
  savon (~> 1.1)
7
8
 
8
9
  GEM
9
- remote: http://rubygems.org/
10
+ remote: https://rubygems.org/
10
11
  specs:
11
12
  akami (1.2.0)
12
13
  gyoku (>= 0.4.0)
13
14
  nokogiri (>= 1.4.0)
14
- builder (3.0.0)
15
+ builder (3.1.3)
15
16
  diff-lcs (1.1.3)
16
- ffi (1.1.5)
17
- guard (1.3.2)
17
+ guard (1.3.3)
18
18
  listen (>= 0.4.2)
19
19
  thor (>= 0.14.6)
20
20
  guard-bundler (1.0.0)
@@ -24,29 +24,24 @@ GEM
24
24
  guard (>= 1.1)
25
25
  gyoku (0.4.6)
26
26
  builder (>= 2.1.2)
27
+ httpclient (2.3.4.1)
27
28
  httpi (1.1.1)
28
29
  rack
29
- listen (0.4.7)
30
- rb-fchange (~> 0.0.5)
31
- rb-fsevent (~> 0.9.1)
32
- rb-inotify (~> 0.8.8)
30
+ listen (0.5.2)
33
31
  nokogiri (1.5.5)
34
32
  nori (1.1.3)
35
33
  rack (1.4.1)
36
- rb-fchange (0.0.5)
37
- ffi
38
- rb-fsevent (0.9.1)
39
- rb-inotify (0.8.8)
40
- ffi (>= 0.5.0)
34
+ rake (0.9.2.2)
35
+ rb-fsevent (0.9.2)
41
36
  rspec (2.11.0)
42
37
  rspec-core (~> 2.11.0)
43
38
  rspec-expectations (~> 2.11.0)
44
39
  rspec-mocks (~> 2.11.0)
45
40
  rspec-core (2.11.1)
46
- rspec-expectations (2.11.2)
41
+ rspec-expectations (2.11.3)
47
42
  diff-lcs (~> 1.1.3)
48
- rspec-mocks (2.11.2)
49
- savon (1.1.0)
43
+ rspec-mocks (2.11.3)
44
+ savon (1.2.0)
50
45
  akami (~> 1.2.0)
51
46
  builder (>= 2.1.2)
52
47
  gyoku (~> 0.4.5)
@@ -70,7 +65,10 @@ DEPENDENCIES
70
65
  guard (~> 1.3)
71
66
  guard-bundler (~> 1.0)
72
67
  guard-rspec (~> 1.2)
68
+ jruby-openssl (~> 0.7)
73
69
  payex!
70
+ rake (~> 0.9)
71
+ rb-fsevent (~> 0.9)
74
72
  rspec (~> 2.11)
75
73
  savon_spec (~> 1.3)
76
74
  terminal-notifier-guard (~> 1.5)
@@ -0,0 +1,59 @@
1
+ [![Build Status](https://travis-ci.org/gointeractive/payex-ruby.png)](https://travis-ci.org/gointeractive/payex-ruby)
2
+
3
+ ## Installation
4
+
5
+ This is a rudimentary Ruby binding for the [PayEx API]. You can
6
+ install it using RubyGems.
7
+
8
+ [PayEx API]: http://pim.payex.com/section3/section3_4_2.htm
9
+
10
+ ```
11
+ gem install payex
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ This library only implements the "credit card redirect" method.
17
+
18
+ Here's how a basic credit card transaction works:
19
+
20
+ ```ruby
21
+ require 'payex'
22
+
23
+ PayEx.account_number = 123456789
24
+ PayEx.encryption_key = 'e4939be3910ebu194'
25
+ PayEx.default_currency = 'SEK'
26
+ #PayEx.base_url = PayEx::TEST_URL # (use this for testing)
27
+
28
+ # (an arbitrary string you can use to identify this transaction)
29
+ my_order_id = 'c704acc45a4bec4c8cd50b73fb01a7c7'
30
+
31
+ payment_url = PayEx::CreditCardRedirect.initialize_transaction!
32
+ order_id: my_order_id,
33
+ product_number: '123456',
34
+ product_description: 'Brief product description',
35
+ price: 14900, # (in cents)
36
+ customer_ip: '12.34.56.78',
37
+ return_url: 'http://example.com/payex-return',
38
+ cancel_url: 'http://example.com/payex-cancel'
39
+ ```
40
+
41
+ After redirecting the customer to `payment_url`, they'll enter their
42
+ payment details and then PayEx will redirect them back to `return_url`
43
+ with a parameter called `orderRef` appended to the query string.
44
+
45
+ The `PayEx::CreditCardRedirect.complete_transaction!` method takes
46
+ this `orderRef` string as input and returns your order ID as output.
47
+
48
+ ```ruby
49
+ order_id, error, raw_response =
50
+ PayEx.complete_transaction! '9b4031c19960da92d'
51
+ case error
52
+ when nil
53
+ # The transaction succeeded (use `order_id` to proceed).
54
+ when PayEx::Error::CardDeclined
55
+ # The transaction was declined by the credit card company.
56
+ else
57
+ # The transaction failed (look at `raw_response` for details).
58
+ end
59
+ ```
data/Rakefile CHANGED
@@ -1,3 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ task :default => :spec
@@ -4,82 +4,30 @@ module PayEx
4
4
  TEST_URL = 'https://test-external.payex.com'
5
5
  LIVE_URL = 'https://external.payex.com'
6
6
 
7
- class Error < StandardError; end
8
-
9
- attr_accessor :default_currency
10
7
  attr_accessor :base_url
11
8
 
9
+ self.base_url = PayEx::TEST_URL
10
+
12
11
  attr_accessor :account_number
13
12
  attr_accessor :encryption_key
13
+ attr_accessor :default_currency
14
14
 
15
- attr_accessor :return_url
16
- attr_accessor :cancel_url
17
- end
18
-
19
- PayEx.default_currency = 'SEK'
20
- PayEx.base_url = PayEx::TEST_URL
21
-
22
- require 'payex/api'
23
- require 'payex/pxorder'
24
-
25
- def PayEx.account_number!
26
- PayEx.account_number or fail 'Please set PayEx.account_number'
27
- end
28
-
29
- def PayEx.encryption_key!
30
- PayEx.encryption_key or fail 'Please set PayEx.encryption_key'
31
- end
32
-
33
- def PayEx.authorize_transaction! order_id, params
34
- response = PayEx::PxOrder.Initialize7 \
35
- orderID: order_id,
36
- purchaseOperation: 'AUTHORIZATION',
37
- productNumber: params[:product_number],
38
- description: params[:product_description],
39
- price: params[:price],
40
- clientIPAddress: params[:customer_ip],
41
- returnUrl: PayEx.return_url,
42
- cancelUrl: PayEx.cancel_url
43
-
44
- response[:redirect_url]
45
- end
46
-
47
- def PayEx.complete_transaction! id
48
- response = PayEx::PxOrder.Complete(orderRef: id)
49
-
50
- status = response[:transaction_status]
51
- status = PayEx.parse_transaction_status(status)
52
- error = nil
53
-
54
- case status
55
- when :sale, :authorize
56
- if response[:already_completed] == 'True'
57
- error = 'Transaction already completed'
58
- end
59
- when :initialize
60
- error = 'Transaction not completed'
61
- when :failure
62
- begin
63
- error = response[:error_details][:third_party_error]
64
- rescue
65
- error = 'Transaction failed'
66
- end
67
- else
68
- error = 'Unexpected transaction status: ' + status.to_s.upcase
15
+ def account_number!
16
+ account_number or fail 'Please set PayEx.account_number'
69
17
  end
70
18
 
71
- [response[:order_id], error, response]
72
- end
19
+ def encryption_key!
20
+ encryption_key or fail 'Please set PayEx.encryption_key'
21
+ end
73
22
 
74
- def PayEx.parse_transaction_status(status)
75
- case status.to_s
76
- when '0' then :sale
77
- when '1' then :initialize
78
- when '2' then :credit
79
- when '3' then :authorize
80
- when '4' then :cancel
81
- when '5' then :failure
82
- when '6' then :capture
83
- else status.to_s
23
+ def default_currency!
24
+ default_currency or fail 'Please set PayEx.default_currency'
84
25
  end
85
26
  end
27
+
28
+ class PayEx::Error < StandardError; end
29
+ class PayEx::Error::CardDeclined < PayEx::Error; end
30
+
31
+ require 'payex/api'
32
+ require 'payex/api/pxorder'
33
+ require 'payex/credit_card_redirect'
@@ -98,4 +98,17 @@ module PayEx::API
98
98
  def param_error! message
99
99
  raise ParamError, message
100
100
  end
101
+
102
+ def parse_transaction_status(status)
103
+ case status.to_s
104
+ when '0' then :sale
105
+ when '1' then :initialize
106
+ when '2' then :credit
107
+ when '3' then :authorize
108
+ when '4' then :cancel
109
+ when '5' then :failure
110
+ when '6' then :capture
111
+ else status.to_s
112
+ end
113
+ end
101
114
  end
@@ -24,7 +24,7 @@ module PayEx::PxOrder
24
24
  },
25
25
  'currency' => {
26
26
  signed: true,
27
- default: proc { PayEx.default_currency }
27
+ default: proc { PayEx.default_currency! }
28
28
  },
29
29
  'vat' => {
30
30
  signed: true,
@@ -0,0 +1,43 @@
1
+ module PayEx::CreditCardRedirect
2
+ extend self
3
+
4
+ def initialize_transaction! params
5
+ response = PayEx::PxOrder.Initialize7 \
6
+ orderID: params[:order_id],
7
+ purchaseOperation: 'AUTHORIZATION',
8
+ productNumber: params[:product_number],
9
+ description: params[:product_description],
10
+ price: params[:price],
11
+ clientIPAddress: params[:customer_ip],
12
+ returnUrl: params[:return_url],
13
+ cancelUrl: params[:cancel_url]
14
+
15
+ response[:redirect_url]
16
+ end
17
+
18
+ def complete_transaction! id
19
+ response = PayEx::PxOrder.Complete(orderRef: id)
20
+
21
+ status = response[:transaction_status]
22
+ status = PayEx::API.parse_transaction_status(status)
23
+
24
+ case status
25
+ when :authorize
26
+ error = nil
27
+ when :initialize
28
+ error = PayEx::Error.new('Transaction not completed')
29
+ when :failure
30
+ details = response[:error_details].inspect
31
+ case details
32
+ when /declined/i
33
+ error = PayEx::Error::CardDeclined.new('Card declined')
34
+ else
35
+ error = PayEx::Error.new('Transaction failed')
36
+ end
37
+ else
38
+ error = PayEx::Error.new('Transaction failed')
39
+ end
40
+
41
+ [response[:order_id], error, response]
42
+ end
43
+ end
@@ -2,17 +2,24 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'payex'
5
- gem.version = '0.1.2'
5
+ gem.version = '0.3'
6
6
  gem.summary = 'PayEx SOAP API glue'
7
7
  gem.author = 'Daniel Brockman'
8
8
  gem.files = `git ls-files 2>/dev/null`.split($\)
9
9
 
10
+ gem.add_dependency 'httpclient', '~> 2.2'
10
11
  gem.add_dependency 'nori', '~> 1.1'
11
12
  gem.add_dependency 'savon', '~> 1.1'
12
13
 
14
+ if RUBY_PLATFORM == 'java'
15
+ gem.add_dependency 'jruby-openssl', '~> 0.7'
16
+ end
17
+
13
18
  gem.add_development_dependency 'guard', '~> 1.3'
14
19
  gem.add_development_dependency 'guard-bundler', '~> 1.0'
15
20
  gem.add_development_dependency 'guard-rspec', '~> 1.2'
21
+ gem.add_development_dependency 'rake', '~> 0.9'
22
+ gem.add_development_dependency 'rb-fsevent', '~> 0.9'
16
23
  gem.add_development_dependency 'rspec', '~> 2.11'
17
24
  gem.add_development_dependency 'savon_spec', '~> 1.3'
18
25
  gem.add_development_dependency 'terminal-notifier-guard', '~> 1.5'
File without changes
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'payex'
3
+ require 'spec_helper'
4
+
5
+ describe PayEx::CreditCardRedirect do
6
+ SAMPLE_ACCOUNT_NUMBER = 'SAMPLEACCOUNTNUMBER0001'
7
+ SAMPLE_ENCRYPTION_KEY = 'SAMPLEENCRYPTIONKEY0001'
8
+ SAMPLE_DEFAULT_CURRENCY = 'SEK'
9
+
10
+ before {
11
+ PayEx.account_number = SAMPLE_ACCOUNT_NUMBER
12
+ PayEx.encryption_key = SAMPLE_ENCRYPTION_KEY
13
+ PayEx.default_currency = SAMPLE_DEFAULT_CURRENCY
14
+ }
15
+
16
+ SAMPLE_PRICE_CENTS = 12300
17
+ SAMPLE_ORDER_ID = 'SAMPLEORDERID0001'
18
+ SAMPLE_PRODUCT_NUMBER = 'SAMPLEPRODUCTNUMBER0001'
19
+ SAMPLE_PRODUCT_DESCRIPTION = 'Sample product description 0001'
20
+ SAMPLE_IP_ADDRESS = '12.34.56.78'
21
+ SAMPLE_RETURN_URL = 'http://example.com/payex-return'
22
+ SAMPLE_CANCEL_URL = 'http://example.com/payex-cancel'
23
+
24
+ describe :initialize_transaction! do
25
+ example 'successful initialization' do
26
+ expected = {
27
+ 'accountNumber' => SAMPLE_ACCOUNT_NUMBER,
28
+ 'purchaseOperation' => 'AUTHORIZATION',
29
+ 'price' => SAMPLE_PRICE_CENTS,
30
+ 'priceArgList' => '',
31
+ 'currency' => SAMPLE_DEFAULT_CURRENCY,
32
+ 'vat' => 0,
33
+ 'orderID' => SAMPLE_ORDER_ID,
34
+ 'productNumber' => SAMPLE_PRODUCT_NUMBER,
35
+ 'description' => SAMPLE_PRODUCT_DESCRIPTION,
36
+ 'clientIPAddress' => SAMPLE_IP_ADDRESS,
37
+ 'clientIdentifier' => '',
38
+ 'additionalValues' => '',
39
+ 'externalID' => '',
40
+ 'returnUrl' => SAMPLE_RETURN_URL,
41
+ 'view' => 'CREDITCARD',
42
+ 'agreementRef' => '',
43
+ 'cancelUrl' => SAMPLE_CANCEL_URL,
44
+ 'clientLanguage' => ''
45
+ }
46
+
47
+ expected['hash'] = PayEx::API.signed_hash(expected.values.join)
48
+ savon.expects('Initialize7').with(expected).returns(:initialize_ok)
49
+
50
+ href = PayEx::CreditCardRedirect.initialize_transaction! \
51
+ order_id: SAMPLE_ORDER_ID,
52
+ product_number: SAMPLE_PRODUCT_NUMBER,
53
+ product_description: SAMPLE_PRODUCT_DESCRIPTION,
54
+ price: SAMPLE_PRICE_CENTS,
55
+ customer_ip: SAMPLE_IP_ADDRESS,
56
+ return_url: SAMPLE_RETURN_URL,
57
+ cancel_url: SAMPLE_CANCEL_URL
58
+
59
+ href.should include 'http'
60
+ end
61
+ end
62
+
63
+ SAMPLE_ORDER_REF = 'SAMPLEORDERREF0001'
64
+
65
+ describe :complete_transaction! do
66
+ def invoke_complete! response_fixture
67
+ expected = {
68
+ 'accountNumber' => SAMPLE_ACCOUNT_NUMBER,
69
+ 'orderRef' => SAMPLE_ORDER_REF
70
+ }
71
+
72
+ expected['hash'] = PayEx::API.signed_hash(expected.values.join)
73
+ savon.expects('Complete').with(expected).returns(response_fixture)
74
+ PayEx::CreditCardRedirect.complete_transaction! SAMPLE_ORDER_REF
75
+ end
76
+
77
+ example 'successful completion' do
78
+ order_id, error, data = invoke_complete! :complete_ok
79
+ order_id.should == SAMPLE_ORDER_ID
80
+ error.should == nil
81
+ end
82
+
83
+ example 'unexpected failure' do
84
+ order_id, error, data = invoke_complete! :complete_failed
85
+ order_id.should == SAMPLE_ORDER_ID
86
+ error.should be_a PayEx::Error
87
+ end
88
+
89
+ example 'card declined' do
90
+ order_id, error, data = invoke_complete! :complete_declined
91
+ order_id.should == SAMPLE_ORDER_ID
92
+ error.should be_a PayEx::Error
93
+ error.should be_a PayEx::Error::CardDeclined
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
5
+ <soap:Body>
6
+ <CompleteResponse xmlns="http://external.payex.com/PxOrder/">
7
+ <CompleteResult>
8
+ <![CDATA[
9
+ <?xml version="1.0" encoding="utf-8" ?>
10
+ <payex>
11
+ <header name="Payex Header v1.0">
12
+ <id>dd473e0a40f54596b6db441b34bf54d9</id>
13
+ <date>2012-09-26 14:08:09</date>
14
+ </header>
15
+ <status>
16
+ <code>OK</code>
17
+ <description>OK</description>
18
+ <errorCode>OK</errorCode>
19
+ <paramName />
20
+ <thirdPartyError />
21
+ </status>
22
+ <transactionStatus>5</transactionStatus>
23
+ <orderStatus>0</orderStatus>
24
+ <transactionRef>6d0b1a8e7ab2480583b32f52dba782fe</transactionRef>
25
+ <transactionNumber>1024377</transactionNumber>
26
+ <orderId>SAMPLEORDERID0001</orderId>
27
+ <productId>SAMPLEPRODUCTNUMBER0001</productId>
28
+ <paymentMethod>VISA</paymentMethod>
29
+ <amount>12300</amount>
30
+ <alreadyCompleted>False</alreadyCompleted>
31
+ <Csid>00000001-4581-0903-5682-000000000000</Csid>
32
+ <errorDetails>
33
+ <transactionErrorCode>CardNotAcceptedForThisPurchase</transactionErrorCode>
34
+ <transactionErrorDescription>Accomplish3rdParty</transactionErrorDescription>
35
+ <transactionThirdPartyError>CARD_DECLINED</transactionThirdPartyError>
36
+ </errorDetails>
37
+ <clientAccount>0</clientAccount>
38
+ <productNumber>SAMPLEPRODUCTNUMBER0001</productNumber>
39
+ <clientGsmNumber />
40
+ <transactionFailedReason />
41
+ <BankHash>00000001-4581-0903-5682-000000000000</BankHash>
42
+ <AuthenticatedWith>N</AuthenticatedWith>
43
+ <AuthenticatedStatus />
44
+ <maskedNumber>45**********5682</maskedNumber>
45
+ <fraudData>false</fraudData>
46
+ <pending>false</pending>
47
+ </payex>
48
+ ]]>
49
+ </CompleteResult>
50
+ </CompleteResponse>
51
+ </soap:Body>
52
+ </soap:Envelope>
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
5
+ <soap:Body>
6
+ <CompleteResponse xmlns="http://external.payex.com/PxOrder/">
7
+ <CompleteResult>
8
+ <![CDATA[
9
+ <?xml version="1.0" encoding="utf-8" ?>
10
+ <payex>
11
+ <header name="Payex Header v1.0">
12
+ <id>dd473e0a40f54596b6db441b34bf54d9</id>
13
+ <date>2012-09-26 14:08:09</date>
14
+ </header>
15
+ <status>
16
+ <code>OK</code>
17
+ <description>OK</description>
18
+ <errorCode>OK</errorCode>
19
+ <paramName />
20
+ <thirdPartyError />
21
+ </status>
22
+ <transactionStatus>5</transactionStatus>
23
+ <orderStatus>0</orderStatus>
24
+ <transactionRef>6d0b1a8e7ab2480583b32f52dba782fe</transactionRef>
25
+ <transactionNumber>1024377</transactionNumber>
26
+ <orderId>SAMPLEORDERID0001</orderId>
27
+ <productId>SAMPLEPRODUCTNUMBER0001</productId>
28
+ <paymentMethod>VISA</paymentMethod>
29
+ <amount>12300</amount>
30
+ <alreadyCompleted>False</alreadyCompleted>
31
+ <Csid>00000001-4581-0903-5682-000000000000</Csid>
32
+ <errorDetails>
33
+ <transactionErrorCode>Error_Generic</transactionErrorCode>
34
+ <transactionErrorDescription>Accomplish3rdParty</transactionErrorDescription>
35
+ <transactionThirdPartyError>9098</transactionThirdPartyError>
36
+ </errorDetails>
37
+ <clientAccount>0</clientAccount>
38
+ <productNumber>SAMPLEPRODUCTNUMBER0001</productNumber>
39
+ <clientGsmNumber />
40
+ <transactionFailedReason />
41
+ <BankHash>00000001-4581-0903-5682-000000000000</BankHash>
42
+ <AuthenticatedWith>N</AuthenticatedWith>
43
+ <AuthenticatedStatus />
44
+ <maskedNumber>45**********5682</maskedNumber>
45
+ <fraudData>false</fraudData>
46
+ <pending>false</pending>
47
+ </payex>
48
+ ]]>
49
+ </CompleteResult>
50
+ </CompleteResponse>
51
+ </soap:Body>
52
+ </soap:Envelope>
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
5
+ <soap:Body>
6
+ <CompleteResponse xmlns="http://external.payex.com/PxOrder/">
7
+ <CompleteResult>
8
+ <![CDATA[
9
+ <?xml version="1.0" encoding="utf-8" ?>
10
+ <payex>
11
+ <header name="Payex Header v1.0">
12
+ <id>dd473e0a40f54596b6db441b34bf54d9</id>
13
+ <date>2012-09-26 14:08:09</date>
14
+ </header>
15
+ <status>
16
+ <code>OK</code>
17
+ <description>OK</description>
18
+ <errorCode>OK</errorCode>
19
+ <paramName />
20
+ <thirdPartyError />
21
+ </status>
22
+ <transactionStatus>3</transactionStatus>
23
+ <orderStatus>0</orderStatus>
24
+ <transactionRef>6d0b1a8e7ab2480583b32f52dba782fe</transactionRef>
25
+ <transactionNumber>1024377</transactionNumber>
26
+ <orderId>SAMPLEORDERID0001</orderId>
27
+ <productId>SAMPLEPRODUCTNUMBER0001</productId>
28
+ <paymentMethod>VISA</paymentMethod>
29
+ <amount>12300</amount>
30
+ <alreadyCompleted>False</alreadyCompleted>
31
+ <Csid>00000001-4581-0903-5682-000000000000</Csid>
32
+ <clientAccount>0</clientAccount>
33
+ <productNumber>SAMPLEPRODUCTNUMBER0001</productNumber>
34
+ <clientGsmNumber />
35
+ <BankHash>00000001-4581-0903-5682-000000000000</BankHash>
36
+ <AuthenticatedWith>Y</AuthenticatedWith>
37
+ <AuthenticatedStatus>3DSecure</AuthenticatedStatus>
38
+ <maskedNumber>45**********5682</maskedNumber>
39
+ <fraudData>false</fraudData>
40
+ <pending>false</pending>
41
+ </payex>
42
+ ]]>
43
+ </CompleteResult>
44
+ </CompleteResponse>
45
+ </soap:Body>
46
+ </soap:Envelope>
@@ -1,30 +1,30 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
3
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5
- <env:Body>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
5
+ <soap:Body>
6
6
  <Initialize7Response xmlns="http://external.payex.com/PxOrder/">
7
7
  <Initialize7Result>
8
8
  <![CDATA[
9
- <?xml version="1.0" encoding="utf-8"?>
9
+ <?xml version="1.0" encoding="utf-8" ?>
10
10
  <payex>
11
11
  <header name="Payex Header v1.0">
12
- <id>4e0fbe36b146452b8ce7b87e6186a3e3</id>
13
- <date>2010-11-10 06:13:48</date>
12
+ <id>07507411082c45aaa8a58f961a47b0f8</id>
13
+ <date>2012-09-26 14:07:42</date>
14
14
  </header>
15
15
  <status>
16
16
  <code>OK</code>
17
17
  <description>OK</description>
18
18
  <errorCode>OK</errorCode>
19
- <paramName/>
20
- <thirdPartyError/>
19
+ <paramName />
20
+ <thirdPartyError />
21
21
  </status>
22
- <orderRef>b93d29bf7df3424cac23407a987c0be9</orderRef>
23
- <sessionRef>7807accc0e7e4d069e1d92ec5680d0cc</sessionRef>
24
- <redirectUrl>https://test-confined.payex.com/PxOrderCC.aspx?orderRef=b93d29bf7df3424cac23407a987c0be9</redirectUrl>
22
+ <orderRef>67d7e7d3b4134741a3297480dca6d899</orderRef>
23
+ <sessionRef>d22235c662eb45bfa524a1319903a434</sessionRef>
24
+ <redirectUrl>https://test-confined.payex.com/PxOrderCC.aspx?orderRef=67d7e7d3b4134741a3297480dca6d899</redirectUrl>
25
25
  </payex>
26
26
  ]]>
27
27
  </Initialize7Result>
28
28
  </Initialize7Response>
29
- </env:Body>
30
- </env:Envelope>
29
+ </soap:Body>
30
+ </soap:Envelope>
@@ -6,3 +6,6 @@ Savon::Spec::Fixture.path =
6
6
  RSpec.configure do |config|
7
7
  config.include Savon::Spec::Macros
8
8
  end
9
+
10
+ # Suppress "HTTPI executes HTTP GET using the httpclient adapter"
11
+ HTTPI.log = false
metadata CHANGED
@@ -1,20 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: '0.3'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Brockman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpclient
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: nori
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
31
  - - ~>
20
32
  - !ruby/object:Gem::Version
@@ -22,7 +34,6 @@ dependencies:
22
34
  type: :runtime
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
38
  - - ~>
28
39
  - !ruby/object:Gem::Version
@@ -30,7 +41,6 @@ dependencies:
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: savon
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
45
  - - ~>
36
46
  - !ruby/object:Gem::Version
@@ -38,7 +48,6 @@ dependencies:
38
48
  type: :runtime
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
52
  - - ~>
44
53
  - !ruby/object:Gem::Version
@@ -46,7 +55,6 @@ dependencies:
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: guard
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
59
  - - ~>
52
60
  - !ruby/object:Gem::Version
@@ -54,7 +62,6 @@ dependencies:
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
66
  - - ~>
60
67
  - !ruby/object:Gem::Version
@@ -62,7 +69,6 @@ dependencies:
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: guard-bundler
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
73
  - - ~>
68
74
  - !ruby/object:Gem::Version
@@ -70,7 +76,6 @@ dependencies:
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
80
  - - ~>
76
81
  - !ruby/object:Gem::Version
@@ -78,7 +83,6 @@ dependencies:
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: guard-rspec
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
87
  - - ~>
84
88
  - !ruby/object:Gem::Version
@@ -86,15 +90,41 @@ dependencies:
86
90
  type: :development
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
94
  - - ~>
92
95
  - !ruby/object:Gem::Version
93
96
  version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rb-fsevent
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '0.9'
94
125
  - !ruby/object:Gem::Dependency
95
126
  name: rspec
96
127
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
128
  requirements:
99
129
  - - ~>
100
130
  - !ruby/object:Gem::Version
@@ -102,7 +132,6 @@ dependencies:
102
132
  type: :development
103
133
  prerelease: false
104
134
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
135
  requirements:
107
136
  - - ~>
108
137
  - !ruby/object:Gem::Version
@@ -110,7 +139,6 @@ dependencies:
110
139
  - !ruby/object:Gem::Dependency
111
140
  name: savon_spec
112
141
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
142
  requirements:
115
143
  - - ~>
116
144
  - !ruby/object:Gem::Version
@@ -118,7 +146,6 @@ dependencies:
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
149
  requirements:
123
150
  - - ~>
124
151
  - !ruby/object:Gem::Version
@@ -126,7 +153,6 @@ dependencies:
126
153
  - !ruby/object:Gem::Dependency
127
154
  name: terminal-notifier-guard
128
155
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
156
  requirements:
131
157
  - - ~>
132
158
  - !ruby/object:Gem::Version
@@ -134,7 +160,6 @@ dependencies:
134
160
  type: :development
135
161
  prerelease: false
136
162
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
163
  requirements:
139
164
  - - ~>
140
165
  - !ruby/object:Gem::Version
@@ -146,41 +171,45 @@ extensions: []
146
171
  extra_rdoc_files: []
147
172
  files:
148
173
  - .gitignore
174
+ - .travis.yml
149
175
  - Gemfile
150
176
  - Gemfile.lock
151
177
  - Guardfile
152
- - README
178
+ - README.md
153
179
  - Rakefile
154
180
  - lib/payex.rb
155
181
  - lib/payex/api.rb
156
- - lib/payex/pxorder.rb
182
+ - lib/payex/api/pxorder.rb
183
+ - lib/payex/credit_card_redirect.rb
157
184
  - payex.gemspec
158
- - spec/api_unit_spec.rb
185
+ - spec/api_spec.rb
186
+ - spec/credit_card_redirect_spec.rb
187
+ - spec/fixtures/complete/complete_declined.xml
188
+ - spec/fixtures/complete/complete_failed.xml
189
+ - spec/fixtures/complete/complete_ok.xml
159
190
  - spec/fixtures/initialize7/initialize_ok.xml
160
- - spec/integration_spec.rb
161
191
  - spec/spec_helper.rb
162
192
  homepage:
163
193
  licenses: []
194
+ metadata: {}
164
195
  post_install_message:
165
196
  rdoc_options: []
166
197
  require_paths:
167
198
  - lib
168
199
  required_ruby_version: !ruby/object:Gem::Requirement
169
- none: false
170
200
  requirements:
171
- - - ! '>='
201
+ - - '>='
172
202
  - !ruby/object:Gem::Version
173
203
  version: '0'
174
204
  required_rubygems_version: !ruby/object:Gem::Requirement
175
- none: false
176
205
  requirements:
177
- - - ! '>='
206
+ - - '>='
178
207
  - !ruby/object:Gem::Version
179
208
  version: '0'
180
209
  requirements: []
181
210
  rubyforge_project:
182
- rubygems_version: 1.8.24
211
+ rubygems_version: 2.0.14
183
212
  signing_key:
184
- specification_version: 3
213
+ specification_version: 4
185
214
  summary: PayEx SOAP API glue
186
215
  test_files: []
data/README DELETED
@@ -1,34 +0,0 @@
1
- # -*- ruby -*-
2
- require 'payex'
3
-
4
- # This is how a basic PayEx transaction works:
5
-
6
- PayEx.account_number = 123456789
7
- PayEx.encryption_key = 'e4939be3910ebu194'
8
-
9
- PayEx.return_url = 'http://example.com/payex-return'
10
- PayEx.cancel_url = 'http://example.com/payex-cancel'
11
-
12
- local_order_id = 'c704acc45a4bec4c8cd50b73fb01a7c7'
13
-
14
- payment_url = PayEx.authorize_transaction! local_order_id,
15
- product_number: '123456',
16
- product_description: 'Brief product description',
17
- price: 14900, # Price in cents
18
- customer_ip: '12.34.56.78'
19
-
20
- # After sending the customer to `payment_url`, they will enter their
21
- # payment details before being redirected back to `PayEx.return_url`
22
- # with an `orderRef` parameter appended to the query string:
23
- #
24
- # <http://example.com/payex-return?orderRef=9b4031c19960da92d>
25
- #
26
- # By giving the `orderRef` value to `PayEx.complete_transaction!` you
27
- # retreive your local order ID and your app can proceed from there.
28
-
29
- begin
30
- local_order_id = PayEx.complete_transaction! '9b4031c19960da92d'
31
- # [transaction successful]
32
- rescue PayEx::Error => error
33
- # [transaction unsucessful]
34
- end
@@ -1,45 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'payex'
3
- require 'spec_helper'
4
-
5
- describe PayEx do
6
- before {
7
- PayEx.account_number = 'foo-account'
8
- PayEx.encryption_key = 'foo-secret'
9
- PayEx.return_url = 'http://example.com/payex-callback'
10
- }
11
-
12
- it 'should send request and parse response' do
13
- expected = {
14
- 'accountNumber' => 'foo-account',
15
- 'purchaseOperation' => 'AUTHORIZATION',
16
- 'price' => 12300,
17
- 'priceArgList' => '',
18
- 'currency' => 'SEK',
19
- 'vat' => 0,
20
- 'orderID' => 'order123',
21
- 'productNumber' => 'PRODUCT123',
22
- 'description' => 'Product description',
23
- 'clientIPAddress' => '12.34.56.78',
24
- 'clientIdentifier' => '',
25
- 'additionalValues' => '',
26
- 'externalID' => '',
27
- 'returnUrl' => 'http://example.com/payex-callback',
28
- 'view' => 'CREDITCARD',
29
- 'agreementRef' => '',
30
- 'cancelUrl' => '',
31
- 'clientLanguage' => ''
32
- }
33
-
34
- expected['hash'] = PayEx::API.signed_hash(expected.values.join)
35
- savon.expects('Initialize7').with(expected).returns(:initialize_ok)
36
-
37
- href = PayEx.authorize_transaction! 'order123',
38
- product_number: 'PRODUCT123',
39
- product_description: 'Product description',
40
- price: 12300,
41
- customer_ip: '12.34.56.78'
42
-
43
- href.should include 'http'
44
- end
45
- end