Skip to content

remove unnecessary token object creation #172

@sherrardb

Description

@sherrardb

i discovered incidentally that methods that will accept a token id can be passed the test token id directly. so in cases where we are not later comparing other properties of the token:

stripe-perl/t/live.t

Lines 247 to 264 in 5ad870c

Charge_with_metadata: {
my $token = $stripe->get_token( token_id => $token_id_visa );
my $charge;
lives_ok {
$charge = $stripe->post_charge(
amount => 2500,
currency => 'usd',
card => $token->id,
description => 'Testing Metadata',
metadata => {'hasmetadata' => 'hello world'},
);
} 'Created a charge object with metadata';
isa_ok $charge, 'Net::Stripe::Charge';
ok defined($charge->metadata), "charge has metadata";
is $charge->metadata->{'hasmetadata'}, 'hello world', 'charge metadata';
my $charge2 = $stripe->get_charge(charge_id => $charge->id);
is $charge2->metadata->{'hasmetadata'}, 'hello world', 'charge metadata in retrieved object';
}

the token object creation can be bypassed, and $token_id_visa can be passed to post_charge(), et al.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions