| 1 | package Business::OnlinePayment::Iridium::Action; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use LWP::UserAgent (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use HTTP::Request (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use XML::Simple (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # PODNAME: Business::OnlinePayment::Iridium::Action | ||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Send / receive data to / from PayVector | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub SERVERS { | ||||||||||||||||||||||||||
|
Subroutine
SERVERS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | return ( 'https://gw1.iridiumcorp.net/', 'https://gw2.iridiumcorp.net/', 'https://gw3.iridiumcorp.net/' ); | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | has 'MerchantID' => ( | |||||||||||||||||||||||||||
| 18 | isa => 'Str', | ||||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||
| 20 | required => '1' | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | has 'Password' => ( | |||||||||||||||||||||||||||
| 24 | isa => 'Str', | ||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||
| 26 | required => '1' | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | has 'CurrencyCode' => ( | |||||||||||||||||||||||||||
| 30 | isa => 'Int', | ||||||||||||||||||||||||||||
| 31 | is => 'rw', | ||||||||||||||||||||||||||||
| 32 | default => '826' # GBP | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | has 'PassOutData' => ( | |||||||||||||||||||||||||||
| 36 | isa => 'Str', | ||||||||||||||||||||||||||||
| 37 | is => 'rw', | ||||||||||||||||||||||||||||
| 38 | required => '0' | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | has '_user_agent' => ( | ||||||||||||||||||||||||||||
| 42 | isa => 'LWP::UserAgent', | ||||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | return LWP::UserAgent->new( agent => 'Business::OnlinePayment::Iridium', | |||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 1 | ); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | has '_type' => ( | |||||||||||||||||||||||||||
| 51 | isa => 'Str', | ||||||||||||||||||||||||||||
| 52 | is => 'ro', | ||||||||||||||||||||||||||||
| 53 | lazy_build => '1' | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | requires '_build__type'; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | requires 'template'; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _build_req_content { | ||||||||||||||||||||||||||
|
Subroutine
_build_req_content: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | my $vars = { | ||||||||||||||||||||||||||||
| 63 | map { | ||||||||||||||||||||||||||||
| 64 | 0 | my $attr_name = $_->name; | |||||||||||||||||||||||||||
| 65 | 0 | $attr_name => $self->$attr_name | |||||||||||||||||||||||||||
| 66 | } $self->meta->get_all_attributes | ||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||
| 68 | 0 | my ( $template, $output ) = ( $self->template, '' ); | |||||||||||||||||||||||||||
| 69 | 0 | my $tt = Template->new(); | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | $tt->process( \$template, $vars, \$output ) || confess $tt->error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | return $output; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub request { | ||||||||||||||||||||||||||
|
Subroutine
request: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 77 | 0 | my $content = $self->_build_req_content; | |||||||||||||||||||||||||||
| 78 | 0 | my $action_url = 'https://www.thepaymentgateway.net/'; | |||||||||||||||||||||||||||
| 79 | 0 | my $ua = $self->_user_agent; | |||||||||||||||||||||||||||
| 80 | 0 | my @SERVERS = $self->SERVERS; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | my $req = HTTP::Request->new( POST => $SERVERS[0] ); | |||||||||||||||||||||||||||
| 83 | 0 | $req->content_type('text/xml; charset=UTF-8'); | |||||||||||||||||||||||||||
| 84 | 0 | $req->header( 'SOAPAction' => $action_url . $self->_type ); | |||||||||||||||||||||||||||
| 85 | 0 | $req->content($content); | |||||||||||||||||||||||||||
| 86 | 0 | $req->content_length( length($content) ); | |||||||||||||||||||||||||||
| 87 | 0 | my $res = $ua->request($req); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | return $self->parse_response( $res->content ); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||
| 93 | 0 | $req->uri( $SERVERS[1] ); | |||||||||||||||||||||||||||
| 94 | 0 | $res = $ua->request($req); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( $res->is_success && $res->content ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->is_success and $res->content
MC/DC0%0/2
$res->is_success and $res->content
$res->is_success
$res->content
Truth table0%0/3
A and B
A= $res->is_successB= $res->content
| |||||||||||||||||||||||||||||
| 97 | 0 | return $self->parse_response( $res->content ); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||
| 100 | 0 | confess $res->status_line; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub parse_response { | ||||||||||||||||||||||||||
|
Subroutine
parse_response: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | my ( $self, $content ) = @_; | |||||||||||||||||||||||||||
| 108 | 0 | my $parser = XML::Simple->new; | |||||||||||||||||||||||||||
| 109 | 0 | return $parser->XMLin($content); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 1 | 1; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||