1 package FS::payinfo_transaction_Mixin;
7 use FS::Record qw(qsearchs);
9 use FS::payment_gateway;
11 @ISA = qw( FS::payinfo_Mixin );
15 FS::payinfo_transaction_Mixin - Mixin class for records in tables that represent transactions.
19 package FS::some_table;
21 @ISA = qw( FS::payinfo_transaction_Mixin FS::Record );
25 This is a mixin class for records that represent transactions: that contain
26 payinfo and realtime result fields (gatewaynum, processor, authorization,
27 order_number). Currently FS::cust_pay, FS::cust_refund, and FS::cust_pay_void.
35 Returns the parent customer object (see L<FS::cust_main>).
41 qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
46 Returns a name for the payby field.
52 if ( $self->payby eq 'BILL' ) { #kludge
55 FS::payby->shortname( $self->payby );
59 # We keep _parse_paybatch just because the upgrade needs it.
64 $self->paybatch =~ /^((\d+)\-)?(\w+):\s*([\w\-\/ ]*)(:([\w\-]+))?$/
66 #"Can't parse paybatch for paynum $options{'paynum'}: ".
67 # $cust_pay->paybatch;
69 my( $gatewaynum, $processor, $auth, $order_number ) = ( $2, $3, $4, $6 );
71 if ( $gatewaynum ) { #gateway for the payment to be refunded
74 qsearchs('payment_gateway', { 'gatewaynum' => $gatewaynum } );
76 $processor = $payment_gateway->gateway_module if $payment_gateway;
81 'gatewaynum' => $gatewaynum,
82 'processor' => $processor,
83 'authorization' => $auth,
84 'order_number' => $order_number,
89 # because we can't actually name the field 'authorization' (reserved word)
97 Checks the validity of the realtime payment fields (gatewaynum, processor,
98 auth, and order_number) as well as payby and payinfo
105 # All of these can be null, so in principle this could go in payinfo_Mixin.
107 $self->SUPER::payinfo_check()
108 || $self->ut_numbern('gatewaynum')
109 # not ut_foreign_keyn, it causes upgrades to fail
110 || $self->ut_alphan('processor')
111 || $self->ut_textn('auth')
112 || $self->ut_textn('order_number')