The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Business::OnlinePayment::CyberSource - CyberSource backend for Business::OnlinePayment

SYNOPSIS

use Business::OnlinePayment;

####
# One step transaction, the simple case.
####

my $tx = new Business::OnlinePayment("");
$tx->content(
           type           => 'VISA',
           action         => 'Normal Authorization',
           invoice_number => '00000001',
           items          => [{'number'   => 0,
                               'name'     => 'Test 1',
                               'quantity' => 1,
                               'unit_price' => '25.00'},
                                {'number'   => 1,
                                 'name'     => 'Test 2',
                                 'quantity' => 1,
                                 'unit_price' => '50.00'},
                              ],
           first_name     => 'Peter',
           last_name      => 'Bowen',
           address        => '123 Anystreet',
           city           => 'Orem',
           state          => 'UT',
           zip            => '84097',
           country        => 'US',
           email          => 'foo@bar.net',
           card_number    => '4111 1111 1111 1111',
           expiration     => '0906',
           cvv2           => '1234', #optional
           referer        => 'http://valid.referer.url/',
           user           => 'cybesource_user',
           fraud_check    => 'true',
           fraud_threshold => '90',
);
$tx->submit();

if($tx->is_success()) {
    print "Card processed successfully: ".$tx->authorization."\n";
} else {
    print "Card was rejected: ".$tx->error_message."\n";
}

####
# Two step transaction, authorization and capture.
# If you don't need to review order before capture, you can
# process in one step as above.
####

my $tx = new Business::OnlinePayment("AuthorizeNet");
$tx->content(
           type           => 'VISA',
           action         => 'Authorization Only',
           invoice_number => '00000001',
           items          => [{'number'   => 0,
                               'name'     => 'iPod Mini',
                               'quantity' => 1,
                               'unit_price' => '25.00'},
                                {'number'   => 1,
                                 'name'     => 'Extended Warranty',
                                 'quantity' => 1,
                                 'unit_price' => '50.00'},
                              ],
           first_name     => 'Peter',
           last_name      => 'Bowen',
           address        => '123 Anystreet',
           city           => 'Orem',
           state          => 'UT',
           zip            => '84097',
           country        => 'US',
           email          => 'foo@bar.net',
           card_number    => '4111 1111 1111 1111',
           expiration     => '0906',
           cvv2           => '1234', #optional
           referer        => 'http://valid.referer.url/',
           user           => 'cybesource_user',
           fraud_check    => 'true',
           fraud_threshold => '90',
);
$tx->submit();

if($tx->is_success()) {
    # get information about authorization
    $authorization = $tx->authorization
    $order_number = $tx->order_number;
    $avs_code = $tx->avs_code; # AVS Response Code
    $cvv2_response = $tx->cvv2_response; # CVV2/CVC2/CID Response Code
    $cavv_response = $tx->cavv_response; # Cardholder Authentication
                                         # Verification Value (CAVV) Response
                                         # Code

    # now capture transaction
    my $capture = new Business::OnlinePayment("CyberSource");

    $capture->content(
        action              => 'Post Authorization',
        order_number        => $order_number,
        merchant_descriptor => 'IPOD MINI',
        amount              => '75.00',
    );

    $capture->submit();

    if($capture->is_success()) { 
        print "Card captured successfully: ".$capture->authorization."\n";
    } else {
        print "Card was rejected: ".$capture->error_message."\n";
    }

} else {
    print "Card was rejected: ".$tx->error_message."\n";
}

SUPPORTED TRANSACTION TYPES

Visa, MasterCard, American Express, Discover

Content required: type, login, action, amount, first_name, last_name, card_number, expiration.

TODO - Checks

DESCRIPTION

For detailed information see Business::OnlinePayment.

NOTE

Unlike Business::OnlinePayment, Business::OnlinePayment::CyberSource requires separate first_name and last_name fields.

To settle an authorization-only transaction (where you set action to 'Authorization Only'), submit the request ID code in the field "order_number" with the action set to "Post Authorization".

You can get the transaction id from the authorization by calling the order_number method on the object returned from the authorization. You must also submit the amount field with a value less than or equal to the amount specified in the original authorization.

COMPATIBILITY

This module implements the Simple Order API 1.0 from Cybersource.

AUTHOR

Peter Bowen peter-cybersource@bowenfamily.org

Based on Business::OnlinePayment::AuthorizeNet

SEE ALSO

perl(1). Business::OnlinePayment.

TODO

Full Documentation
Electronic Checks
Pay Pal
Full support including Level III descriptors

1 POD Error

The following errors were encountered while parsing the POD:

Around line 526:

=over without closing =back