forked from swombat/peeves
-
Notifications
You must be signed in to change notification settings - Fork 2
/
simulate.rb
72 lines (61 loc) · 2.96 KB
/
simulate.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# require 'rubygems'
# require 'activesupport'
require File.expand_path(File.dirname(__FILE__) + "/../../../config/environment")
$LOAD_PATH << "lib"
ActiveSupport::Dependencies.load_paths = $LOAD_PATH
# EDIT THIS BEFORE RUNNING:
Peeves::Config.vendor = "xinzheng"
# END
Peeves::Config.gateway_mode = :simulator
p = PeevesGateway.new(:simulator)
transaction_reference = Peeves::UniqueId.generate("TEST")
customer_data = Peeves::CustomerData.new(:surname => 'blah',
:firstnames => 'blah',
:address1 => 'blah',
:address2 => 'blah',
:city => 'blah',
:post_code => 'blah',
:country => 'gb',
:email => '[email protected]'
)
# Payment registration
payment_response = p.payment(Peeves::Money.new(1000, "GBP"),
{
:transaction_reference => transaction_reference,
:description => "Test Transaction",
:notification_url => "http://test.example.com",
:customer_data => { :billing => customer_data,
:delivery => customer_data,
:email => customer_data.email }
})
puts payment_response.inspect
# Not yet working
# Issue with :related_transaction_authorisation_number which needs to come from
# A3: Notification of Results for Transactions
#
# Repeat payment registration
repeat_response = p.repeat(Peeves::Money.new(1000, "GBP"),
{
:transaction_reference => Peeves::UniqueId.generate("TEST"),
:description => "Test Repeat Transaction",
:notification_url => "http://test.example.com",
:related_transaction_reference => transaction_reference,
:related_vps_transaction_id => payment_response[:vps_transaction_id],
:related_security_key => payment_response[:security_key],
# :related_transaction_authorisation_number => "1213121212"
:related_transaction_authorisation_number => "0"
})
#
# puts repeat_response
# AUTHORISE can only be used after AUTHENTICATE; not needed
#
#response2 = p.authorise(Peeves::Money.new(1000, "GBP"),
# {
# :transaction_reference => Peeves::UniqueId.generate("TEST"),
# :description => "Test Authorise",
# :related_transaction_reference => transaction_reference,
# :related_vps_transaction_id => response.vps_transaction_id,
# :related_security_key => response.security_key
# })
#
#puts response2.inspect