docdata 0.0.1 → 0.0.2
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/.coveralls.yml +2 -0
- data/.gitignore +4 -1
- data/.travis.yml +10 -0
- data/LICENSE +1 -1
- data/README.md +173 -7
- data/Rakefile +8 -0
- data/docdata.gemspec +18 -11
- data/lib/docdata.rb +74 -1
- data/lib/docdata/bank.rb +27 -0
- data/lib/docdata/config.rb +41 -0
- data/lib/docdata/docdata_error.rb +8 -0
- data/lib/docdata/engine.rb +13 -0
- data/lib/docdata/ideal.rb +40 -0
- data/lib/docdata/line_item.rb +99 -0
- data/lib/docdata/payment.rb +196 -0
- data/lib/docdata/response.rb +173 -0
- data/lib/docdata/shopper.rb +112 -0
- data/lib/docdata/version.rb +1 -1
- data/lib/docdata/xml/bank-list.xml +39 -0
- data/lib/docdata/xml/cancel.xml.erb +9 -0
- data/lib/docdata/xml/create.xml.erb +98 -0
- data/lib/docdata/xml/start.xml.erb +67 -0
- data/lib/docdata/xml/status.xml.erb +9 -0
- data/php-example/create.xml.erb +140 -0
- data/php-example/index.html +78 -0
- data/php-example/process.php +182 -0
- data/php-example/return.php +36 -0
- data/php-example/soap.rb +21 -0
- data/spec/config_spec.rb +53 -0
- data/spec/ideal_spec.rb +19 -0
- data/spec/line_item_spec.rb +55 -0
- data/spec/payment_spec.rb +162 -0
- data/spec/response_spec.rb +206 -0
- data/spec/shopper_spec.rb +50 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/xml/status-canceled-creditcard.xml +34 -0
- data/spec/xml/status-canceled-ideal.xml +29 -0
- data/spec/xml/status-new.xml +20 -0
- data/spec/xml/status-paid-creditcard.xml +33 -0
- data/spec/xml/status-paid-ideal.xml +33 -0
- data/spec/xml/status-paid-sofort.xml +33 -0
- metadata +145 -13
- data/LICENSE.txt +0 -22
@@ -0,0 +1,78 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
5
|
+
<title>Example docdatapayment (PHP)</title>
|
6
|
+
</head>
|
7
|
+
<style>
|
8
|
+
.row label {
|
9
|
+
margin-right: 100px;
|
10
|
+
display: block;
|
11
|
+
}
|
12
|
+
|
13
|
+
.row {
|
14
|
+
margin-bottom: 10px;
|
15
|
+
}
|
16
|
+
|
17
|
+
legend {
|
18
|
+
font-weight: 900;
|
19
|
+
margin-left: 5px;
|
20
|
+
margin-right: 5px;
|
21
|
+
}
|
22
|
+
|
23
|
+
input[type=text] {
|
24
|
+
width: 200px;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
<body>
|
28
|
+
<h1>Example docdatapayment (PHP)</h1>
|
29
|
+
|
30
|
+
<div id="input">
|
31
|
+
<form id="paymentform" action="process.php" method="post">
|
32
|
+
<fieldset>
|
33
|
+
<legend>1. Merchant</legend>
|
34
|
+
<div class="row"><label for="merchantname">Merchant name:</label><input name="merchantname" type="text" size="30" value="phptest" /></div>
|
35
|
+
<div class="row"><label for="merchantpassword">Merchant password:</label><input name="merchantpassword" type="text" size="30" value="xxx" /></div>
|
36
|
+
</fieldset>
|
37
|
+
|
38
|
+
<fieldset>
|
39
|
+
<legend>2. Order</legend>
|
40
|
+
<div class="row"><label for="merchantOrderReference">merchantOrderReference:</label><input name="merchantOrderReference" type="text" size="30" value="12345" /></div>
|
41
|
+
<div class="row"><label for="totalGrossAmount">totalGrossAmount:</label><input name="totalGrossAmount" type="text" size="30" value="1000" /></div>
|
42
|
+
<div class="row"><label for="totalNetAmount">totalNetAmount:</label><input name="totalNetAmount" type="text" size="30" value="1000" /></div>
|
43
|
+
<div class="row"><label for="totalVatAmount">totalVatAmount:</label><input name="totalVatAmount" type="text" size="30" value="190" /></div>
|
44
|
+
</fieldset>
|
45
|
+
|
46
|
+
<fieldset>
|
47
|
+
<legend>3. Shopper</legend>
|
48
|
+
<div class="row"><label for="shopperid">Shopper ID:</label><input name="shopperid" type="text" size="30" value="12345" /></div>
|
49
|
+
<div class="row"><label for="shoppernamefirst">First name:</label><input name="shoppernamefirst" type="text" size="30" value="Firstname" /></div>
|
50
|
+
<div class="row"><label for="shoppernameinitials">Last name:</label><input name="shoppernameinitials" type="text" size="30" value="T." /></div>
|
51
|
+
<div class="row"><label for="shoppernamelast">Last name:</label><input name="shoppernamelast" type="text" size="30" value="Lastname" /></div>
|
52
|
+
<div class="row"><label for="shopperemail">Email:</label><input name="shopperemail" type="text" size="30" value="info@test.com" /></div>
|
53
|
+
|
54
|
+
<div class="row"><label for="shopperlanguagecode">Language:</label><input name="shopperlanguagecode" type="text" size="30" value="nl" /></div>
|
55
|
+
<div class="row"><label for="shoppergender">Gender:</label><input name="shoppergender" type="text" size="30" value="M" /></div>
|
56
|
+
<div class="row"><label for="shopperdateOfBirth">Date of birth:</label><input name="shopperdateOfBirth" type="text" size="30" value="1972-02-02" /></div>
|
57
|
+
<div class="row"><label for="shopperphoneNumber">Phonenumber:</label><input name="shopperphoneNumber" type="text" size="30" value="+31201234567" /></div>
|
58
|
+
<div class="row"><label for="shoppermobilePhoneNumber">Mobile:</label><input name="shoppermobilePhoneNumber" type="text" size="30" value="+3161234567" /></div>
|
59
|
+
</fieldset>
|
60
|
+
|
61
|
+
<fieldset>
|
62
|
+
<legend>4. Address</legend>
|
63
|
+
<div class="row"><label for="street">Street:</label><input name="street" type="text" size="30" value="Teststraat" /></div>
|
64
|
+
<div class="row"><label for="houseNumber">House number:</label><input name="houseNumber" type="text" size="30" value="10" /></div>
|
65
|
+
<div class="row"><label for="postalCode">Postalcode:</label><input name="postalCode" type="text" size="30" value="1000AA" /></div>
|
66
|
+
<div class="row"><label for="city">City:</label><input name="city" type="text" size="30" value="Amsterdam" /></div>
|
67
|
+
<div class="row"><label for="country">Country:</label><input name="country" type="text" size="30" value="NL" /></div>
|
68
|
+
</fieldset>
|
69
|
+
|
70
|
+
<input type="submit" value="TEST" />
|
71
|
+
</form>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
<div id="contact">
|
75
|
+
Example by <a href="http://www.individualae.nl">Individual AE</a>
|
76
|
+
</div>
|
77
|
+
</body>
|
78
|
+
</html>
|
@@ -0,0 +1,182 @@
|
|
1
|
+
<pre>
|
2
|
+
<h2>Post</h2>
|
3
|
+
<?php
|
4
|
+
// Example by www.individualae.nl
|
5
|
+
// info@individualae.nl
|
6
|
+
// +31(0)20-6982047
|
7
|
+
|
8
|
+
print_r($_POST);
|
9
|
+
|
10
|
+
//$url = "https://secure.docdatapayments.com/ps/services/paymentservice/1_1?wsdl"; // live url
|
11
|
+
$url = "https://test.docdatapayments.com/ps/services/paymentservice/1_1?wsdl";
|
12
|
+
$base_url = 'http://localhost/docdatapayment/'; // only required for example
|
13
|
+
|
14
|
+
$client = new SoapClient( $url );
|
15
|
+
|
16
|
+
$parameters = array();
|
17
|
+
|
18
|
+
$parameters['version'] = "1.1";
|
19
|
+
|
20
|
+
// merchant information
|
21
|
+
$parameters['merchant']['name'] = $_POST['merchantname'];
|
22
|
+
$parameters['merchant']['password'] = $_POST['merchantpassword'];
|
23
|
+
|
24
|
+
$parameters['menuPreferences']['css']['id']=1;
|
25
|
+
|
26
|
+
$parameters['paymentPreferences']['profile'] = 'standard';
|
27
|
+
$parameters['paymentPreferences']['numberOfDaysToPay'] = '14';
|
28
|
+
|
29
|
+
|
30
|
+
// order reference
|
31
|
+
$parameters['merchantOrderReference'] = $_POST['merchantOrderReference']; // order reference must be unique
|
32
|
+
|
33
|
+
$parameters['totalGrossAmount'] = array(
|
34
|
+
'_' => '2000',
|
35
|
+
'currency' => 'EUR');
|
36
|
+
|
37
|
+
// shopper information
|
38
|
+
$parameters['shopper']['id'] = $_POST['shopperid'];
|
39
|
+
$parameters['shopper']['name']['first'] = $_POST['shoppernamefirst'];
|
40
|
+
$parameters['shopper']['name']['last'] = $_POST['shoppernamelast'];
|
41
|
+
$parameters['shopper']['email'] = $_POST['shopperemail'];
|
42
|
+
$parameters['shopper']['language']['code'] = $_POST['shopperlanguagecode'];
|
43
|
+
$parameters['shopper']['gender'] = $_POST['shoppergender'];
|
44
|
+
$parameters['shopper']['dateOfBirth'] = $_POST['shopperdateOfBirth'];
|
45
|
+
$parameters['shopper']['phoneNumber'] = $_POST['shopperphoneNumber'];
|
46
|
+
$parameters['shopper']['mobilePhoneNumber'] = $_POST['shoppermobilePhoneNumber'];
|
47
|
+
|
48
|
+
// billing to information
|
49
|
+
$parameters['billTo']['name']['first'] = $_POST['shoppernamefirst'];
|
50
|
+
$parameters['billTo']['name']['last'] = $_POST['shoppernamelast'];
|
51
|
+
$parameters['billTo']['name']['initials'] = $_POST['shoppernameinitials'];
|
52
|
+
$parameters['billTo']['address']['street'] = $_POST['street'];
|
53
|
+
$parameters['billTo']['address']['houseNumber'] = $_POST['houseNumber'];
|
54
|
+
$parameters['billTo']['address']['postalCode'] = $_POST['postalCode'];
|
55
|
+
$parameters['billTo']['address']['city'] = $_POST['city'];
|
56
|
+
$parameters['billTo']['address']['country']['code'] = $_POST['country'];
|
57
|
+
|
58
|
+
// shipto information is required to set when using invoice
|
59
|
+
// invoice is required for using lineitems
|
60
|
+
$parameters['invoice']['shipTo']['name']['first'] = $_POST['shoppernamefirst'];
|
61
|
+
$parameters['invoice']['shipTo']['name']['last'] = $_POST['shoppernamelast'];
|
62
|
+
$parameters['invoice']['shipTo']['address']['street'] = $_POST['street'];
|
63
|
+
$parameters['invoice']['shipTo']['address']['houseNumber'] = $_POST['houseNumber'];
|
64
|
+
$parameters['invoice']['shipTo']['address']['postalCode'] = $_POST['postalCode'];
|
65
|
+
$parameters['invoice']['shipTo']['address']['city'] = $_POST['city'];
|
66
|
+
$parameters['invoice']['shipTo']['address']['country']['code'] = $_POST['country'];
|
67
|
+
|
68
|
+
// invoice information required when using lineitems
|
69
|
+
$parameters['invoice']['additionalDescription'] = "Additional information";
|
70
|
+
$parameters['invoice']['totalNetAmount'] = array(
|
71
|
+
'_' => '1000',
|
72
|
+
'currency' => 'EUR');
|
73
|
+
$parameters['invoice']['totalVatAmount'] = array(
|
74
|
+
'_' => '190',
|
75
|
+
'currency' => 'EUR',
|
76
|
+
'rate' => '19');
|
77
|
+
|
78
|
+
// lineitem - 1
|
79
|
+
$parameters['invoice']['item'][0]['number'] = '12345';
|
80
|
+
$parameters['invoice']['item'][0]['name'] = 'Test product';
|
81
|
+
$parameters['invoice']['item'][0]['code'] = '12345';
|
82
|
+
$parameters['invoice']['item'][0]['quantity'] = array(
|
83
|
+
'_' => '1',
|
84
|
+
'unitOfMeasure' => 'PCS');
|
85
|
+
|
86
|
+
$parameters['invoice']['item'][0]['description'] = 'Dit is een test product';
|
87
|
+
$parameters['invoice']['item'][0]['netAmount'] = array(
|
88
|
+
'_' => '1000',
|
89
|
+
'currency' => 'EUR');
|
90
|
+
$parameters['invoice']['item'][0]['grossAmount'] = array(
|
91
|
+
'_' => '1000',
|
92
|
+
'currency' => 'EUR');
|
93
|
+
$parameters['invoice']['item'][0]['vat'] = array(
|
94
|
+
'rate' => '19',
|
95
|
+
'amount' => array(
|
96
|
+
'_' => '190',
|
97
|
+
'currency' => 'EUR')
|
98
|
+
);
|
99
|
+
$parameters['invoice']['item'][0]['totalNetAmount'] = array(
|
100
|
+
'_' => '1000',
|
101
|
+
'currency' => 'EUR');
|
102
|
+
$parameters['invoice']['item'][0]['totalGrossAmount'] = array(
|
103
|
+
'_' => '1000',
|
104
|
+
'currency' => 'EUR');
|
105
|
+
$parameters['invoice']['item'][0]['totalVat'] = array(
|
106
|
+
'rate' => '19',
|
107
|
+
'amount' => array(
|
108
|
+
'_' => '119',
|
109
|
+
'currency' => 'EUR') );
|
110
|
+
// lineitem - 2
|
111
|
+
$parameters['invoice']['item'][1]['number'] = '789';
|
112
|
+
$parameters['invoice']['item'][1]['name'] = 'Test product 2';
|
113
|
+
$parameters['invoice']['item'][1]['code'] = '789';
|
114
|
+
$parameters['invoice']['item'][1]['quantity'] = array(
|
115
|
+
'_' => '1',
|
116
|
+
'unitOfMeasure' => 'PCS');
|
117
|
+
|
118
|
+
$parameters['invoice']['item'][1]['description'] = 'Dit is een test product 2';
|
119
|
+
$parameters['invoice']['item'][1]['netAmount'] = array(
|
120
|
+
'_' => '1000',
|
121
|
+
'currency' => 'EUR');
|
122
|
+
$parameters['invoice']['item'][1]['grossAmount'] = array(
|
123
|
+
'_' => '1000',
|
124
|
+
'currency' => 'EUR');
|
125
|
+
$parameters['invoice']['item'][1]['vat'] = array(
|
126
|
+
'rate' => '19',
|
127
|
+
'amount' => array(
|
128
|
+
'_' => '190',
|
129
|
+
'currency' => 'EUR')
|
130
|
+
);
|
131
|
+
$parameters['invoice']['item'][1]['totalNetAmount'] = array(
|
132
|
+
'_' => '1000',
|
133
|
+
'currency' => 'EUR');
|
134
|
+
$parameters['invoice']['item'][1]['totalGrossAmount'] = array(
|
135
|
+
'_' => '1000',
|
136
|
+
'currency' => 'EUR');
|
137
|
+
$parameters['invoice']['item'][1]['totalVat'] = array(
|
138
|
+
'rate' => '19',
|
139
|
+
'amount' => array(
|
140
|
+
'_' => '119',
|
141
|
+
'currency' => 'EUR') );
|
142
|
+
|
143
|
+
// dorequest
|
144
|
+
echo "<h2>Create</h2>";
|
145
|
+
|
146
|
+
$response = $client->create( $parameters );
|
147
|
+
|
148
|
+
$parameters['paymentOrderKey'] = '';
|
149
|
+
|
150
|
+
if( isset( $response->createSuccess->success ) ) {
|
151
|
+
echo "Order created successfull with key " . $response->createSuccess->key;
|
152
|
+
$parameters['paymentOrderKey'] = $response->createSuccess->key;
|
153
|
+
} else {
|
154
|
+
print_r( $response->createError );
|
155
|
+
}
|
156
|
+
|
157
|
+
// create redirect url
|
158
|
+
$url = array();
|
159
|
+
$url['payment_cluster_key'] = $parameters['paymentOrderKey'];
|
160
|
+
$url['merchant_name'] = $parameters['merchant']['name'];
|
161
|
+
$url['return_url_success'] = $base_url . 'return.php?key='. $url['payment_cluster_key'];
|
162
|
+
$url['return_url_pending'] = $base_url . 'return.php?key='. $url['payment_cluster_key'];
|
163
|
+
$url['return_url_canceled'] = $base_url . 'return.php?key='. $url['payment_cluster_key'];
|
164
|
+
$url['return_url_error'] = $base_url .'return.php?key='. $url['payment_cluster_key'];
|
165
|
+
$url['locale'] = '';
|
166
|
+
$redirecturl = 'https://test.docdatapayments.com/ps/menu?';
|
167
|
+
|
168
|
+
$counter = 0;
|
169
|
+
foreach( $url as $key => $item ) {
|
170
|
+
$seperator = "&";
|
171
|
+
|
172
|
+
if($counter == 0 ) $seperator = "";
|
173
|
+
$redirecturl .= $seperator . $key . "=" . $item;
|
174
|
+
|
175
|
+
$counter++;
|
176
|
+
}
|
177
|
+
|
178
|
+
?>
|
179
|
+
</pre>
|
180
|
+
<?php
|
181
|
+
echo '<a href="'. $redirecturl .'">' . $redirecturl . '</a>';
|
182
|
+
?>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<pre>
|
2
|
+
<?php
|
3
|
+
|
4
|
+
$key = $_GET['key'];
|
5
|
+
|
6
|
+
//$url = "https://secure.docdatapayments.com/ps/services/paymentservice/1_1?wsdl"; // live url
|
7
|
+
$url = "https://test.docdatapayments.com/ps/services/paymentservice/1_1?wsdl";
|
8
|
+
|
9
|
+
$client = new SoapClient( $url );
|
10
|
+
|
11
|
+
//var_dump($client->__getFunctions());
|
12
|
+
|
13
|
+
$parameters = array();
|
14
|
+
|
15
|
+
$parameters['version'] = "1.1";
|
16
|
+
|
17
|
+
// merchant
|
18
|
+
//$parameters['merchant']['name'] = $_POST['merchantname'];
|
19
|
+
//$parameters['merchant']['password'] = $_POST['merchantpassword'];
|
20
|
+
$parameters['merchant']['name'] = 'phptest';
|
21
|
+
$parameters['merchant']['password'] = 'xxx';
|
22
|
+
|
23
|
+
$parameters['paymentOrderKey'] = $key;
|
24
|
+
|
25
|
+
// dorequest
|
26
|
+
echo "<h2>Status</h2>";
|
27
|
+
|
28
|
+
$response = $client->status( $parameters );
|
29
|
+
|
30
|
+
if( isset( $response->statusSuccess->success ) ) {
|
31
|
+
print_r($response->statusSuccess->report);
|
32
|
+
} else {
|
33
|
+
print_r( $response->statusError );
|
34
|
+
}
|
35
|
+
?>
|
36
|
+
</pre>
|
data/php-example/soap.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'savon'
|
3
|
+
# gem 'savon', '~> 2.0'
|
4
|
+
|
5
|
+
# require 'rubyntlm'
|
6
|
+
|
7
|
+
url = "https://test.docdatapayments.com/ps/services/paymentservice/1_1?wsdl"
|
8
|
+
# client = Savon.client(wsdl: url, strip_namespaces: false)
|
9
|
+
# client.namespaces = { "xmlns:_1" => "http://www.docdatapayments.com/services/paymentservice/1_1/" }
|
10
|
+
|
11
|
+
# client.call(:create)
|
12
|
+
xml = File.read("#{File.dirname(__FILE__)}/create.xml")
|
13
|
+
client = Savon.client(wsdl: url, namespace: "http://www.docdatapayments.com/services/paymentservice/1_1/")
|
14
|
+
|
15
|
+
response = client.call(:create, xml: xml.to_s)
|
16
|
+
|
17
|
+
# response = client.call(:create, create_request: "<![CDATA#{xml}]]>")
|
18
|
+
puts response
|
19
|
+
# response = client.call(:create) do |locals|
|
20
|
+
# locals.message "Query" => {"Head" => {"UserId" => "my_username_here", "Password" => "my_password_here", "SchemaName" => "StandardXML1_2"}, "Body" => {"MLS" => "nwmls", "PropertyType" => "RESI", "BeginDate" => "2014-04-17T00:25:00", "EndDate" => "2014-04-22T00:25:00"}}
|
21
|
+
# end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docdata do
|
4
|
+
before(:each) do
|
5
|
+
Docdata.test_mode = true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns correct version number" do
|
9
|
+
expect(Docdata.version).to eq(Docdata::VERSION)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "settings" do
|
13
|
+
it "is in test mode by default" do
|
14
|
+
expect(Docdata.test_mode).to eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
# it "should have the correct default values" do
|
18
|
+
# expect(Docdata.test_mode).to be_truthy
|
19
|
+
# expect(Docdata.username).to be_nil
|
20
|
+
# expect(Docdata.password).to be_nil
|
21
|
+
# end
|
22
|
+
|
23
|
+
it "is able to update and set settings" do
|
24
|
+
Docdata.test_mode = false
|
25
|
+
Docdata.username = "abcd"
|
26
|
+
Docdata.password = "321zyx12"
|
27
|
+
|
28
|
+
expect(Docdata.test_mode).to be_falsey
|
29
|
+
expect(Docdata.username).to match "abcd"
|
30
|
+
expect(Docdata.password).to match "321zyx12"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "SOAP configuration" do
|
35
|
+
|
36
|
+
it "should have the proper test URL" do
|
37
|
+
expect(Docdata.test_mode).to eq(true)
|
38
|
+
expect(Docdata.url).to eq("https://test.docdatapayments.com/ps/services/paymentservice/1_1?wsdl")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a response" do
|
42
|
+
VCR.use_cassette("wsdl-init") do
|
43
|
+
expect(Docdata.client.class.to_s).to eq("Savon::Client")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has methods to create, cancel, start, etc." do
|
48
|
+
VCR.use_cassette("wsdl-client-methods") do
|
49
|
+
expect(Docdata.client.operations).to match_array([:create, :cancel, :start, :refund, :status, :capture, :status_extended])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/ideal_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docdata::Ideal do
|
4
|
+
it "returns a hash of at least 5 banks" do
|
5
|
+
VCR.use_cassette("retrieve-bank-list") do
|
6
|
+
expect(Docdata::Ideal.banks).to be_kind_of(Array)
|
7
|
+
expect(Docdata::Ideal.banks.count).to be > 5
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "each bank has a name and a code" do
|
12
|
+
VCR.use_cassette("retrieve-bank-list") do
|
13
|
+
bank_1 = Docdata::Ideal.banks.first
|
14
|
+
expect(bank_1).to be_kind_of(Docdata::Bank)
|
15
|
+
expect(bank_1.id).to match /[0-9]{4}/
|
16
|
+
expect(bank_1.name).to match /[a-z]{3,}/i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# require 'spec_helper'
|
2
|
+
|
3
|
+
# describe Docdata::LineItem do
|
4
|
+
# before(:each) do
|
5
|
+
# @shopper = Docdata::Shopper.create_valid_shopper
|
6
|
+
# @payment = Docdata::Payment.new
|
7
|
+
# @payment.amount = 500
|
8
|
+
# @payment.profile = ENV["DOCDATA_PAYMENT_PROFILE"]
|
9
|
+
# @payment.order_reference = rand(500)
|
10
|
+
# @payment.currency = "EUR"
|
11
|
+
# @payment.shopper = @shopper
|
12
|
+
# end
|
13
|
+
|
14
|
+
# describe "#new" do
|
15
|
+
# it "validates attributes" do
|
16
|
+
# line_item = Docdata::LineItem.new
|
17
|
+
# expect(line_item).not_to be_valid
|
18
|
+
# expect(line_item.errors.full_messages).to include("name is not present")
|
19
|
+
# expect(line_item.errors.full_messages).to include("code is not present")
|
20
|
+
# expect(line_item.errors.full_messages).to include("quantity is not present")
|
21
|
+
# expect(line_item.errors.full_messages).to include("price_per_unit is not present")
|
22
|
+
# expect(line_item.errors.full_messages).to include("description is not present")
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
|
26
|
+
# it "raises error when payment is created and LineItems are not valid" do
|
27
|
+
# line_item = Docdata::LineItem.new
|
28
|
+
# @payment.line_items << line_item
|
29
|
+
# VCR.use_cassette("payments-create-with-invalid-line-items") do
|
30
|
+
# expect { @payment.create }.to raise_error(DocdataError, "One of your line_items is invalid. Error messages: name is not present, quantity is not present, quantity is not a number, price_per_unit is not present, price_per_unit is not a number, description is not present, code is not present")
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
# describe "successfull payments" do
|
35
|
+
|
36
|
+
# before(:each) do
|
37
|
+
# @line_item = Docdata::LineItem.new
|
38
|
+
# @line_item.name = "Green eggs and Ham"
|
39
|
+
# @line_item.code = "GEH123"
|
40
|
+
# @line_item.quantity = 1
|
41
|
+
# @line_item.price_per_unit = 1299
|
42
|
+
# @line_item.description = "Book by dr. Seuss"
|
43
|
+
# end
|
44
|
+
|
45
|
+
# it "makes create request with line items" do
|
46
|
+
|
47
|
+
# @payment.line_items << @line_item
|
48
|
+
# VCR.use_cassette("payments-create-with-valid-line-items") do
|
49
|
+
# result = @payment.create
|
50
|
+
# expect(result).to be_success
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
|
54
|
+
# end
|
55
|
+
# end
|