File Coverage

lib/Payment/Sisow/SOAP.pm
Criterion Covered Total %
statement 19 21 90.4
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 28 92.8


line stmt bran cond sub pod time code
1             # Copyrights 2013-2014 by [Mark Overmeer].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.01.
5 1     1   995 use warnings;
  1         2  
  1         39  
6 1     1   6 use strict;
  1         2  
  1         34  
7 1     1   5 use utf8;
  1         2  
  1         8  
8              
9             package Payment::Sisow::SOAP;
10 1     1   33 use vars '$VERSION';
  1         2  
  1         56  
11             $VERSION = '0.13';
12              
13 1     1   6 use base 'Payment::Sisow';
  1         2  
  1         101  
14              
15 1     1   7 use Log::Report 'sisow';
  1         8  
  1         10  
16              
17 1     1   823 use XML::Compile::WSDL11;
  0            
  0            
18             use XML::Compile::SOAP11;
19             use XML::Compile::SOAP12; # to understand SOAP1.2 info in WSDL
20             use XML::Compile::Transport::SOAPHTTP;
21              
22             use File::Basename qw(dirname);
23             use File::Spec ();
24              
25             my $wsdl_fn = File::Spec->catfile(dirname(__FILE__), 'sisow-soap-v2.0.wsdl');
26              
27              
28             sub init($)
29             { my ($self, $args) = @_;
30             $self->SUPER::init($args);
31              
32             my $wsdl = $self->{PSS_wsdl} = XML::Compile::WSDL11->new($wsdl_fn);
33             $wsdl->compileCalls(port => 'sisowSoap');
34              
35             $self;
36             }
37              
38             #--------------
39              
40             sub wsdl() {shift->{PSS_wsdl}}
41              
42             #--------------
43              
44             sub _list_ideal_banks(%)
45             { my ($self, %args) = @_;
46             my $test = (exists $args{test} ? $args{test} : $self->isTest) || 0;
47             my ($answer, $trace) = $self->wsdl->call(GetIssuers => test => $test);
48             unless($answer)
49             { $trace->printErrors;
50             panic $trace->{error};
51             }
52              
53             # $answer = { parameters =>
54             # { GetIssuersResult => 0,
55             # , issuers => { string => [ 'Sisow Bank (test)', 99 ] }
56             # }};
57             my @pairs = @{$answer->{parameters}{issuers}{string} || []};
58             my @issuers;
59             while(@pairs)
60             { my ($name, $id) = splice @pairs, 0, 2;
61             push @issuers, +{name => $name, id => $id};
62             }
63              
64             \@issuers;
65             }
66              
67             sub _transaction_status(%)
68             { my ($self, %args) = @_;
69              
70             my ($answer, $trace) = $self->wsdl->call(GetStatus => %args);
71             unless($answer)
72             { $trace->printErrors;
73             panic $trace->{error};
74             }
75              
76             # $answer = {parameters => {GetStatusResult => 0, status => 'Expired'}};
77             my $p = $answer->{parameters};
78             my $rc = $p->{GetStatusResult};
79             $rc==0
80             or error __x"request transaction {tid} status failed with {rc}"
81             , tid => $args{transaction}, rc => $rc;
82              
83             $p;
84             }
85              
86             sub _transaction_info(%)
87             { my ($self, %args) = @_;
88              
89             my ($answer, $trace) = $self->wsdl->call(GetTransaction => %args);
90             unless($answer)
91             { $trace->printErrors;
92             error $trace->{error};
93             }
94              
95             # $answer = {parameters => {GetTransactionResult => 0, @pairs}};
96             my $p = $answer->{parameters};
97             my $rc = delete $p->{GetTransactionResult};
98             $rc==0
99             or error __x"request transaction {tid} info failed with {rc}"
100             , tid => $args{transation}, rc => $rc;
101              
102             $p;
103             }
104              
105             sub _start_transaction(%)
106             { my ($self, %args) = @_;
107              
108             my ($answer, $trace) = $self->wsdl->call(GetURL => %args);
109             unless($answer)
110             { $trace->printErrors;
111             error $trace->{error};
112             }
113              
114              
115             # $answer = {parameters => {GetURLResult => 0, issuerurl =>, trxid => }};
116             my $p = $answer->{parameters};
117             my $rc = delete $p->{GetURLResult};
118             $rc==0
119             or error __x"start transaction for purchase {id} failed with {rc}"
120             , id => $args{purchaseid}, rc => $rc;
121              
122             $p;
123             }
124              
125             #--------------
126              
127             1;