| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer2::Plugin::Interchange6::Business::OnlinePayment; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
507935
|
use Business::OnlinePayment 3.02; |
|
|
4
|
|
|
|
|
9432
|
|
|
|
4
|
|
|
|
|
94
|
|
|
4
|
4
|
|
|
4
|
|
441
|
use Dancer2 ':syntax'; |
|
|
4
|
|
|
|
|
225497
|
|
|
|
4
|
|
|
|
|
27
|
|
|
5
|
4
|
|
|
4
|
|
131596
|
use Moo; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
27
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Dancer2::Plugin::Interchange6::Business::OnlinePayment - Interchange6 wrapper for Business:OnlinePayment |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Configuration for AuthorizeNet provider: |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
plugins: |
|
16
|
|
|
|
|
|
|
Interchange6: |
|
17
|
|
|
|
|
|
|
payment: |
|
18
|
|
|
|
|
|
|
default_provider: AuthorizeNet |
|
19
|
|
|
|
|
|
|
providers: |
|
20
|
|
|
|
|
|
|
AuthorizeNet: |
|
21
|
|
|
|
|
|
|
login: <API Login ID> |
|
22
|
|
|
|
|
|
|
password: <Transaction Key> |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
If you use a test account, please add the following |
|
25
|
|
|
|
|
|
|
parameters: |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
test_transaction: 1 |
|
28
|
|
|
|
|
|
|
server: test.authorize.net |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 provider |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Payment provider. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has provider => ( |
|
39
|
|
|
|
|
|
|
is => 'rwp', |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 provider_args |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Payment provider settings, like login and password. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has provider_args => ( |
|
49
|
|
|
|
|
|
|
is => 'rwp', |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 payment_order |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Payment order object. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has payment_order => ( |
|
59
|
|
|
|
|
|
|
is => 'rw', |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 is_success |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
True if the payment was successful, false otherwise. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has is_success => ( |
|
69
|
|
|
|
|
|
|
is => 'rwp', |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 authorization |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns authorization code from provider after a successful |
|
75
|
|
|
|
|
|
|
payment. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has authorization => ( |
|
80
|
|
|
|
|
|
|
is => 'rwp', |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 order_number |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns unique order number from provider after a successful |
|
86
|
|
|
|
|
|
|
payment. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has order_number => ( |
|
91
|
|
|
|
|
|
|
is => 'rwp', |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 error_code |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns error code in case of payment failure. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has error_code => ( |
|
101
|
|
|
|
|
|
|
is => 'rwp', |
|
102
|
|
|
|
|
|
|
); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 error_message |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns error message in case of payment failure. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
has error_message => ( |
|
111
|
|
|
|
|
|
|
is => 'rwp', |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub BUILDARGS { |
|
115
|
8
|
|
|
8
|
0
|
5495
|
my ( $class, @args ) = @_; |
|
116
|
8
|
|
|
|
|
16
|
my ( %params ); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# first argument is the provider |
|
119
|
8
|
|
|
|
|
22
|
$params{provider} = shift @args; |
|
120
|
8
|
|
|
|
|
30
|
$params{provider_args} = {@args}; |
|
121
|
|
|
|
|
|
|
|
|
122
|
8
|
|
|
|
|
131
|
return \%params; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 charge |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Performs charge transaction with payment provider. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub charge { |
|
134
|
8
|
|
|
8
|
1
|
1064
|
my ( $self, %args ) = @_; |
|
135
|
8
|
|
|
|
|
15
|
my ( $provider_settings, $bop_object ); |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# reset values |
|
138
|
8
|
|
|
|
|
31
|
$self->_set_is_success(0); |
|
139
|
8
|
|
|
|
|
26
|
$self->_set_authorization(''); |
|
140
|
8
|
|
|
|
|
39
|
$self->_set_order_number(''); |
|
141
|
8
|
|
|
|
|
20
|
$self->_set_error_code(''); |
|
142
|
8
|
|
|
|
|
23
|
$self->_set_error_message(''); |
|
143
|
|
|
|
|
|
|
|
|
144
|
8
|
|
|
|
|
23
|
$provider_settings = $self->provider_args; |
|
145
|
|
|
|
|
|
|
|
|
146
|
8
|
|
|
|
|
75
|
$bop_object = Business::OnlinePayment->new($self->provider, %$provider_settings); |
|
147
|
|
|
|
|
|
|
|
|
148
|
8
|
100
|
|
|
|
5224
|
if ($provider_settings->{server}) { |
|
149
|
1
|
|
|
|
|
18
|
$bop_object->server( $provider_settings->{server} ); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Sofortbanking expects amount as xx.xx |
|
153
|
8
|
|
|
|
|
126
|
$args{amount} = sprintf( '%.2f', $args{amount} ); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$bop_object->content( |
|
156
|
|
|
|
|
|
|
%$provider_settings, |
|
157
|
|
|
|
|
|
|
amount => $args{amount}, |
|
158
|
|
|
|
|
|
|
card_number => $args{card_number}, |
|
159
|
|
|
|
|
|
|
expiration => $args{expiration}, |
|
160
|
|
|
|
|
|
|
cvc => $args{cvc}, |
|
161
|
|
|
|
|
|
|
first_name => $args{first_name}, |
|
162
|
|
|
|
|
|
|
last_name => $args{last_name}, |
|
163
|
|
|
|
|
|
|
login => $provider_settings->{login}, |
|
164
|
|
|
|
|
|
|
password => $provider_settings->{password}, |
|
165
|
|
|
|
|
|
|
type => $args{type} || $provider_settings->{type} || 'CC', |
|
166
|
8
|
|
100
|
|
|
193
|
action => $args{action} || $provider_settings->{action} || 'Authorization Only', |
|
|
|
|
100
|
|
|
|
|
|
167
|
|
|
|
|
|
|
); |
|
168
|
|
|
|
|
|
|
|
|
169
|
8
|
|
|
|
|
429
|
eval { $bop_object->submit(); }; |
|
|
8
|
|
|
|
|
21
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
8
|
100
|
|
|
|
685
|
if ($@) { |
|
172
|
2
|
|
|
|
|
27
|
die "Payment with provider ", $self->{provider}, " failed: ", $@; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
6
|
100
|
|
|
|
91
|
if ( $bop_object->is_success() ) { |
|
176
|
4
|
|
|
|
|
26
|
$self->_set_is_success(1); |
|
177
|
|
|
|
|
|
|
|
|
178
|
4
|
100
|
|
|
|
25
|
if ( $bop_object->can('popup_url') ) { |
|
179
|
1
|
|
|
|
|
4
|
debug( "Success! Redirect browser to " . $bop_object->popup_url() ); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
else { |
|
182
|
3
|
|
|
|
|
46
|
debug("Successful payment, authorization: ", |
|
183
|
|
|
|
|
|
|
$bop_object->authorization); |
|
184
|
3
|
|
|
|
|
2443
|
debug("Order number: ", $bop_object->order_number); |
|
185
|
3
|
|
|
|
|
1300
|
$self->_set_authorization($bop_object->authorization); |
|
186
|
3
|
|
|
|
|
62
|
$self->_set_order_number($bop_object->order_number); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
else { |
|
190
|
2
|
|
|
|
|
41
|
debug( 'Card was rejected by ', $self->provider, ': ' , $bop_object->error_message ); |
|
191
|
2
|
|
|
|
|
38717
|
$self->_set_error_code($bop_object->failure_status); |
|
192
|
2
|
|
|
|
|
46
|
$self->_set_error_message($bop_object->error_message); |
|
193
|
2
|
|
|
|
|
45
|
return; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Stefan Hornburg (Racke), <racke@linuxia.de> |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Copyright 2012-2016 Stefan Hornburg (Racke) <racke@linuxia.de>. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
206
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
207
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
1; |