Business-OnlinePayment-Braintree
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Business/OnlinePayment/Braintree.pm view on Meta::CPAN
package Business::OnlinePayment::Braintree;
use 5.006;
use strict;
use warnings;
use Business::OnlinePayment 3.01;
use Net::Braintree;
use base 'Business::OnlinePayment';
=head1 NAME
Business::OnlinePayment::Braintree - Online payment processing through Braintree
=head1 VERSION
Version 0.020
=cut
our $VERSION = '0.020';
=head1 SYNOPSIS
use Business::OnlinePayment;
$tx = new Business::OnlinePayment('Braintree',
merchant_id => 'your merchant id',
public_key => 'your public key',
private_key => 'your private key',
);
$tx->test_transaction(1); # sandbox transaction for development and tests
$tx->content(amount => 100,
card_number => '4111 1111 1111 1111',
expiration => '1212');
$tx->submit();
if ($tx->is_success) {
print "Card processed successfully: " . $tx->authorization . "\n";
} else {
print "Card was rejected: " . $tx->error_message . "\n";
}
=head1 DESCRIPTION
Online payment processing through Braintree based on L<Net::Braintree>.
The documentation for L<Net::Braintree> is located at
L<https://www.braintreepayments.com/docs/perl>.
=head1 NOTES
This is supposed to cover the complete Braintree Perl API finally.
=head1 METHODS
=head2 submit
Submits transaction to Braintree gateway.
=cut
sub submit {
my $self = shift;
my $config = Net::Braintree->configuration;
my %content = $self->content;
my ($action, $result, $transaction, $result_code);
# sandbox vs production
if ($self->test_transaction) {
$config->environment('sandbox');
}
else {
$config->environment('production');
}
# transaction
$action = lc($content{action});
if ($action eq 'normal authorization' ) {
$result = $self->sale(1);
}
elsif ($action eq 'authorization only') {
$result = $self->sale(0);
}
elsif ($action eq 'post authorization') {
$result = Net::Braintree::Transaction->submit_for_settlement($content{order_number}, $content{amount});
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.631 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )