arteman (arteman) wrote in changelog,
arteman
arteman
changelog

[ljcom] r12097: LJSV-2236 add date and username of purch...

Committer: azateev
LJSV-2236 add date and username of purchasing account to order confirmation emails
U   trunk/bin/maint/pay.pl
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
Modified: trunk/bin/maint/pay.pl
===================================================================
--- trunk/bin/maint/pay.pl	2012-06-09 11:22:44 UTC (rev 12096)
+++ trunk/bin/maint/pay.pl	2012-06-09 12:46:50 UTC (rev 12097)
@@ -39,16 +39,29 @@
     while (my $p = $sth->fetchrow_hashref)
     {
         my $pu = LJ::load_userid($p->{userid});
+        my $lang = $pu->prop('browselang') || $LJ::DEFAULT_LANG;
+        my $html = $pu->receives_html_emails;
+        my $datesent = LJ::TimeUtil->fancy_time_format(
+                            LJ::TimeUtil->mysqldate_to_time($p->{datesent}),
+                            'day'
+                       );
 
         my $note_msg = sub {
             return "" unless $p->{'notes'};
 
             # this will get run through Text::Wrap when it's emailed
-            my $notes = $p->{'notes'};
-            $notes =~ s/\n/\n   /g;
-
-            return "Here are some notes associated with this payment:\n\n" .
-                   "   $notes\n\n";
+            my $notes = LJ::Lang::get_text (
+                            $lang,
+                            'shop.notification.payment.recieved.note'
+                        ) .
+                        "\n\n" .
+                        $p->{'notes'};
+            if ($html) {
+                $notes =~ s/\n/<br \/>&nbsp;&nbsp;&nbsp;/g;
+            } else {
+                $notes =~ s/\n/\n   /g;
+            }
+            return $notes;
         };
 
         # recurring billing emails are not handled via the legacy
@@ -63,32 +76,78 @@
 
             my $pmt = LJ::Pay::Payment->load( payid   => $p->{'payid'},
                                               forwhat => $p->{'forwhat'} );
-                                              
+
             unless ($pmt->payvar_get('do_not_notify_sender')) {
 
                 my $cart = "$p->{'payid'}-$p->{'anum'}";
                 my $amt_show = $p->{'method'} eq 'wallet' ?
-                    sprintf( '%d tokens',
-                             $p->{'amount'} * LJ::Pay::Wallet::EXCHANGE_RATE ) :
+                    LJ::Lang::get_text (
+                        $lang,
+                        'shop.notification.payment.wallet.amt',
+                        undef,
+                        {
+                            amt => sprintf(
+                                     '%d',
+                                     $p->{'amount'} * LJ::Pay::Wallet::EXCHANGE_RATE
+                                   )
+                        }
+                    ) :
                     sprintf( '$%.2f', $p->{'amount'} );
 
-                LJ::send_mail({
-                    'to' => $pu->email_raw,
-                    'from' => $LJ::ACCOUNTS_EMAIL,
-                    'fromname' => $LJ::SITENAMESHORT,
-                    'wrap' => 1,
-                    'charset' => 'utf-8',
-                    'subject' => "Thanks, We've Received Your Payment",
-                    'body' => ("Your payment of $amt_show for order $cart was received and the order is now being processed.\n\n".
-                               "For your reference, you can view the order here:\n\n".
-                               "   $LJ::SITEROOT/pay/?c=$cart\n\n".
-                               $note_msg->() .
-                               "Thank you for supporting the site!\n\n".
-                               "--\n$LJ::SITENAMESHORT Team\n$LJ::SITEROOT"
-                               )});
+                my $subject = LJ::Lang::get_text (
+                                $lang,
+                                'shop.notification.payment.recieved.subject'
+                              );
+                my $body = LJ::Lang::get_text (
+                                $lang,
+                                'shop.notification.payment.received.body.plain',
+                                undef,
+                                {
+                                    username    => $pu->display_username,
+                                    amount      => $amt_show,
+                                    order       => $cart,
+                                    date        => $datesent,
+                                    admin_note  => $note_msg->(),
+                                    siteroot    => $LJ::SITEROOT,
+                                }
+                           );
+                if ($html) {
+                    my $html_body = LJ::Lang::get_text (
+                                        $lang,
+                                        'shop.notification.payment.received.body.html',
+                                        undef,
+                                        {
+                                            username    => $pu->ljuser_display,
+                                            amount      => $amt_show,
+                                            order       => $cart,
+                                            date        => $datesent,
+                                            admin_note  => $note_msg->(),
+                                            siteroot    => $LJ::SITEROOT,
+                                        }
+                                    );
+                    LJ::send_mail({
+                        to          => $pu->email_raw,
+                        from        => $LJ::ACCOUNTS_EMAIL,
+                        fromname    => $LJ::SITENAMESHORT,
+                        wrap        => 1,
+                        charset     => 'utf-8',
+                        subject     => $subject,
+                        body        => $body,
+                        html        => $html_body,
+                    });
+                } else {
+                    LJ::send_mail({
+                        to          => $pu->email_raw,
+                        from        => $LJ::ACCOUNTS_EMAIL,
+                        fromname    => $LJ::SITENAMESHORT,
+                        wrap        => 1,
+                        charset     => 'utf-8',
+                        subject     => $subject,
+                        body        => $body,
+                    });
+                }
+            }
 
-            }
-            
             $dbh->do("UPDATE payments SET mailed='Y' WHERE payid=$p->{'payid'}");
             next;
         }
@@ -732,7 +791,7 @@
 
         print "$u->{'user'}\n" if ($LJ::LJMAINT_VERBOSE == 2);
         # Send reminder email
-        LJ::send_mail({ 
+        LJ::send_mail({
                         'force_schwartz' => 1, ## slow outgoing connection may be a reason for 'MySQL server has gone away'.
                         'to' => $u->email_raw,
                         'from' => $LJ::ACCOUNTS_EMAIL,

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2012-06-09 11:22:44 UTC (rev 12096)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2012-06-09 12:46:50 UTC (rev 12097)
@@ -281,7 +281,7 @@
             if ($u->{opt_htmlemail} eq 'N' || !$html_body) {
                 LJ::send_mail({
                     to       => $u->email_raw,
-                    from     => $LJ::ACCOUNTS_EMAIL,,
+                    from     => $LJ::ACCOUNTS_EMAIL,
                     fromname => $LJ::SITENAMESHORT,
                     wrap     => 1,
                     charset  => $u->mailencoding || 'utf-8',

Tags: arteman, azateev, ljcom, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments