buckaruby 1.2.0 → 1.3.0
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 +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/lib/buckaruby/gateway.rb +2 -2
- data/lib/buckaruby/payment_method.rb +1 -0
- data/lib/buckaruby/response.rb +25 -5
- data/lib/buckaruby/version.rb +1 -1
- data/spec/buckaruby/gateway_spec.rb +31 -2
- data/spec/fixtures/responses/callback_payment_amex.txt +1 -0
- data/spec/fixtures/responses/callback_refund_amex.txt +1 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855a453200b91387930947cdd68b6d315e5cf3072f0f96af43c9aedd602d2a19
|
4
|
+
data.tar.gz: 811de69c1218ab1e5a10c8f9d3ca1ddf8e8e01bea31da9157bc6203fde9a3a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce0ce26ff6272ccd8fa73d95c7af0078b1f68a20723a6c8214cb1a1fafe1e2a8755ee8ccf05202f921904f8d54b603daed3d378f0465467be958da346fe756d
|
7
|
+
data.tar.gz: c569a0978c2723ba373a00f620a08dc8593f6fb9a0e4e8e21a1804fbf34e3163f0cb06ff8802b588e020bb92fcbae96e5d20a6a00f84a1c6f48e0f76764590b1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/buckaruby/gateway.rb
CHANGED
@@ -151,7 +151,7 @@ module Buckaruby
|
|
151
151
|
|
152
152
|
valid_payment_methods = [
|
153
153
|
PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING, PaymentMethod::VISA, PaymentMethod::MASTER_CARD, PaymentMethod::MAESTRO,
|
154
|
-
PaymentMethod::SEPA_DIRECT_DEBIT, PaymentMethod::PAYPAL, PaymentMethod::BANCONTACT_MISTER_CASH
|
154
|
+
PaymentMethod::AMERICAN_EXPRESS, PaymentMethod::SEPA_DIRECT_DEBIT, PaymentMethod::PAYPAL, PaymentMethod::BANCONTACT_MISTER_CASH
|
155
155
|
]
|
156
156
|
validate_payment_method!(options, valid_payment_methods)
|
157
157
|
|
@@ -191,7 +191,7 @@ module Buckaruby
|
|
191
191
|
validate_amount!(options)
|
192
192
|
|
193
193
|
valid_payment_methods = [
|
194
|
-
PaymentMethod::VISA, PaymentMethod::MASTER_CARD, PaymentMethod::MAESTRO,
|
194
|
+
PaymentMethod::VISA, PaymentMethod::MASTER_CARD, PaymentMethod::MAESTRO, PaymentMethod::AMERICAN_EXPRESS,
|
195
195
|
PaymentMethod::SEPA_DIRECT_DEBIT, PaymentMethod::PAYPAL
|
196
196
|
]
|
197
197
|
validate_payment_method!(options, valid_payment_methods)
|
data/lib/buckaruby/response.rb
CHANGED
@@ -177,18 +177,38 @@ module Buckaruby
|
|
177
177
|
if params[:brq_transaction_type] && !params[:brq_transaction_type].empty?
|
178
178
|
# See http://support.buckaroo.nl/index.php/Transactietypes
|
179
179
|
case params[:brq_transaction_type]
|
180
|
-
when '
|
180
|
+
when 'C021', 'V021', # iDEAL
|
181
|
+
'C002', 'C004', 'C005', # (SEPA) Direct Debit
|
182
|
+
'V010', 'V014', # PayPal
|
183
|
+
'C090', 'V090', # Bancontact
|
184
|
+
'C001', # Transfer
|
185
|
+
'C044', 'C192', 'V002', 'V032', 'V044', 'V192', # Visa
|
186
|
+
'C043', 'C089', 'V001', 'V043', 'V089', 'V031', # MasterCard
|
187
|
+
'C046', 'C251', 'V034', 'V046', 'V245', 'V094', # Maestro
|
188
|
+
'V003', 'V030', 'V036', 'V042' # American Express
|
189
|
+
|
181
190
|
# Check the recurring flag to detect a normal or recurring transaction.
|
182
191
|
if params[:brq_recurring] && params[:brq_recurring].casecmp("true").zero?
|
183
192
|
TransactionType::PAYMENT_RECURRENT
|
184
193
|
else
|
185
194
|
TransactionType::PAYMENT
|
186
195
|
end
|
187
|
-
when '
|
188
|
-
|
189
|
-
|
196
|
+
when 'C121', # iDEAL
|
197
|
+
'C102', 'C500', # (SEPA) Direct Debit
|
198
|
+
'V110', # PayPal
|
199
|
+
'C092', 'V092', # Bancontact
|
200
|
+
'C101', # Transfer
|
201
|
+
'C080', 'C194', 'V068', 'V080', 'V102', 'V194', # Visa
|
202
|
+
'C079', 'C197', 'V067', 'V079', 'V101', 'V149', 'V197', # MasterCard
|
203
|
+
'C082', 'C252', 'V070', 'V082', 'V246', # Maestro
|
204
|
+
'V066', 'V072', 'V078', 'V103' # American Express
|
190
205
|
TransactionType::REFUND
|
191
|
-
when 'C501', 'C502', '
|
206
|
+
when 'C501', 'C502', 'C562', # (SEPA) Direct Debit
|
207
|
+
'V111', # PayPal
|
208
|
+
'C554', 'C593', 'V132', 'V144', 'V544', 'V592', # Visa
|
209
|
+
'C553', 'C589', 'V131', 'V143', 'V543', 'V589', # MasterCard
|
210
|
+
'C546', 'C551', 'V134', 'V146', 'V545', 'V546', # Maestro
|
211
|
+
'V130', 'V136', 'V142' # American Express
|
192
212
|
TransactionType::REVERSAL
|
193
213
|
end
|
194
214
|
else
|
data/lib/buckaruby/version.rb
CHANGED
@@ -215,7 +215,7 @@ RSpec.describe Buckaruby::Gateway do
|
|
215
215
|
expect(response.custom[:quux]).to eq("42")
|
216
216
|
|
217
217
|
expect(WebMock).to have_requested(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest")
|
218
|
-
.with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&cust_foo=bar&cust_quux=42&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=
|
218
|
+
.with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&cust_foo=bar&cust_quux=42&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=e185c8a1bce030a3e0d001f0c09fbf6b0c8f88ab")
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
@@ -227,7 +227,7 @@ RSpec.describe Buckaruby::Gateway do
|
|
227
227
|
expect(response.additional[:myreference]).to eq("12345")
|
228
228
|
|
229
229
|
expect(WebMock).to have_requested(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest")
|
230
|
-
.with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&add_myreference=12345&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=
|
230
|
+
.with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&add_myreference=12345&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=40ee09a9b7ccac816318c9e9bc81493fcee183f7")
|
231
231
|
end
|
232
232
|
end
|
233
233
|
end
|
@@ -573,6 +573,20 @@ RSpec.describe Buckaruby::Gateway do
|
|
573
573
|
expect(response.timestamp).to be_an_instance_of(Time)
|
574
574
|
expect(response.to_h).to be_an_instance_of(Hash)
|
575
575
|
end
|
576
|
+
|
577
|
+
it 'sets the transaction type to payment and payment method to American Express for amex callback' do
|
578
|
+
params = File.read("spec/fixtures/responses/callback_payment_amex.txt")
|
579
|
+
|
580
|
+
response = subject.callback(params)
|
581
|
+
expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::SUCCESS)
|
582
|
+
expect(response.transaction_type).to eq(Buckaruby::TransactionType::PAYMENT)
|
583
|
+
expect(response.payment_method).to eq(Buckaruby::PaymentMethod::AMERICAN_EXPRESS)
|
584
|
+
expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
|
585
|
+
expect(response.payment_id).to eq("E86256B2787EE7FF0C33D0D4C6159CD922227B79")
|
586
|
+
expect(response.invoicenumber).to eq("12345")
|
587
|
+
expect(response.timestamp).to be_an_instance_of(Time)
|
588
|
+
expect(response.to_h).to be_an_instance_of(Hash)
|
589
|
+
end
|
576
590
|
end
|
577
591
|
|
578
592
|
context 'when callback is a payment recurrent response' do
|
@@ -635,6 +649,21 @@ RSpec.describe Buckaruby::Gateway do
|
|
635
649
|
expect(response.timestamp).to be_an_instance_of(Time)
|
636
650
|
expect(response.to_h).to be_an_instance_of(Hash)
|
637
651
|
end
|
652
|
+
|
653
|
+
it 'recognizes an amex refund response' do
|
654
|
+
params = File.read("spec/fixtures/responses/callback_refund_amex.txt")
|
655
|
+
|
656
|
+
response = subject.callback(params)
|
657
|
+
expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::SUCCESS)
|
658
|
+
expect(response.transaction_type).to eq(Buckaruby::TransactionType::REFUND)
|
659
|
+
expect(response.payment_method).to eq(Buckaruby::PaymentMethod::AMERICAN_EXPRESS)
|
660
|
+
expect(response.transaction_id).to eq("B51118F58785274E117EFE1BF99D4D50CCB96949")
|
661
|
+
expect(response.payment_id).to be nil
|
662
|
+
expect(response.invoicenumber).to eq("12345")
|
663
|
+
expect(response.refund_transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
|
664
|
+
expect(response.timestamp).to be_an_instance_of(Time)
|
665
|
+
expect(response.to_h).to be_an_instance_of(Hash)
|
666
|
+
end
|
638
667
|
end
|
639
668
|
|
640
669
|
context 'when callback is a reversal response' do
|
@@ -0,0 +1 @@
|
|
1
|
+
brq_amount=1.00&brq_currency=EUR&brq_customer_name=Test&brq_description=Test+American+Express&brq_invoicenumber=12345&brq_issuing_country=NL&brq_mutationtype=Processing&brq_payer_hash=ec4dcf6c815f12bd75b7f5a2ef61d0307c868bd2a48a7af4ab5425c4abd475bb9c5c85f279baed6e4e4576a59b9d16311dcc1c9dd6be100386876905d909c99e&brq_payment=E86256B2787EE7FF0C33D0D4C6159CD922227B79&brq_SERVICE_amex_Authentication=Y&brq_SERVICE_amex_CardExpirationDate=2019-10&brq_SERVICE_amex_CardNumberEnding=8084&brq_SERVICE_amex_Enrolled=Y&brq_SERVICE_amex_MaskedCreditcardNumber=375317%2A%2A%2A%2A%2A8084&brq_statuscode=190&brq_statuscode_detail=S001&brq_statusmessage=Transaction+successfully+processed&brq_test=true&brq_timestamp=2019-10-08+10%3A02%3A31&brq_transaction_method=amex&brq_transaction_type=V036&brq_transactions=41C48B55FA9164E123CC73B1157459E840BE5D24&brq_websitekey=12345678&brq_signature=495dbdbb3c87c04351bec97cd40bafe0addec0f3
|
@@ -0,0 +1 @@
|
|
1
|
+
brq_amount_credit=1.00&brq_currency=EUR&brq_invoicenumber=12345&brq_mutationtype=Processing&brq_relatedtransaction_refund=41C48B55FA9164E123CC73B1157459E840BE5D24&brq_statuscode=190&brq_statusmessage=Success&brq_test=true&brq_timestamp=2019-10-08+10%3A21%3A28&brq_transaction_method=amex&brq_transaction_type=V072&brq_transactions=B51118F58785274E117EFE1BF99D4D50CCB96949&brq_websitekey=1234567&brq_signature=feccc64fd8bdf9c17b1dd48961513f2361991439
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buckaruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08
|
11
|
+
date: 2019-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- spec/buckaruby/signature_spec.rb
|
109
109
|
- spec/buckaruby/support/case_insensitive_hash_spec.rb
|
110
110
|
- spec/fixtures/responses/callback_invalid_signature.txt
|
111
|
+
- spec/fixtures/responses/callback_payment_amex.txt
|
111
112
|
- spec/fixtures/responses/callback_payment_cancelled.txt
|
112
113
|
- spec/fixtures/responses/callback_payment_empty_transaction_type.txt
|
113
114
|
- spec/fixtures/responses/callback_payment_failed.txt
|
@@ -117,6 +118,7 @@ files:
|
|
117
118
|
- spec/fixtures/responses/callback_payment_success.txt
|
118
119
|
- spec/fixtures/responses/callback_recurrent_sepa.txt
|
119
120
|
- spec/fixtures/responses/callback_recurrent_visa.txt
|
121
|
+
- spec/fixtures/responses/callback_refund_amex.txt
|
120
122
|
- spec/fixtures/responses/callback_refund_ideal.txt
|
121
123
|
- spec/fixtures/responses/callback_refund_paypal.txt
|
122
124
|
- spec/fixtures/responses/callback_reversal_paypal.txt
|
@@ -151,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
153
|
- !ruby/object:Gem::Version
|
152
154
|
version: '0'
|
153
155
|
requirements: []
|
154
|
-
|
155
|
-
rubygems_version: 2.7.9
|
156
|
+
rubygems_version: 3.0.6
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Ruby library for communicating with the Buckaroo Payment Engine 3.0.
|
@@ -163,6 +164,7 @@ test_files:
|
|
163
164
|
- spec/buckaruby/signature_spec.rb
|
164
165
|
- spec/buckaruby/support/case_insensitive_hash_spec.rb
|
165
166
|
- spec/fixtures/responses/callback_invalid_signature.txt
|
167
|
+
- spec/fixtures/responses/callback_payment_amex.txt
|
166
168
|
- spec/fixtures/responses/callback_payment_cancelled.txt
|
167
169
|
- spec/fixtures/responses/callback_payment_empty_transaction_type.txt
|
168
170
|
- spec/fixtures/responses/callback_payment_failed.txt
|
@@ -172,6 +174,7 @@ test_files:
|
|
172
174
|
- spec/fixtures/responses/callback_payment_success.txt
|
173
175
|
- spec/fixtures/responses/callback_recurrent_sepa.txt
|
174
176
|
- spec/fixtures/responses/callback_recurrent_visa.txt
|
177
|
+
- spec/fixtures/responses/callback_refund_amex.txt
|
175
178
|
- spec/fixtures/responses/callback_refund_ideal.txt
|
176
179
|
- spec/fixtures/responses/callback_refund_paypal.txt
|
177
180
|
- spec/fixtures/responses/callback_reversal_paypal.txt
|