Business-OnlinePayment-CyberSource
view release on metacpan or search on metacpan
lib/Business/OnlinePayment/CyberSource/Role/TransactionHandling.pm view on Meta::CPAN
package Business::OnlinePayment::CyberSource::Role::TransactionHandling;
use 5.010;
use strict;
use warnings;
use namespace::autoclean;
use DateTime;
use Moose::Role;
use MooseX::StrictConstructor;
use Try::Tiny;
use Business::OnlinePayment::CyberSource::Client;
# ABSTRACT: Transaction handling role for BOP::CyberSource
our $VERSION = '3.000016'; # VERSION
#### Subroutine Definitions ####
# Submits the transaction request to CyberSource
# Accepts: Nothing
# Returns: Nothing
sub submit {
my ( $self ) = @_;
my $content = { $self->content() };
# Default values
my $data = {
reference_code => $content->{invoice_number}
};
$content->{currency} ||= 'USD';
# purchaser information
my $map = {
ip => 'customer_ip',
first_name => 'first_name',
last_name => 'last_name',
email => 'email',
phone_number => 'phone',
street1 => 'address',
city => 'city',
state => 'state',
postal_code => 'zip',
country => 'country',
};
foreach my $name ( keys %$map ) {
if (
$content->{ $map->{$name} }
&& $content->{action} !~ /^Post\ Authorization|Void$/ix
) {
$data->{bill_to}->{$name} = $content->{ $map->{$name} }
unless ( $content->{po_number} && $content->{action} =~ /^Credit$/ix );
}
}
# Purchase totals information
$data->{purchase_totals} = {
total => $content->{amount},
currency => $content->{currency},
};
$data->{service} = { request_id => $content->{po_number} }
if $content->{po_number};
( run in 0.389 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )