Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

inital request design, build out header

Signed-off-by: Caleb Cushing <xenoterracide@gmail.com>
  • Loading branch information...
commit 17dfb4f55c9fee034c51e264f3527aff00ed69c2 1 parent baae518
Caleb Cushing authored
82 lib/Business/CyberSource/Request.pm
... ... @@ -0,0 +1,82 @@
  1 +package Business::CyberSource::Request;
  2 +use 5.008;
  3 +use strict;
  4 +use warnings;
  5 +use Carp;
  6 +BEGIN {
  7 + # VERSION
  8 +}
  9 +use Moose::Role;
  10 +use SOAP::Data::Builder;
  11 +use Data::Dumper;
  12 +
  13 +has _username_token => (
  14 + is => 'rw',
  15 + isa => 'SOAP::Data::Builder::Element',
  16 +);
  17 +
  18 +has data_builder => (
  19 + required => 1,
  20 + is => 'rw',
  21 + isa => 'SOAP::Data::Builder',
  22 + default => sub {
  23 + my $self = shift;
  24 + my $sb = SOAP::Data::Builder->new;
  25 + $sb->autotype(0);
  26 + my $security = $sb->add_elem(
  27 + header => 1,
  28 + name => 'wsse:Security',
  29 + attributes => {
  30 + 'xmlns:wsse'
  31 + => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
  32 + }
  33 + );
  34 +
  35 + my $username_token = $sb->add_elem(
  36 + header => 1,
  37 + parent => $security,
  38 + name => 'wsse:UsernameToken',
  39 + );
  40 +
  41 + $self->_username_token( $username_token );
  42 +
  43 + return $sb;
  44 + },
  45 +);
  46 +
  47 +has username => (
  48 + required => 1,
  49 + is => 'ro',
  50 + isa => 'Str',
  51 + default => sub { '' },
  52 + trigger => sub {
  53 + my ( $self, $username ) = @_;
  54 + my $sb = $self->data_builder;
  55 + $sb->add_elem(
  56 + header => 1,
  57 + parent => $self->_username_token,
  58 + name => 'wsse:Username',
  59 + value => $username,
  60 + );
  61 + }
  62 +);
  63 +
  64 +has password => (
  65 + required => 1,
  66 + is => 'ro',
  67 + isa => 'Str', # actually I wonder if I can validate this more
  68 + default => sub { '' },
  69 + trigger => sub {
  70 + my ( $self, $password ) = @_;
  71 + $self->data_builder->add_elem(
  72 + header => 1,
  73 + parent => $self->_username_token,
  74 + name => 'wsse:Password',
  75 + value => $password,
  76 + );
  77 + }
  78 +);
  79 +
  80 +1;
  81 +
  82 +# ABSTRACT: Request Role
29 lib/Business/CyberSource/Request/Authorization.pm
... ... @@ -0,0 +1,29 @@
  1 +package Business::CyberSource::Request::Authorization;
  2 +use 5.008;
  3 +use strict;
  4 +use warnings;
  5 +BEGIN {
  6 + # VERSION
  7 +}
  8 +
  9 +use SOAP::Lite ( +trace => [ qw( debug ) ] );
  10 +use Moose;
  11 +with 'Business::CyberSource::Request';
  12 +
  13 +sub submit {
  14 + my ( $self ) = shift;
  15 +
  16 + my $req = SOAP::Lite->new(
  17 + readable => 1,
  18 + autotype => 0,
  19 + proxy => 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor',
  20 + default_ns => 'urn:schemas-cybersource-com:transaction-data-1.61',
  21 + );
  22 + my $ret = $req->requestMessage( $self->data_builder->to_soap_data )->result;
  23 + return $ret;
  24 +}
  25 +
  26 +__PACKAGE__->meta->make_immutable;
  27 +1;
  28 +
  29 +# ABSTRACT: CyberSource Authorization request object

0 comments on commit 17dfb4f

Please sign in to comment.
Something went wrong with that request. Please try again.