I want to send an email using yii2 mailer. I have configured the mailer and already tried to send a single record in a single email. Now I want to send multiple records but in a single email.
Below is my action controller
$sql = "SELECT COUNT(DISTINCT od.`meter_serial`) AS 'OGP Created',
COUNT(DISTINCT mp.`meter_id`) AS 'Installed & Un-Verified Meters',
COUNT(DISTINCT ins.`meter_msn`) AS 'Installed & Verified',
sd.`sub_div_code` AS 'SD Code',sd.`name` AS 'SD-Name'
FROM `ogp_detail` od
INNER JOIN `survey_hesco_subdivision` sd ON od.`sub_div` =
sd.`sub_div_code`
LEFT JOIN `meter_ping` mp ON od.`meter_id` = mp.`meter_id`
LEFT JOIN `installations` ins ON od.`meter_serial` = ins.`meter_msn`
WHERE od.`meter_type` = '3-Phase'
GROUP BY sd.`name`";
$result = Yii::$app->db->createCommand($sql)->queryAll();
print_r($result);
exit();
The output is
Array ( [0] => Array ( [OGP Created] => 7 [Installed & Un-Verified Meters] => 2 [Installed & Verified] => 4 [SD Code] => 37153 [SD-Name] => ALLAMA IQBAL ) [1] => Array ( [OGP Created] => 68 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 0 [SD Code] => 37281 [SD-Name] => BADIN ) [2] => Array ( [OGP Created] => 13 [Installed & Un-Verified Meters] => 6 [Installed & Verified] => 0 [SD Code] => 37336 [SD-Name] => BHIT SHAH ) [3] => Array ( [OGP Created] => 6 [Installed & Un-Verified Meters] => 2 [Installed & Verified] => 0 [SD Code] => 37254 [SD-Name] => BULRISHAH KARIM ) [4] => Array ( [OGP Created] => 26 [Installed & Un-Verified Meters] => 18 [Installed & Verified] => 0 [SD Code] => 37144 [SD-Name] => CHAMBER ) [5] => Array ( [OGP Created] => 13 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 6 [SD Code] => 37182 [SD-Name] => CITIZEN COLONY ) [6] => Array ( [OGP Created] => 117 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37314 [SD-Name] => DAUR ) [7] => Array ( [OGP Created] => 78 [Installed & Un-Verified Meters] => 26 [Installed & Verified] => 2 [SD Code] => 37421 [SD-Name] => DIGRI ) [8] => Array ( [OGP Created] => 15 [Installed & Un-Verified Meters] => 1 [Installed & Verified] => 7 [SD Code] => 37112 [SD-Name] => GARI KHATA ) [9] => Array ( [OGP Created] => 24 [Installed & Un-Verified Meters] => 10 [Installed & Verified] => 0 [SD Code] => 37283 [SD-Name] => GOLARCHI ) [10] => Array ( [OGP Created] => 7 [Installed & Un-Verified Meters] => 4 [Installed & Verified] => 0 [SD Code] => 37335 [SD-Name] => HALA ) [11] => Array ( [OGP Created] => 4 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 3 [SD Code] => 37151 [SD-Name] => HALI ROAD ) [12] => Array ( [OGP Created] => 21 [Installed & Un-Verified Meters] => 8 [Installed & Verified] => 1 [SD Code] => 37183 [SD-Name] => HIRABAD ) [13] => Array ( [OGP Created] => 85 [Installed & Un-Verified Meters] => 9 [Installed & Verified] => 0 [SD Code] => 37413 [SD-Name] => HIRABAD MPK ) [14] => Array ( [OGP Created] => 112 [Installed & Un-Verified Meters] => 28 [Installed & Verified] => 49 [SD Code] => 37111 [SD-Name] => HYD SADDAR ) [15] => Array ( [OGP Created] => 10 [Installed & Un-Verified Meters] => 10 [Installed & Verified] => 0 [SD Code] => 37243 [SD-Name] => ILYASABAD ) [16] => Array ( [OGP Created] => 70 [Installed & Un-Verified Meters] => 37 [Installed & Verified] => 6 [SD Code] => 37222 [SD-Name] => JAMSHORO ) [17] => Array ( [OGP Created] => 123 [Installed & Un-Verified Meters] => 28 [Installed & Verified] => 0 [SD Code] => 37342 [SD-Name] => JHOLE ) [18] => Array ( [OGP Created] => 16 [Installed & Un-Verified Meters] => 9 [Installed & Verified] => 0 [SD Code] => 37422 [SD-Name] => JHUDO ) [19] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 20 [Installed & Verified] => 0 [SD Code] => 37345 [SD-Name] => KHIPRO ) [20] => Array ( [OGP Created] => 38 [Installed & Un-Verified Meters] => 6 [Installed & Verified] => 10 [SD Code] => 37221 [SD-Name] => KOTRI ) [21] => Array ( [OGP Created] => 18 [Installed & Un-Verified Meters] => 13 [Installed & Verified] => 0 [SD Code] => 37434 [SD-Name] => KUNRI ) [22] => Array ( [OGP Created] => 9 [Installed & Un-Verified Meters] => 1 [Installed & Verified] => 6 [SD Code] => 37115 [SD-Name] => LIAQAT COLONY ) [23] => Array ( [OGP Created] => 45 [Installed & Un-Verified Meters] => 19 [Installed & Verified] => 0 [SD Code] => 37273 [SD-Name] => MAKLI ) [24] => Array ( [OGP Created] => 49 [Installed & Un-Verified Meters] => 4 [Installed & Verified] => 0 [SD Code] => 37334 [SD-Name] => MATIARI ) [25] => Array ( [OGP Created] => 27 [Installed & Un-Verified Meters] => 7 [Installed & Verified] => 0 [SD Code] => 37253 [SD-Name] => MATLI ) [26] => Array ( [OGP Created] => 5 [Installed & Un-Verified Meters] => 1 [Installed & Verified] => 0 [SD Code] => 37244 [SD-Name] => MEMON HOSPITAL ) [27] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 11 [Installed & Verified] => 0 [SD Code] => 37411 [SD-Name] => MIPURKHAS CITY ) [28] => Array ( [OGP Created] => 26 [Installed & Un-Verified Meters] => 12 [Installed & Verified] => 6 [SD Code] => 37155 [SD-Name] => MIRAN M.SHAH ) [29] => Array ( [OGP Created] => 64 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 0 [SD Code] => 37414 [SD-Name] => MIRWAH ) [30] => Array ( [OGP Created] => 84 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 0 [SD Code] => 37424 [SD-Name] => MITHI ) [31] => Array ( [OGP Created] => 11 [Installed & Un-Verified Meters] => 6 [Installed & Verified] => 0 [SD Code] => 37423 [SD-Name] => NAUKOT ) [32] => Array ( [OGP Created] => 59 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 6 [SD Code] => 37311 [SD-Name] => NAWAB SHAH-I ) [33] => Array ( [OGP Created] => 26 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37312 [SD-Name] => NAWAB SHAH-II ) [34] => Array ( [OGP Created] => 43 [Installed & Un-Verified Meters] => 13 [Installed & Verified] => 0 [SD Code] => 37225 [SD-Name] => NOORIABAD ) [35] => Array ( [OGP Created] => 14 [Installed & Un-Verified Meters] => 9 [Installed & Verified] => 0 [SD Code] => 37333 [SD-Name] => ODERO LAL ) [36] => Array ( [OGP Created] => 3 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37241 [SD-Name] => PARETABAD ) [37] => Array ( [OGP Created] => 9 [Installed & Un-Verified Meters] => 5 [Installed & Verified] => 0 [SD Code] => 37432 [SD-Name] => PITHORO ) [38] => Array ( [OGP Created] => 27 [Installed & Un-Verified Meters] => 3 [Installed & Verified] => 15 [SD Code] => 37181 [SD-Name] => QASIMABAD ) [39] => Array ( [OGP Created] => 66 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37318 [SD-Name] => QAZI AHMED ) [40] => Array ( [OGP Created] => 5 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37152 [SD-Name] => RIZVI HOSPITAL ) [41] => Array ( [OGP Created] => 189 [Installed & Un-Verified Meters] => 22 [Installed & Verified] => 0 [SD Code] => 37316 [SD-Name] => SAEEDABAD ) [42] => Array ( [OGP Created] => 130 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37315 [SD-Name] => SAKRAND ) [43] => Array ( [OGP Created] => 21 [Installed & Un-Verified Meters] => 7 [Installed & Verified] => 0 [SD Code] => 37433 [SD-Name] => SAMARO ) [44] => Array ( [OGP Created] => 172 [Installed & Un-Verified Meters] => 117 [Installed & Verified] => 0 [SD Code] => 37341 [SD-Name] => SANGHAR ) [45] => Array ( [OGP Created] => 21 [Installed & Un-Verified Meters] => 2 [Installed & Verified] => 13 [SD Code] => 37113 [SD-Name] => SARFARAZ COLONY ) [46] => Array ( [OGP Created] => 55 [Installed & Un-Verified Meters] => 13 [Installed & Verified] => 0 [SD Code] => 37412 [SD-Name] => SATELLITE TOWN ) [47] => Array ( [OGP Created] => 94 [Installed & Un-Verified Meters] => 8 [Installed & Verified] => 2 [SD Code] => 37226 [SD-Name] => SEHWAN SHARIF ) [48] => Array ( [OGP Created] => 18 [Installed & Un-Verified Meters] => 2 [Installed & Verified] => 13 [SD Code] => 37154 [SD-Name] => SH:UMAID ALI KHAN ) [49] => Array ( [OGP Created] => 16 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 1 [SD Code] => 37223 [SD-Name] => SHAHBAZ ) [50] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 20 [Installed & Verified] => 0 [SD Code] => 37343 [SD-Name] => SHAHDAD PUR-I ) [51] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 20 [Installed & Verified] => 0 [SD Code] => 37344 [SD-Name] => SHAHDAD PUR-II ) [52] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 20 [Installed & Verified] => 0 [SD Code] => 37346 [SD-Name] => SHAHPUR CHAKAR ) [53] => Array ( [OGP Created] => 20 [Installed & Un-Verified Meters] => 20 [Installed & Verified] => 0 [SD Code] => 37347 [SD-Name] => SINDHRI ) [54] => Array ( [OGP Created] => 111 [Installed & Un-Verified Meters] => 0 [Installed & Verified] => 0 [SD Code] => 37313 [SD-Name] => SOCIETY ) [55] => Array ( [OGP Created] => 37 [Installed & Un-Verified Meters] => 5 [Installed & Verified] => 0 [SD Code] => 37272 [SD-Name] => SUJAWAL ) [56] => Array ( [OGP Created] => 24 [Installed & Un-Verified Meters] => 4 [Installed & Verified] => 0 [SD Code] => 37251 [SD-Name] => T.MUHAMMAD KHAN-I ) [57] => Array ( [OGP Created] => 8 [Installed & Un-Verified Meters] => 5 [Installed & Verified] => 0 [SD Code] => 37252 [SD-Name] => T.MUHAMMAD KHAN-II ) [58] => Array ( [OGP Created] => 36 [Installed & Un-Verified Meters] => 11 [Installed & Verified] => 0 [SD Code] => 37282 [SD-Name] => TALHAR ) [59] => Array ( [OGP Created] => 4 [Installed & Un-Verified Meters] => 1 [Installed & Verified] => 0 [SD Code] => 37331 [SD-Name] => TANDO ADAM-I ) [60] => Array ( [OGP Created] => 18 [Installed & Un-Verified Meters] => 12 [Installed & Verified] => 0 [SD Code] => 37332 [SD-Name] => TANDO ADAM-II ) [61] => Array ( [OGP Created] => 97 [Installed & Un-Verified Meters] => 31 [Installed & Verified] => 20 [SD Code] => 37141 [SD-Name] => TANDO ALLAH YAR-I ) [62] => Array ( [OGP Created] => 82 [Installed & Un-Verified Meters] => 1 [Installed & Verified] => 11 [SD Code] => 37142 [SD-Name] => TANDO ALLAH YAR-II ) [63] => Array ( [OGP Created] => 22 [Installed & Un-Verified Meters] => 2 [Installed & Verified] => 0 [SD Code] => 37143 [SD-Name] => TANDO JAM ) [64] => Array ( [OGP Created] => 47 [Installed & Un-Verified Meters] => 27 [Installed & Verified] => 0 [SD Code] => 37271 [SD-Name] => THATTA ) [65] => Array ( [OGP Created] => 48 [Installed & Un-Verified Meters] => 19 [Installed & Verified] => 0 [SD Code] => 37431 [SD-Name] => UMERKOT ) )
As in above result, there are multiple records I want to send them in a single email.
I also want to add up the OGP Created,'Installed & Un-Verified Meters' and 'Installed & Verified' count values i.e. sum them in a separate variable
Update 1
As per suggestion was given a csv attachment would work. But there is something more I want to add. As I have said above that I want to sum up the count values of all the first three columns. So I have tried to add them like this
foreach ($result as $set)
{
$sum_OGP +=$set['OGP_Created'];
$sum_UnVerified +=$set['Installed _& _Un_Verified_Meters'];
$sum_Verified +=$set['Installed_& _Verified_Meters'];
}
echo "Total OGP ";
print_r($sum_OGP);
echo "<br>";
echo "<br>";
echo "Total Un-Verified Meters ";
print_r($sum_UnVerified);
echo "<br>";
echo "<br>";
echo "Total Verified Meters ";
print_r($sum_Verified);
exit();
And the output is
Total OGP 2813
Total Un-Verified Meters 712
Total Verified Meters 181
The sum is correct but how can I send it in the attachment?
Any help would be highly appreciated.
If you want to send the output of the query into an email then you should go for creating a csv file and sending as an attachment via email.
public function test() {
$sql = "SELECT COUNT(DISTINCT od.`meter_serial`) AS 'OGP Created',
COUNT(DISTINCT mp.`meter_id`) AS 'Installed & Un-Verified Meters',
COUNT(DISTINCT ins.`meter_msn`) AS 'Installed & Verified',
sd.`sub_div_code` AS 'SD Code',sd.`name` AS 'SD-Name'
FROM `ogp_detail` od
INNER JOIN `survey_hesco_subdivision` sd ON od.`sub_div` =
sd.`sub_div_code`
LEFT JOIN `meter_ping` mp ON od.`meter_id` = mp.`meter_id`
LEFT JOIN `installations` ins ON od.`meter_serial` = ins.`meter_msn`
WHERE od.`meter_type` = '3-Phase'
GROUP BY sd.`name`";
$results = Yii::$app->db->createCommand($sql)->queryAll();
//create a csv file
$filename = $this->getAttachment($results);
//send email
$this->sendEmail('omer#omer.com',$filename);
}
/**
*
* #param type $email
* #param type $filename
* #return type
*/
public function sendEmail($email,$filename)
{
return Yii::$app->mailer->compose()
->setTo($email)
->setFrom(['admin#domain.com' => 'Admin'])
->setSubject('Some Subject for the email')
->setTextBody('Text body of the email ')
->attach($filename,['filename'=>'information','contentType'=>'text/csv'])
->send();
}
/**
*
* #param type $results
* #return string $filename
*/
public function getAttachment($results) {
$filename = Yii::getAlias('#webroot') . DIRECTORY_SEPARATOR . 'my-attachment-' . time() . '.csv';
//open a csv file
$file = fopen($filename, "w");
$headerInjected = false;
$header = ['OGP Created', 'Installed & Un-Verified Meters', 'Installed & Verified', 'SD Code', 'SD-Name'];
//write lines to the csv file
foreach ($results as $result) {
if (!$headerInjected) {
$headerInjected = true;
fputcsv($file, $header);
}
fputcsv($file, $result);
$sum_OGP +=$result['OGP_Created'];
$sum_UnVerified +=$result['Installed_&_Un_Verified_Meters'];
$sum_Verified +=$result['Installed_&_Verified_Meters'];
}
//add the sum in the last row
fputcsv($file,[$sum_OGP,$sum_UnVerified,$sum_Verified]);
//close the file handle
fclose($file);
return $filename;
}
Related
I am using the Symfony\Component\Form\Extension\Core\Type\DateTimeType;
I want my time field to show hours and minutes in the same drop down select like this:
00:00
00:30
01:00
01:30
02.00
02:30
03:00
03:30
Any help?
Hy, if you just want have the minutes to 00 or 30 you can do in your buildForm :
->add('myDate', DateTimeType::class, array(
'widget' => 'choice',
'minutes' => array(
0,
30
),
'with_seconds' => false
))
I've signed for my own subscription, and I've got these messages with from paypal. I displayed txn_type and subscr_date.
| txn_type | subscr_date |
| subscr_payment | NULL |
| subscr_signup | 05:04:37 May 15, 2017 PDT |
| subscr_cancel | 05:05:57 May 15, 2017 PDT |
Messages of txn_type subsrc_payment only have subscr_id and nothing else.
I am interested in what messages will be send when recurring payment gets executed next month, next year...
I suspect there will be just
| txn_type | subscr_date | subscr_id
| subscr_payment | NULL | SOME ID HERE
Can anyone what kind of txn_type will be sent over? I am having a hard time simulating this process.
When a payment happens then the subscr_payment is the IPN type you would get. Not sure why you're saying you are only seeing minimal parameters. Here is a sample of a subscr_payment IPN:
Array
(
[mc_gross] => 5.00
[protection_eligibility] => Eligible
[address_status] => unconfirmed
[payer_id] => 8FXTJQD6PGD5N
[address_street] => 123 Test Ave.
[payment_date] => 22:30:42 Jan 04, 2017 PST
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => 11000
[first_name] => Tester
[mc_fee] => 0.50
[address_country_code] => MA
[address_name] => HAMMA Omar
[notify_version] => 3.8
[subscr_id] => I-WCECH3SA87PT
[payer_status] => unverified
[business] => receiver#email.com
[address_country] => Morocco
[address_city] => Rabat
[verify_sign] => A3Y1IabViDnLM.hMAUvK-kr83JP5AaoMlP3UYuHFIfHdL4P5lBuXYBoQ
[payer_email] => payer#email.com
[txn_id] => 0RF86855U2529745U
[payment_type] => instant
[payer_business_name] => Testerson Tester
[last_name] => Testerson
[address_state] => Rabat
[receiver_email] => receiver#email.com
[payment_fee] => 0.50
[receiver_id] => G3LWKY98MHFFC
[txn_type] => subscr_payment
[item_name] => Times News
[mc_currency] => USD
[residence_country] => MA
[test_ipn] => 1
[transaction_subject] => Times News
[payment_gross] => 5.00
[ipn_track_id] => d95263f949f25
[ipn_url_name] => AE Sandbox
)
Consider following record
Id F1 F2 f3 Date
-------------------------------------------------
1 1800 1990 19 2016-06-27 09:24:25.550
2 1181 1991 19 2016-06-27 09:25:15.243
3 1919 2000 19 2016-06-27 11:04:27.807
4 1920 2000 19 2016-06-27 13:04:27.807
5 1800 2001 19 2016-06-28 09:24:25.550
6 1181 2002 19 2016-06-28 09:25:15.243
7 1919 2010 19 2016-06-28 11:04:27.807
I want to Groupby f1 sorted by Date descending
Desirder Output
Id F1 F2 f3 Date
-------------------------------------------------
7 1919 2010 19 2016-06-28 11:04:27.807
6 1181 2002 19 2016-06-28 09:25:15.243
5 1800 2001 19 2016-06-28 09:24:25.550
4 1920 2000 19 2016-06-27 13:04:27.807
I have Tried with
DateTime EndDate=DateTime.Now.AddDays(-1);
var result = (from opt in db.Output
where opt.f3==19 && opt.Date > EndDate
orderby opt.Date descending
select new
{
Id= opt.Id,
F1=opt.F1,
F2=opt.F2,
F3=opt.F3,
Date=opt.Date
}).GroupBy(x => x.F1).Select(s => s.OrderBy(o => o.F2).FirstOrDefault()).OrderByDescending(x => x.Date).ToList();
Im getting Output as
Id F1 F2 f3 Date
-------------------------------------------------
1 1800 1990 19 2016-06-27 09:24:25.550
2 1181 1991 19 2016-06-27 09:25:15.243
3 1919 2000 19 2016-06-27 11:04:27.807
4 1920 2000 19 2016-06-27 13:04:27.807
What is wrong with my code.
If I understand correctly you want the most recent item of each group:
db.Output.GroupBy(opt => opt.F1).
Select(group => group.OrderByDescending(opt => opt.Date).First()).
OrderBy(opt => opt.ID);
I'm not sure the translation to SQL with be efficient though due to the inner ordering.
Now since GroupBy preserves order, you might fix this issue with:
db.Output.OrderByDescending(opt => opt.Date).
GroupBy(opt => opt.F1).
Select(group => group.First().
OrderBy(opt => opt.ID);
The problem is in s.OrderBy(o => o.F2).FirstOrDefault(). Here ordering should be on Date.
Why your code doesn't work :
//creates group
.GroupBy(x => x.F1)
//Order by F1 and take first - *Here the record with latest date is eliminated
.Select(s => s.OrderBy(o => o.F2).FirstOrDefault())
//This order by desc is of no use as we already have only 1 rec from each group
.OrderByDescending(x => x.Date).ToList();
var result = db.Output
.Where(opt => opt.f3==19 && opt.Date > EndDate)
.OrderByDescending(o => o.Date)
.GroupBy(x => x.F1)
.Select(s => s.FirstOrDefault())
.ToList();
or
var result = db.Output
.Where(opt => opt.f3==19 && opt.Date > EndDate)
.OrderBy(o1=>o1.F2)
.ThenByDescending(o => o.Date)
.GroupBy(x => x.F1)
.Select(s => s.FirstOrDefault())
.ToList();
Use Multiple column Group
DateTime EndDate=DateTime.Now.AddDays(-1);
var result = (from opt in db.Output
where opt.f3==19 && opt.Date > EndDate
orderby opt.Date descending
select new
{
Id= opt.Id,
F1=opt.F1,
F2=opt.F2,
F3=opt.F3,
Date=opt.Date
}).GroupBy(x => new{x.Date, x.F1}).Select(s => s.OrderBy(o => o.F2).FirstOrDefault()).OrderByDescending(x => x.Date).ToList();
I set up an IPN inside Paypal to hit every time a Recurring Payment using Payflow Pro is set to go through. How can I make it send back the variable for the custom ID I need to make sure that I can use to extend the membership?
So far I have tried ProfileID, payer_business_name, option_name1, rp_invoice_id, invoice, and custom, none are sent back when it goes through.
The custom variable should certainly work, if it was included in the POST. Alternatively you can add any variable name=value pair you like to the notify_url, as long as they don't conflict with PayPal's IPN variables.
rp_invoice_id is returned in both recurring_payments_profile_created and regular recurring_payment IPN's. Here's a sample of both.
Array
(
[payment_cycle] => Monthly
[txn_type] => recurring_payment_profile_created
[last_name] => Parr
[next_payment_date] => 02:00:00 Jan 02, 2014 PST
[residence_country] => US
[initial_payment_amount] => 0.00
[rp_invoice_id] => 5416
[currency_code] => USD
[time_created] => 11:40:24 Jan 02, 2014 PST
[verify_sign] => A0AUpo6gn8Mp.jtr-HUe-oSqCFb6A0LWR7wKLHmMMUUwszTktyPfL8DU
[period_type] => Regular
[payer_status] => verified
[tax] => 0.00
[payer_email] => blahblah#aol.com
[first_name] => Don
[receiver_email] => blahblah#usbswiper.com
[payer_id] => F5T99998MN
[product_type] => 1
[payer_business_name] => Testers, LLC
[shipping] => 0.00
[amount_per_cycle] => 1.95
[profile_status] => Active
[charset] => windows-1252
[notify_version] => 3.7
[amount] => 1.95
[outstanding_balance] => 0.00
[recurring_payment_id] => I-WK69LR0DU8DU
[product_name] => USBSwiper Monthly Subscription
[ipn_track_id] => 6ddc294dddb3f
)
Array
(
[mc_gross] => 1.95
[period_type] => Regular
[outstanding_balance] => 0.00
[next_payment_date] => 02:00:00 Feb 02, 2014 PST
[protection_eligibility] => Ineligible
[payment_cycle] => Monthly
[address_status] => confirmed
[tax] => 0.00
[payer_id] => F59999MN
[address_street] => 96 east granada drive
[payment_date] => 11:41:08 Jan 02, 2014 PST
[payment_status] => Completed
[product_name] => USBSwiper Monthly Subscription
[charset] => windows-1252
[rp_invoice_id] => 5416
[recurring_payment_id] => I-WK69LR0DU8DU
[address_zip] => 08723
[first_name] => Blah
[mc_fee] => 0.34
[address_country_code] => US
[address_name] => Testers, LLC
[notify_version] => 3.7
[amount_per_cycle] => 1.95
[payer_status] => verified
[currency_code] => USD
[business] => blah#usbswiper.com
[address_country] => United States
[address_city] => brick
[verify_sign] => AoumLIHoQx0AdOelHJVEVpKjHTDiArY--xdOStWxP3msX12oC3zHxpWw
[payer_email] => blahblah#aol.com
[initial_payment_amount] => 0.00
[profile_status] => Active
[amount] => 1.95
[txn_id] => 5DL77590UR008354X
[payment_type] => instant
[payer_business_name] => Testers, LLC
[last_name] => Blah
[address_state] => NJ
[receiver_email] => blahblah#usbswiper.com
[payment_fee] => 0.34
[receiver_id] => M5VRAQYEFCSK6
[txn_type] => recurring_payment
[mc_currency] => USD
[residence_country] => US
[transaction_subject] => USBSwiper Monthly Subscription
[payment_gross] => 1.95
[shipping] => 0.00
[product_type] => 1
[time_created] => 11:40:24 Jan 02, 2014 PST
[ipn_track_id] => 8e2c922895e5c
)
If you're not getting rp_invoice_id in your IPN's then it must not be getting included in your API request correctly.
I am implementing Recurring Payment API with Paypal Pro. My question is when a payment fails, and i receive an IPN, what will be its txn_type? And what all IPN's i'll be expecting? so that i can take care of then in my IPNhandler class.
Possible txn_type's you can get when using Recurring Payments consist of:
recurring_payment_profile_created
recurring_payment_profile_cancel
recurring_payment_profile_modify
recurring_payment
recurring_payment_skipped
recurring_payment_failed
recurring_payment_suspended_due_to_max_failed_payment
In most cases when a payment fails you'll get the skipped notification. I very rarely see an actual failed notification. I've never gotten any answers as to why that is.
Here are some samples.
Array
(
[payment_cycle] => Monthly
[txn_type] => recurring_payment_skipped
[last_name] => Testerson
[next_payment_date] => 03:00:00 Oct 24, 2012 PDT
[residence_country] => US
[initial_payment_amount] => 0.00
[rp_invoice_id] => 3250
[currency_code] => USD
[time_created] => 15:42:49 Sep 19, 2012 PDT
[verify_sign] => AH1WkYze3JQ1xNtDm31SsDJxLeGrAxPpeVKBrMHLFmRVOWXnZep95xOm
[period_type] => Regular
[payer_status] => unverified
[test_ipn] => 1
[tax] => 0.00
[payer_email] => test#hey.com
[first_name] => Tester
[receiver_email] => usb_1329725429_biz#angelleye.com
[payer_id] => TP7CXHP6TVNSS
[product_type] => 1
[shipping] => 0.00
[amount_per_cycle] => 1.95
[profile_status] => Active
[charset] => windows-1252
[notify_version] => 3.7
[amount] => 1.95
[outstanding_balance] => 0.00
[recurring_payment_id] => I-0SAH6FDN3JJA
[product_name] => USBSwiper Monthly Subscription
[ipn_track_id] => f2380796ce7c
)
Array
(
[payment_cycle] => Monthly
[txn_type] => recurring_payment_failed
[last_name] => Garcia
[next_payment_date] => 02:00:00 Feb 12, 2012 PST
[residence_country] => US
[initial_payment_amount] => 0.00
[rp_invoice_id] => 939
[currency_code] => USD
[time_created] => 16:29:33 Jan 29, 2010 PST
[verify_sign] => A5rGTRcXhg6p48uIMYaPQKo7dsKqAO89FRXvCmuAfV5EYGWkAAD0vbPc
[period_type] => Regular
[payer_status] => unverified
[tax] => 0.00
[payer_email] => testpayer#hey.com
[first_name] => Maria
[receiver_email] => testreceiver#hey.com
[payer_id] => EJ8JBQ63VHECL
[product_type] => 1
[shipping] => 0.00
[amount_per_cycle] => 4.95
[profile_status] => Active
[charset] => windows-1252
[notify_version] => 3.4
[amount] => 4.95
[outstanding_balance] => 14.85
[recurring_payment_id] => I-S3APFHH0KFJ2
[product_name] => USBSwiper Monthly Subscription
[ipn_track_id] => Gi2zp.DfhsYitm8Kd0Dn3g
)
Array
(
[payment_cycle] => Monthly
[txn_type] => recurring_payment_suspended_due_to_max_failed_payment
[last_name] => Nom_3
[next_payment_date] => N/A
[residence_country] => CA
[initial_payment_amount] => 0.00
[rp_invoice_id] => 3245
[currency_code] => USD
[time_created] => 10:53:25 Mar 14, 2012 PDT
[verify_sign] => AptDZCkTZINE6OhArrkjyIYauY8GAGO.XoBdyMW5t7SoHPSC8DOFS9kB
[period_type] => Regular
[payer_status] => unverified
[test_ipn] => 1
[tax] => 0.00
[payer_email] => sandbox#hey.com
[first_name] => Prenom_3
[receiver_email] => usb_1329725429_biz#angelleye.com
[payer_id] => TP7CXHP6TVNSS
[product_type] => 1
[shipping] => 0.00
[amount_per_cycle] => 1.95
[profile_status] => Suspended
[charset] => windows-1252
[notify_version] => 3.4
[amount] => 1.95
[outstanding_balance] => 1.95
[recurring_payment_id] => I-CEBHH0K0V7T1
[product_name] => USBSwiper Monthly Subscription
[ipn_track_id] => d09d07fdd833
)
Array
(
[mc_gross] => 1.95
[period_type] => Regular
[outstanding_balance] => 0.00
[next_payment_date] => 03:00:00 Aug 18, 2013 PDT
[protection_eligibility] => Ineligible
[payment_cycle] => Monthly
[address_status] => confirmed
[tax] => 0.00
[payer_id] => E7BTGVXBFSUAU
[address_street] => 1 Main St
[payment_date] => 05:00:34 Jul 18, 2013 PDT
[payment_status] => Completed
[product_name] => USBSwiper Monthly Subscription
[charset] => windows-1252
[rp_invoice_id] => 3275
[recurring_payment_id] => I-R0KGNCTUYAVW
[address_zip] => 95131
[first_name] => Drew
[mc_fee] => 0.15
[address_country_code] => US
[address_name] => Drew Angell's Test Store
[notify_version] => 3.7
[amount_per_cycle] => 1.95
[payer_status] => verified
[currency_code] => USD
[business] => usb_1329725429_biz#angelleye.com
[address_country] => United States
[address_city] => San Jose
[verify_sign] => AOX9jItnq2qBtXeyCB5nhWVdWyqEAScu5FToCodROuhjlKYjtDeAdlmL
[payer_email] => sandbo_1204199080_biz#angelleye.com
[initial_payment_amount] => 0.00
[profile_status] => Active
[amount] => 1.95
[txn_id] => 9PD943662S291292G
[payment_type] => instant
[payer_business_name] => Drew Angell's Test Store
[last_name] => Angell
[address_state] => CA
[receiver_email] => usb_1329725429_biz#angelleye.com
[payment_fee] => 0.15
[receiver_id] => C9TAVNJFATXCS
[txn_type] => recurring_payment
[mc_currency] => USD
[residence_country] => US
[test_ipn] => 1
[transaction_subject] => USBSwiper Monthly Subscription
[payment_gross] => 1.95
[shipping] => 0.00
[product_type] => 1
[time_created] => 15:10:22 Jun 18, 2013 PDT
[ipn_track_id] => 28067cf6ae8f
)
Array
(
[payment_cycle] => Monthly
[txn_type] => recurring_payment_profile_created
[last_name] => Angell
[next_payment_date] => 03:00:00 Jun 18, 2013 PDT
[residence_country] => US
[initial_payment_amount] => 0.00
[rp_invoice_id] => 3275
[currency_code] => USD
[time_created] => 15:10:22 Jun 18, 2013 PDT
[verify_sign] => ANrMRzzgbWP1I9ntjeVxAzQDTVjbATTckkxc4RtXKTYHoCoFDbklKPpd
[period_type] => Regular
[payer_status] => verified
[test_ipn] => 1
[tax] => 0.00
[payer_email] => sandbo_1204199080_biz#angelleye.com
[first_name] => Drew
[receiver_email] => usb_1329725429_biz#angelleye.com
[payer_id] => E7BTGVXBFSUAU
[product_type] => 1
[payer_business_name] => Drew Angell's Test Store
[shipping] => 0.00
[amount_per_cycle] => 1.95
[profile_status] => Active
[charset] => windows-1252
[notify_version] => 3.7
[amount] => 1.95
[outstanding_balance] => 0.00
[recurring_payment_id] => I-R0KGNCTUYAVW
[product_name] => USBSwiper Monthly Subscription
[ipn_track_id] => 1bf251e429b9c
)
Same as Andrew, but expanding on how skips and fails work (from what I've seen.):
recurring_payment_profile_created - When the profile is created. Important to note the recurring_payment_id, this is what you'll need to cancel/suspend/modify the profile.
recurring_payment_profile_cancel - When the profile is canceled.
recurring_payment_profile_modify - When the profile is modified.
recurring_payment - When you receive a recurring payment.
recurring_payment_skipped - When PayPal failed to collect payment and will try again in 5 days.
recurring_payment_failed - When MAXFAILEDPAYMENTS is not set, PayPal will try 3 times, if it fails all three, this will be the 3rd IPN.
recurring_payment_suspended_due_to_max_failed_payment - When MAXFAILEDPAYMENTS is set, this will be the IPN instead of recurring_payment_failed when the max is reached.