Payment Information (See L<FS::payinfo_Mixin> for data format)
+=item paycardtype
+
+Detected credit card type, if appropriate; autodetected.
+
=item paymask
Masked payinfo (See L<FS::payinfo_Mixin> for how this works)
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- unless ($self->reasonnum) {
- my $result = $self->reason( $self->getfield('reason'),
- exists($options{ 'reason_type' })
- ? ('reason_type' => $options{ 'reason_type' })
- : (),
- );
- unless($result) {
+ if (!$self->reasonnum) {
+ my $reason_text = $self->get('reason')
+ or return "reason text or existing reason required";
+ my $reason_type = $options{'reason_type'}
+ or return "reason type required";
+
+ local $@;
+ my $reason = FS::reason->new_or_existing(
+ reason => $reason_text,
+ type => $reason_type,
+ class => 'F',
+ );
+ if ($@) {
$dbh->rollback if $oldAutoCommit;
- return "failed to set reason for $me"; #: ". $dbh->errstr;
+ return "failed to set refund reason: $@";
}
+ $self->set('reasonnum', $reason->reasonnum);
}
$self->setfield('reason', '');
sub replace {
my $self = shift;
- return "Can't modify closed refund" if $self->closed =~ /^Y/i;
+ return "Can't modify closed refund"
+ if $self->closed =~ /^Y/i && !$FS::payinfo_Mixin::allow_closed_replace;
$self->SUPER::replace(@_);
}
|| $self->ut_numbern('_date')
|| $self->ut_textn('paybatch')
|| $self->ut_enum('closed', [ '', 'Y' ])
+ || $self->ut_foreign_keyn('source_paynum', 'cust_pay', 'paynum')
;
return $error if $error;
my ($class, %opts) = @_;
$class->_upgrade_reasonnum(%opts);
$class->_upgrade_otaker(%opts);
+
+ local $ignore_empty_reasonnum = 1;
+ $class->upgrade_set_cardtype;
}
=back