Skip to content

Commit 538578f

Browse files
committed
update statement_description to backwards-compatible statement_descriptor for Net::Stripe::Charge and Net::Stripe::Plan <https://stripe.com/docs/upgrades#2014-12-17>;
add failing test to detect previously-missing attribute in Net::Stripe::Charge;
1 parent b091f06 commit 538578f

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

lib/Net/Stripe.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ L<https://stripe.com/docs/api#create_charge>
114114
115115
=item * capture - Bool - optional
116116
117-
=item * statement_description - Str - description for statement - optional
117+
=item * statement_descriptor - Str - descriptor for statement - optional
118118
119119
=item * application_fee - Int - optional
120120
@@ -194,7 +194,7 @@ Charges: {
194194
Str :$description?,
195195
HashRef :$metadata?,
196196
Bool :$capture?,
197-
Str :$statement_description?,
197+
Str :$statement_descriptor?,
198198
Int :$application_fee?,
199199
Str :$receipt_email?
200200
) {
@@ -205,7 +205,7 @@ Charges: {
205205
description => $description,
206206
metadata => $metadata,
207207
capture => $capture,
208-
statement_description => $statement_description,
208+
statement_descriptor => $statement_descriptor,
209209
application_fee => $application_fee,
210210
receipt_email => $receipt_email
211211
);
@@ -818,7 +818,7 @@ L<https://stripe.com/docs/api#create_plan>
818818
819819
=item * trial_period_days - Int - optional
820820
821-
=item * statement_description - Str - optional
821+
=item * statement_descriptor - Str - optional
822822
823823
=back
824824
@@ -893,7 +893,7 @@ Plans: {
893893
Str :$name,
894894
Int :$trial_period_days?,
895895
HashRef :$metadata?,
896-
Str :$statement_description?) {
896+
Str :$statement_descriptor?) {
897897
my $plan = Net::Stripe::Plan->new(id => $id,
898898
amount => $amount,
899899
currency => $currency,
@@ -902,7 +902,7 @@ Plans: {
902902
name => $name,
903903
trial_period_days => $trial_period_days,
904904
metadata => $metadata,
905-
statement_description => $statement_description);
905+
statement_descriptor => $statement_descriptor);
906906
return $self->_post('plans', $plan);
907907
}
908908

lib/Net/Stripe/Charge.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ has 'invoice' => (is => 'ro', isa => 'Maybe[Str]');
2727
has 'receipt_email' => (is => 'ro', isa => 'Maybe[Str]');
2828
has 'status' => (is => 'ro', isa => 'Maybe[Str]');
2929
has 'capture' => (is => 'ro', isa => 'Bool', default=> 1);
30+
has 'statement_descriptor' => ('is' => 'ro', isa => 'Maybe[Str]');
3031

3132
method form_fields {
3233
return (
3334
$self->fields_for('card'),
3435
$self->form_fields_for_metadata(),
3536
map { $_ => $self->get_form_field_value( $_ ) }
3637
grep { defined $self->$_ }
37-
qw/amount currency customer description application_fee receipt_email capture/
38+
qw/amount currency customer description application_fee receipt_email capture
39+
statement_descriptor/
3840
);
3941
}
4042

lib/Net/Stripe/Plan.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ extends 'Net::Stripe::Resource';
77

88
# ABSTRACT: represent a Plan object from Stripe
99

10-
subtype 'StatementDescription',
10+
subtype 'StatementDescriptor',
1111
as 'Str',
1212
where { !defined($_) || $_ =~ /^[^<>"']{0,15}$/ },
13-
message { "The statement description you provided '$_' must be 15 characters or less and not contain <>\"'." };
13+
message { "The statement descriptor you provided '$_' must be 15 characters or less and not contain <>\"'." };
1414

1515
has 'id' => (is => 'ro', isa => 'Maybe[Str]', required => 1);
1616
has 'amount' => (is => 'ro', isa => 'Maybe[Int]', required => 1);
@@ -19,13 +19,13 @@ has 'interval' => (is => 'ro', isa => 'Maybe[Str]', required => 1);
1919
has 'interval_count' => (is => 'ro', isa => 'Maybe[Int]', required => 0);
2020
has 'name' => (is => 'ro', isa => 'Maybe[Str]', required => 1);
2121
has 'trial_period_days' => (is => 'ro', isa => 'Maybe[Int]');
22-
has 'statement_description' => ('is' => 'ro', isa => 'Maybe[StatementDescription]', required => 0);
22+
has 'statement_descriptor' => ('is' => 'ro', isa => 'Maybe[StatementDescriptor]', required => 0);
2323

2424
method form_fields {
2525
return (
2626
map { $_ => $self->$_ }
2727
grep { defined $self->$_ }
28-
qw/id amount currency interval interval_count name statement_description trial_period_days/
28+
qw/id amount currency interval interval_count name statement_descriptor trial_period_days/
2929
);
3030
}
3131

t/live.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ Plans: {
7878
interval => 'month',
7979
name => "Test Plan - $future",
8080
trial_period_days => 10,
81+
statement_descriptor => 'Statement Descr',
8182
);
8283
isa_ok $plan, 'Net::Stripe::Plan',
8384
'I love it when a plan comes together';
85+
is $plan->statement_descriptor, 'Statement Descr', 'plan statement_descriptor matches';
8486

8587
my $newplan = $stripe->get_plan(plan_id => $id);
8688
isa_ok $newplan, 'Net::Stripe::Plan',
@@ -154,17 +156,19 @@ Charges: {
154156
currency => 'usd',
155157
card => $fake_card,
156158
description => 'Wikileaks donation',
159+
statement_descriptor => 'Statement Descr',
157160
);
158161
} 'Created a charge object';
159162
isa_ok $charge, 'Net::Stripe::Charge';
160163
for my $field (qw/id amount created currency description
161-
livemode paid refunded status/) {
164+
livemode paid refunded status statement_descriptor/) {
162165
ok defined($charge->$field), "charge has $field";
163166
}
164167
ok !$charge->refunded, 'charge is not refunded';
165168
ok $charge->paid, 'charge was paid';
166169
is $charge->status, 'paid', 'charge status is paid';
167170
ok $charge->captured, 'charge was captured';
171+
is $charge->statement_descriptor, 'Statement Descr', 'charge statement_descriptor matches';
168172

169173
# Check out the returned card object
170174
my $card = $charge->card;

0 commit comments

Comments
 (0)