restore fallback to customer billing address for CC transactions, RT#77641, RT#71513
authorIvan Kohler <ivan@freeside.biz>
Wed, 13 Feb 2019 18:02:47 +0000 (10:02 -0800)
committerIvan Kohler <ivan@freeside.biz>
Wed, 13 Feb 2019 18:02:47 +0000 (10:02 -0800)
FS/FS/cust_main/Billing_Realtime.pm

index b29408b..4ff2c06 100644 (file)
@@ -361,14 +361,23 @@ sub _bop_content {
 
   $content{name} = $payname if $payname;
 
 
   $content{name} = $payname if $payname;
 
-  $content{address} = $options->{'address1'};
-  my $address2 = $options->{'address2'};
-  $content{address} .= ", ". $address2 if length($address2);
-
-  $content{city} = $options->{'city'};
-  $content{state} = $options->{'state'};
-  $content{zip} = $options->{'zip'};
-  $content{country} = $options->{'country'};
+  if ( exists($options->{'address1'}) ) {
+
+    $content{address} = $options->{'address1'};
+    my $address2 = $options->{'address2'};
+    $content{address} .= ", ". $address2 if length($address2);
+
+    $content{$_} = $options->{$_} foreach qw( city state zip country );
+
+  } elsif ( ref($self) ) {
+
+    $content{address} = $self->address1;
+    my $address2 = $self->address2;
+    $content{address} .= ", ". $address2 if length($address2);
+
+    $content{$_} = $self->$_() foreach qw( city state zip country );
+
+  }
 
   # can't set phone if called as class method
   $content{phone} = $self->daytime || $self->night
 
   # can't set phone if called as class method
   $content{phone} = $self->daytime || $self->night