1 package Business::BatchPayment::Item;
5 use Moose::Util::TypeConstraints;
6 use MooseX::UndefTolerant;
11 Business::BatchPayment::Item
15 A Business::BatchPayment::Item represents a single payment request or
16 reply (approval or rejection). When submitting a batch, the merchant
17 system constructs B::BP::Item objects for each attempted payment in
18 the batch. Results downloaded from the gateway are returned as a
19 list of Items with the 'approved' field set to a true or false value.
21 =head1 REQUIRED ATTRIBUTES
27 "payment" or "credit". Most processors support only "payment".
28 "payment" is defined as "money transfer FROM the account identified in the
29 Item TO the account identified by the Processor object's login settings."
30 "credit" is the other direction.
34 enum 'Action' => qw(payment credit);
35 coerce 'Action', from 'Str', via { lc $_ };
46 "CC" or "ECHECK". Most processors will only support
47 one or the other, and if set on the BBP::Processor object, this is not
52 # are we okay with these names?
53 enum 'PaymentType' => qw( CC ECHECK );
54 has payment_type => ( is => 'rw', isa => 'PaymentType' );
58 the amount, as a decimal number. Required only in request
63 # perhaps we should apply roles that distinguish request and reply items?
64 # they have different required fields.
72 transaction identifier. Requests must provide this. It's a token of
73 some kind to be passed to the gateway and used to identify the reply.
74 For now it's required to be an integer. An invoice number would be
79 has tid => ( is => 'rw', isa => 'Int' );
83 =head1 OPTIONAL ATTRIBUTES
85 =head2 Customer Information
91 A customer number or other identifier, for the merchant's use.
105 =item address, address2, city, state, country, zip
107 Billing address fields. Credit card processors may use these (especially
108 zip) for authentication.
123 ) ] => ( is => 'rw', isa => 'Str', default => '' );
127 =head2 Transaction Information
133 The date requested for processing.
137 An invoice number, for your use.
141 class_type 'DateTime';
142 coerce 'DateTime', from 'Int', via { DateTime->from_epoch($_) };
143 has process_date => ( is => 'rw', isa => 'DateTime', coerce => 1 );
145 has invoice_number => ( is => 'rw', isa => 'Str' );
149 =head2 Bank Transfer / ACH / EFT
163 Can be 'personal checking', 'personal savings', 'business checking',
164 or 'business savings'.
168 enum 'Account_Type' => [
174 coerce 'Account_Type', from 'Str', via { lc $_ };
176 has account_number => ( is => 'rw', isa => 'Str' );
177 has routing_code => ( is => 'rw', isa => 'Str' );
178 has account_type => ( is => 'rw', isa => 'Account_Type', coerce => 1 );
192 Credit card expiration, MMYY format.
196 has card_number => ( is => 'rw', isa => 'Str' );
197 has expiration => ( is => 'rw', isa => 'Str' );
201 =head2 Tokenized Payment
207 If your gateway supports it, this may be
208 provided instead of card_number/account_number. See also
209 C<assigned_token> below.
213 has pay_by_token => ( is => 'rw', isa => 'Str' );
217 =head1 REPLY ATTRIBUTES
223 Boolean field for whether the item was approved. This
224 will always be set on replies.
228 The date the payment was processed, as a DateTime
233 The transaction identifier returned by the gateway
234 (not to be confused with 'tid', which is a transaction identifier assigned
235 by the merchant system). This is usually the identifier for performing
236 other operations on the transaction, like voiding or refunding it.
240 The authorization code, probably only meaningful for credit cards.
241 Should be undef (or not present) if the transaction wasn't approved.
245 In tokenized systems which store the customer's account number or
246 credit card for future transactions, this is the token assigned to
247 identify that account. Pass it as 'pay_by_token' to use that payment
252 The message returned by the gateway. This may contain a value even
253 if the payment was successful (use C<approved> to determine that.)
259 has approved => ( is => 'rw', isa => 'Maybe[Bool]' );
261 has payment_date => ( is => 'rw', isa => 'DateTime' );
268 )] => ( is => 'rw', isa => 'Str');
270 __PACKAGE__->meta->make_immutable;