Business-GoCardless

 view release on metacpan or  search on metacpan

lib/Business/GoCardless/Client.pm  view on Meta::CPAN

        Business::GoCardless::Exception->throw({
            message => "Invalid signature for confirm_resource"
        });
    }

    my $data = {
        resource_id   => $params->{resource_id},
        resource_type => $params->{resource_type},
    };

    my $credentials = encode_base64( $self->app_id . ':' . $self->app_secret );
    $credentials    =~ s/\s//g;

    my $ua = LWP::UserAgent->new;
    $ua->agent( $self->user_agent );

    my $req = HTTP::Request->new(
        POST => join( '/',$self->base_url . $self->api_path,'confirm' )
    );

    $req->header( 'Authorization' => "Basic $credentials" );
    $req->header( 'Accept' => 'application/json' );

    $req->content_type( 'application/x-www-form-urlencoded' );
    $req->content( $self->normalize_params( $data ) );

    my $res = $ua->request( $req );

    if ( $res->is_success ) {
        
        my $class_suffix = ucfirst( $params->{resource_type} );

t/business/gocardless.t  view on Meta::CPAN

);

cmp_deeply(
    $GoCardless->client_details,
    { api_version => 1 },
    'client_details'
);
isa_ok( $GoCardless->client,'Business::GoCardless::Client' );

# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $mock };

test_bill( $GoCardless,$mock );
test_merchant( $GoCardless,$mock );
test_payout( $GoCardless,$mock );

t/business/gocardless/paginator.t  view on Meta::CPAN

            'last' => 2,
            'next' => 2,
        },
        'pages' => 2,
        'records' => 15,
    },
    'info'
);

# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {
    my ( $self,$want ) = @_;
    return {
        'link'         => $link,
        'x-pagination' => '{"records":15,"pages":2,"links":{"next":2,"last":2}}}'
    }->{ lc( $want ) };

t/business/gocardless/pro.t  view on Meta::CPAN

);

cmp_deeply(
    $GoCardless->client_details,
    { api_version => 2 },
    'client_details'
);
isa_ok( $GoCardless->client,'Business::GoCardless::Client' );

# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $mock };

test_payment( $GoCardless,$mock );
test_payout( $GoCardless,$mock );
test_pre_authorization( $GoCardless,$mock );

t/business/gocardless/redirectflow.t  view on Meta::CPAN

ok( ! $RedirectFlow->cancelled,'cancelled' );
ok( ! $RedirectFlow->expired,'expired' );

throws_ok(
    sub { $RedirectFlow->cancel },
    'Business::GoCardless::Exception',
    "->cancel on a RedirectFlow is not meaningful in the Pro API",
);

# monkey patching LWP here to make this test work without
# having to actually hit the endpoints or use credentials
no warnings 'redefine';
no warnings 'once';
my $mock = Test::MockObject->new;
$mock->mock( 'is_success',sub { 1 } );
$mock->mock( 'header',sub {} );
*LWP::UserAgent::request = sub { $mock };
my $i = 0;
$mock->mock( 'content',sub { ! $i++ ? _redirect_flow_json() : _mandate_json() } );

is( $RedirectFlow->mandate->next_possible_charge_date,'2017-09-27','->mandate' );

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.045 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )