Business-OnlinePayment-DLocal

 view release on metacpan or  search on metacpan

t/01-sale.t  view on Meta::CPAN

#!/usr/bin/env perl

use 5.010;
use strict;
use warnings;

use Test::More;
use Module::Runtime qw( use_module );
use Time::HiRes;

my $username = $ENV{PERL_BUSINESS_DLOCAL_USERNAME} || 'mocked';
my $password = $ENV{PERL_BUSINESS_DLOCAL_PASSWORD} || 'mocked';
my $secret   = $ENV{PERL_BUSINESS_DLOCAL_SECRET}   || 'mocked';
my $reports_username   = $ENV{PERL_BUSINESS_DLOCAL_REPORTS_USERNAME}   || 'mocked';
my $reports_key   = $ENV{PERL_BUSINESS_DLOCAL_REPORTS_KEY}   || 'mocked';

if ($username eq 'mocked') {
    diag '';
    diag '';
    diag '';
    diag 'All tests are run using MOCKED return values.';
    diag 'If you wish to run REAL tests then add these ENV variables.';
    diag '';
    diag 'export PERL_BUSINESS_DLOCAL_USERNAME=your_test_user';
    diag 'export PERL_BUSINESS_DLOCAL_PASSWORD=your_test_password';
    diag 'export PERL_BUSINESS_DLOCAL_SECRET=your_test_secret';
    diag 'export PERL_BUSINESS_DLOCAL_REPORTS_USERNAME=your_reports_user';
    diag 'export PERL_BUSINESS_DLOCAL_REPORTS_KEY=your_reports_key';
    diag '';
    diag '';
}

if ( $username ne 'mocked' && $password ne 'mocked') {
    plan tests => 20;
} else {
    plan skip_all => 'No credentials set in the environment.'
      . ' Set PERL_BUSINESS_DLOCAL_USERNAME and '
      . ' PERL_BUSINESS_DLOCAL_SECRET and '
      . 'PERL_BUSINESS_DLOCAL_PASSWORD to run this test.'
}

my $client = new_ok( use_module('Business::OnlinePayment'), ['DLocal'] );
$client->test_transaction(1);    # test, dont really charge

my @test_cards = (
    '6363687851866592',
    '6062823125988953',
    #'5300323635297148',
    '3696656326587732', # DC
    '4312522698854138', # VI
    '3432524265896994', # AMEX
    '5578390741038760', # MC

    '5078601870000123', # aura
    '5895626746595650', # naranja
    '5200533989557118', # nativa
    #'6034883265619896', # tarjeta
    #'6034932528973614', # cencosud
    #'6271701225979642', # cabal
    '5011054488597827', # Argencard
);


my $data = {
 login          => $username,
 password       => $password,
 password2      => $secret,
 reports_login  => $reports_username,
 reports_key    => $reports_key,
 ##### action         => 'fetchByMerchantTransactionId',
 description    => 'Business::OnlinePayment visa test',

 division_number     => '1',
 type                => 'CC',
 amount              => '90.00',
 customer_number     => '123',
 subscription_number => 'TEST-'.Time::HiRes::time(),
 invoice_number      => 'TEST-'.Time::HiRes::time(),
 authorization       => '123456',
 timestamp           => '2012-09-11T22:34:32.265Z',
 first_name          => 'Bop',
 last_name           => 'Testing',
 address             => '123',
 city                => 'Santa Isabel',
 state               => 'RJ',
 zip                 => '0750000',
 country             => 'BR',
 currency            => 'USD',
 email               => 'testing2@astropaycard.com',
 card_number         => $test_cards[0],
 cvv2                => '554',
 cpf                 => '00003456789',
 expiration          => '06/19',
 device_id           => '54hj4h5jh46hasjd',
};



( run in 0.724 second using v1.01-cache-2.11-cpan-364913b4093 )