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 one or the other,
47 and if set on the Processor object, this is not required.
51 # are we okay with these names?
52 enum 'PaymentType' => qw( CC ECHECK );
53 has payment_type => ( is => 'rw', isa => 'PaymentType' );
57 the amount, as a decimal number. Required only in request
62 # perhaps we should apply roles that distinguish request and reply items?
63 # they have different required fields.
71 transaction identifier. Requests must provide this. It's a token of
72 some kind to be passed to the gateway and used to identify the reply.
73 For now it's required to be an integer. An invoice number would be
78 has tid => ( is => 'rw', isa => 'Int' );
82 =head1 OPTIONAL ATTRIBUTES
84 =head2 Customer Information
90 A customer number or other identifier, for the merchant's use.
104 =item address, address2, city, state, country, zip
106 Billing address fields. Credit card processors may use these (especially
107 zip) for authentication.
122 ) ] => ( is => 'rw', isa => 'Str', default => '' );
126 =head2 Transaction Information
132 The date requested for processing.
136 An invoice number, for your use.
140 class_type 'DateTime';
141 coerce 'DateTime', from 'Int', via { DateTime->from_epoch($_) };
142 has process_date => ( is => 'rw', isa => 'DateTime', coerce => 1 );
144 has invoice_number => ( is => 'rw', isa => 'Str' );
148 =head2 Bank Transfer / ACH / EFT
162 Can be 'personal checking', 'personal savings', 'business checking',
163 or 'business savings'.
167 enum 'Account_Type' => [
173 coerce 'Account_Type', from 'Str', via { lc $_ };
175 has account_number => ( is => 'rw', isa => 'Str' );
176 has routing_code => ( is => 'rw', isa => 'Str' );
177 has account_type => ( is => 'rw', isa => 'Account_Type', coerce => 1 );
191 Credit card expiration, MMYY format.
195 has card_number => ( is => 'rw', isa => 'Str' );
196 has expiration => ( is => 'rw', isa => 'Str' );
200 =head2 Tokenized Payment
206 If your gateway supports it, this may be
207 provided instead of card_number/account_number. See also
208 C<assigned_token> below.
212 has pay_by_token => ( is => 'rw', isa => 'Str' );
216 =head1 REPLY ATTRIBUTES
222 Boolean field for whether the item was approved. This
223 will always be set on replies.
227 The date the payment was processed, as a DateTime
232 The transaction identifier returned by the gateway
233 (not to be confused with 'tid', which is a transaction identifier assigned
234 by the merchant system). This is usually the identifier for performing
235 other operations on the transaction, like voiding or refunding it.
239 The authorization code, probably only meaningful for credit cards.
240 Should be undef (or not present) if the transaction wasn't approved.
244 The check number, probably only meaningful if this transaction was
245 processed from a paper check.
249 In tokenized systems which store the customer's account number or
250 credit card for future transactions, this is the token assigned to
251 identify that account. Pass it as 'pay_by_token' to use that payment
256 The message returned by the gateway. This may contain a value even
257 if the payment was successful (use C<approved> to determine that.)
263 has approved => ( is => 'rw', isa => 'Maybe[Bool]' );
265 has payment_date => ( is => 'rw', isa => 'DateTime' );
272 )] => ( is => 'rw', isa => 'Str');
274 has check_number => ( is => 'rw', isa => 'Int' );
276 __PACKAGE__->meta->make_immutable;