Permalink
Browse files

inital request design, build out header

Signed-off-by: Caleb Cushing <xenoterracide@gmail.com>
  • Loading branch information...
1 parent baae518 commit 17dfb4f55c9fee034c51e264f3527aff00ed69c2 @xenoterracide committed Aug 10, 2011
Showing with 111 additions and 0 deletions.
  1. +82 −0 lib/Business/CyberSource/Request.pm
  2. +29 −0 lib/Business/CyberSource/Request/Authorization.pm
View
82 lib/Business/CyberSource/Request.pm
@@ -0,0 +1,82 @@
+package Business::CyberSource::Request;
+use 5.008;
+use strict;
+use warnings;
+use Carp;
+BEGIN {
+ # VERSION
+}
+use Moose::Role;
+use SOAP::Data::Builder;
+use Data::Dumper;
+
+has _username_token => (
+ is => 'rw',
+ isa => 'SOAP::Data::Builder::Element',
+);
+
+has data_builder => (
+ required => 1,
+ is => 'rw',
+ isa => 'SOAP::Data::Builder',
+ default => sub {
+ my $self = shift;
+ my $sb = SOAP::Data::Builder->new;
+ $sb->autotype(0);
+ my $security = $sb->add_elem(
+ header => 1,
+ name => 'wsse:Security',
+ attributes => {
+ 'xmlns:wsse'
+ => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
+ }
+ );
+
+ my $username_token = $sb->add_elem(
+ header => 1,
+ parent => $security,
+ name => 'wsse:UsernameToken',
+ );
+
+ $self->_username_token( $username_token );
+
+ return $sb;
+ },
+);
+
+has username => (
+ required => 1,
+ is => 'ro',
+ isa => 'Str',
+ default => sub { '' },
+ trigger => sub {
+ my ( $self, $username ) = @_;
+ my $sb = $self->data_builder;
+ $sb->add_elem(
+ header => 1,
+ parent => $self->_username_token,
+ name => 'wsse:Username',
+ value => $username,
+ );
+ }
+);
+
+has password => (
+ required => 1,
+ is => 'ro',
+ isa => 'Str', # actually I wonder if I can validate this more
+ default => sub { '' },
+ trigger => sub {
+ my ( $self, $password ) = @_;
+ $self->data_builder->add_elem(
+ header => 1,
+ parent => $self->_username_token,
+ name => 'wsse:Password',
+ value => $password,
+ );
+ }
+);
+
+1;
+
+# ABSTRACT: Request Role
View
29 lib/Business/CyberSource/Request/Authorization.pm
@@ -0,0 +1,29 @@
+package Business::CyberSource::Request::Authorization;
+use 5.008;
+use strict;
+use warnings;
+BEGIN {
+ # VERSION
+}
+
+use SOAP::Lite ( +trace => [ qw( debug ) ] );
+use Moose;
+with 'Business::CyberSource::Request';
+
+sub submit {
+ my ( $self ) = shift;
+
+ my $req = SOAP::Lite->new(
+ readable => 1,
+ autotype => 0,
+ proxy => 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor',
+ default_ns => 'urn:schemas-cybersource-com:transaction-data-1.61',
+ );
+ my $ret = $req->requestMessage( $self->data_builder->to_soap_data )->result;
+ return $ret;
+}
+
+__PACKAGE__->meta->make_immutable;
+1;
+
+# ABSTRACT: CyberSource Authorization request object

0 comments on commit 17dfb4f

Please sign in to comment.