Magento save billing address in Quote - php

From the beginning I want to apologize for my poor English! I have a task to make the proper storage of information in the customer session in Magento on the page checkout. When i try to save billing address of a guest user i had rewrite billing model and all ok. But when user is logged in and has several address in his address book i saw interesting thing.... I had rewrite billing model more to save a customer address id and save selected address but when user select an option in select "New address", form data save in quote and when i try to get it with getQuote()->getBillingAddress() i took the default user address (when user not logged in all work good) How i can do this task ?? I need help because this important task for me ... A lot of thx !!!

If I am parsing your question correctly, are you saying that getQuote()->getBillingAddress() is getting the customer's default billing address instead of the new address the customer has entered in the order?
I have this problem in Magento 1.4.0.1 as well, I worked around it by getting all the addresses from the customer and comparing every attribute with the address specified in the order to find out the real entity ID of the address.
I copied this from my code with some parts of custom business logic removed, so consider it untested, but you get the idea:
(The code is only tested on Magento 1.4.0.1 and might not apply to Magento 1.5)
$currentCustomer = Mage::getModel('customer/customer')->load($order['customer_id']);
$attributesToCompare = array('firstname', 'lastname', 'country_id', 'region', 'region_id', 'city', 'telephone', 'postcode', 'company', 'fax', 'prefix', 'middlename', 'suffix', 'street');
$orderAddresses = array(
'billing' => $order->getBillingAddress()->getData(),
'shipping' => $order->getShippingAddress()->getData()
);
$foundExistingCustomerAddressEntityId = array(
'billing' => false,
'shipping' => false
);
$billingSameAsShipping = false;
$currentCustomerAddresses = $currentCustomer->getAddressesCollection();
// is the billing/shipping address currently found in the customer's address book?
foreach ($orderAddresses as $orderAddressKey => $orderAddress) {
//var_dump($orderAddress);
foreach ($currentCustomerAddresses as $currentCustomerAddressObj) {
$currentCustomerAddress = $currentCustomerAddressObj->getData();
$attributesMatchCount = 0;
foreach ($attributesToCompare as $attributeToCompare) {
if (empty($currentCustomerAddress[$attributeToCompare])) {
$currentCustomerAddress[$attributeToCompare] = false;
}
$attributesMatchCount += ($orderAddress[$attributeToCompare] == $currentCustomerAddress[$attributeToCompare])?1:0;
//echo 'attributesMatchCount: '.$attributesMatchCount." {$orderAddress[$attributeToCompare]} {$currentCustomerAddress[$attributeToCompare]}\n";
}
if ($attributesMatchCount == count($attributesToCompare)) {
$foundExistingCustomerAddressEntityId[$orderAddressKey] = $currentCustomerAddress['entity_id'];
//echo 'foundExistingCustomerAddressEntityId['.$orderAddressKey.']: '.$foundExistingCustomerAddressEntityId[$orderAddressKey]."\n\n";
break;
}
}
}
$billingShippingExactMatchCount = 0;
foreach ($attributesToCompare as $attributeToCompare) {
$billingShippingExactMatchCount += ($orderAddresses['billing'][$attributeToCompare] == $orderAddresses['shipping'][$attributeToCompare])?1:0;
}
if ($billingShippingExactMatchCount == count($attributesToCompare)) {
$billingSameAsShipping = true;
}

Related

applying promotion code instead of coupon in laravel/cashier

i am trying to use Promotion code instead of coupon code in laravel cashier/stripe official package but i couldn't find any help in there on how to apply promotion code instead of coupon on subscription as i know how to apply coupon but i want to apply promotion code, how can i do it.
below is my code for applying coupon when creating new subscription but i don't know how can i achieve it using promotion code:
$subscription = $user->newSubscription($plan->name, $selectedPlan);
// Add the trial days if any
if ($plan->trial_days) {
$subscription = $subscription->trialDays($plan->trial_days);
}
// Add the coupon id if any
if ($request->input('coupon_id')) {
$subscription = $subscription->withCoupon($request->input('coupon_id'));
}
$subscription->create($paymentMethod->id, [
'email' => $user->email
]);
You can add promotion code by using the ->withPromotionCode() e.g.
if ($request->input('promotion_code_id')) {
$subscription = $subscription->withPromotionCode($request->input('promotion_code_id'));
}
However, this function requires the promotion code ID instead of the code, and most likely you want your user to key in the code, not the ID. In such case, you can retrieve all active promotion codes and match the code.
if ($request->has('promotion_code')) {
$stripeClient = new \Stripe\StripeClient(config('cashier.secret'));
$result = $this->stripe->promotionCodes->all(
['code' => $request->get("promotion_code"), 'active' => true]
);
if($result->isEmpty()){
// handle invalid promo code here
}
$promoCodeID = $result->first()->id;
$subscription = $subscription->withPromotionCode($promoCodeID);
}

Developer Response - Payment Callback. PHP - Making me go crazy

Okay so I am trying to set up payments in my app that I am developing, I have the dialog working and it confirms the purchase of the item. I have no idea what it does after here tbh, I have read articles after articles, but no joy. I need information on how I can update mysql database on the purchase. I know the question is vague, but any guidance will be appreciated!
The code i have so far is below.
if ($request_type == 'payments_get_items') {
// Get order info from Pay Dialog's order_info.
// Assumes order_info is a JSON encoded string.
$order_info = json_decode($request['credits']['order_info'], true);
// Get item id.
$item_id = $order_info['item_id'];
// Simulutates item lookup based on Pay Dialog's order_info.
if ($item_id == '10Kremeggs') {
$item = array(
'title' => '10 Kremeggs',
'description' => 'Spend Kremeggs in Alien Abduction.',
// Price must be denominated in credits.
'price' => 5,
'image_url' => 'https://afternoon-snow-5267.herokuapp.com/images/bung.png',
'product_url' => 'https://afternoon-snow-5267.herokuapp.com/Purchase/10xKremeggs.php'
);
// Construct response.
$response = array(
'content' => array(
0 => $item,
),
'method' => $request_type,
);
// Response must be JSON encoded.
$response = json_encode($response);
}
} else if ($request_type == "payments_status_update") {
// Get order details.
$order_details = json_decode($request['credits']['order_details'], true);
// Determine if this is an earned currency order.
$item_data = json_decode($order_details['items'][0]['data'], true);
$earned_currency_order = (isset($item_data['modified'])) ?
$item_data['modified'] : null;
// Get order status.
$current_order_status = $order_details['status'];
if ($current_order_status == 'placed') {
// Fulfill order based on $order_details unless...
if ($earned_currency_order) {
// Fulfill order based on the information below...
// URL to the application's currency webpage.
$product = $earned_currency_order['product'];
// Title of the application currency webpage.
$product_title = $earned_currency_order['product_title'];
// Amount of application currency to deposit.
$product_amount = $earned_currency_order['product_amount'];
// If the order is settled, the developer will receive this
// amount of credits as payment.
$credits_amount = $earned_currency_order['credits_amount'];
}
$next_order_status = 'settled';
// Construct response.
$response = array(
'content' => array(
'status' => $next_order_status,
'order_id' => $order_details['order_id'],
),
'method' => $request_type,
);
// Response must be JSON encoded.
$response = json_encode($response);
} else if ($current_order_status == 'disputed') {
// 1. Track disputed item orders.
// 2. Investigate user's dispute and resolve by settling or refunding the order.
// 3. Update the order status asychronously using Graph API.
} else if ($current_order_status == 'refunded') {
// Track refunded item orders initiated by Facebook. No need to respond.
} else {
// Track other order statuses.
}
}
Above is part of the payment callback
<? mysql_query("UPDATE users SET Kremeggs = Kremeggs+10 WHERE Facebook_id = '$PurchaseUpdate'");
header ("Location: http://apps.facebook.com/alien_abduction/purchaseComplete.php");
?>
</body>
</html>
Above is what i need the payment to do.
It sounds like you're attempting to handle two very separate parts of the process at the same time in one file (your second code sample). The first code sample you posted (looks like their sample code, which is fine) is the proper place to award the user - your mysql query belongs inside the block which starts on line 43 (if ($current_order_status == 'placed') {). I'll leave the details of that for you to work out.
The second half of what you want to do (redirect the user to a confirmation page) does not belong in that callback, but rather on the page with the payment dialog. If you're using the sample code there as well, it belongs inside the js_callback function - try window.location.href='purchase_complete.php' (ensuring that this only happens on successful orders, ofc).
Hope that gets you pointed in the right direction!
else if ($request_type == "payments_status_update") {mysql_query("update users_table set payment_column='isok' where kulid like 'getFacebookUserId'");}

Add custom attribute in order email templates - Magento

I have created a 'Companyname' attribute which gets added up in my Customer's Account information and is a required field.
It gets filled up on registration, form and edit pages fine and gets displayed on Customer's Grid in the back-end too.
However I am not able to display the Company name in any of my order email templates.
I believe this is because there is neither any column called 'companyname' in my order tables nor do I have any custom variable which I can pass to order/invoice/shipment templates to display Company name right next to the line after Customer's name.
Can any one point out the file where I can create this custom variable containing my custom 'companyname' attribute and pass it to all types of sales email templates
Thanks
After a little bit of searching I found the right file to make the changes. Since I already had 'companyname' as one of my attributes I retrieved the value of this field and passed it as a param in the following function
app/code/core/Mage/Sales/Model/Order.php
public function sendNewOrderEmail()
{
/*Existing Code*/
if ($this->getCustomerIsGuest()) {
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
$customerId = Mage::getModel('customer/customer')->load($this->getCustomerId());
$companyname = $customerId->getCompanyname();
$customerName = $this->getBillingAddress()->getName();
} else {
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
$customerId = Mage::getModel('customer/customer')->load($this->getCustomerId());
$companyname = $customerId->getCompanyname();
$customerName = $this->getCustomerName();
}
/*Existing Code*/
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'companyname' => $companyname
));
/*Rest of the code remains the same*/
}
After making this change. I edited my Transactional Email to include this param. Since I wanted to display inside Shipping Address, I placed my variable just before this line in
System > Transactional Emails > New Order Email
{{ var companyname }}
{{var order.getShippingAddress.format('html')}}
If your companyname is getting saved as a part of Customer Information then this would get displayed in your Order Email in 'Shipping Address' Information right at the Start.
You can do the same for Invoice and Shipment Emails.
Hope this helps someone !!! :-)

Magento Questions get customer details and onepage/checkout/success doesn't sending email

How to get customers data so i can pass it to a gateway payment.
Here is my model:
public function getStandardCheckoutFormFields() {
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
//$order = $this->get_sale_order($orderIncrementId);
echo Mage::getModel('customer/customer')->load($orderIncrementId);
$productArray = array();
foreach ($order->getAllItems() as $item) {
$productArray[] = array(
"product_name" => $item->getName(),
"product_qty" => $item->getQtyOrdered(),
"product_price" => $item->getPrice(),
);
}
return $productArray;
}
here is my controller:
public function redirectAction(){
$session = Mage::getSingleton('checkout/session');
$session->setAsurepayCustompayQuoteId($session->getQuoteId());
$this->getResponse()->setBody($this->getLayout()->createBlock('custompay/redirect')->toHtml());
$session->unsQuoteId();
$session->unsRedirectUrl();
}
This are running perfectly running, the problem is i can't get customer details such as customer name, address and etc.
I already tried this code
Mage::getSingleton(customer/customer)->getData();
There was a result but not printing.
In the checkout page success (onepage). When customer redirected here, There is no email will be send to the customer and the order was not update as completed.
You're trying to load a customer with an id that belongs to the order. This obviously doesn't work! You need to extract the customer_id from the order and load the customer model based on that.
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
You're also using Mage::getSingleton which is the wrong call. You want a new instance tailored to a specific customer, not the single permissible instance of the class.

PayPal IPN, lots of sign ups, one payment, all in the wrong order

I've recently implemented a PayPal IPN into CodeIgniter2, using the PayPal Lib. I'm using the system for subscriptions.
I have a table in my database that records all IPN requests in the database.
For some reason, after every sign up the IPN requests aren't coming through properly. I tend to get one subscr_payment along with several subscr_signups, all with the same subscr_id. It's causing untolds amount of hassle within the system, for obvious reasons. What adds to this, is the fact that the IPN requests don't come in the correct order, sometimes I get the subscr_payment before the subscr_signup - making it impossible to track as there's no subscr_id from the sign up to link it to a user.
I've had a Google and can't find much on this, I seem to be a little bit of an anomaly. I'm wondering if it's something to do with the PayPal Lib I'm using, but I don't really want to have to do it outside of CodeIgniter, as I am doing a lot of processing. Below is the full IPN script.
class Paypal extends CI_Controller {
function _construct()
{
parent::_construct();
$this->load->library('paypal_lib');
}
function ipn()
{
$this->output->enable_profiler(TRUE);
$this->load->model('payments_model');
$this->load->model('paypal_model');
$this->load->model('users_model');
ob_start();
if ($this->paypal_lib->validate_ipn())
{
$paypal_id = $this->paypal_model->add_paypal_ipn($this->paypal_lib->ipn_data);
// Split the 'custom' field up, containing ID of temp user, ID of package and coupon
$custom = explode(';', $this->paypal_lib->ipn_data['custom']);
###
# subscription sign up
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_signup') {
// Activate user/move from temp > live
$this->users_model->move_temp($custom[0], $this->paypal_lib->ipn_data['subscr_id']);
} # end subscr_signup
###
# subscription payment
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_payment') {
// Grab the coupon info, if we have one
$discount = 1;
if(!empty($custom[2])){
$this->load->model('coupons_model');
$couponinfo = $this->coupons_model->get_coupon($custom[2]);
$discount = $couponinfo->discount;
}
// Grab the package info
$package = $this->packages_model->get_package($custom[1]);
$price = $package->monthly * $discount; // Calculate discount, 0.8 = 20% off
// Does the price calculated match the gross price? If not something fishy is going on, block it
if($price != $this->paypal_lib->ipn_data['mc_gross']){
mail(CONTACT_EMAIL, SITE_NAME.' failed payment attempt, possible hack', 'Price paid doesnt match price computed... paid: '.$this->paypal_lib->ipn_data['mc_gross'].' - price worked out: '.$price."\n\n".print_r($this->paypal_lib->ipn_data, true));
exit;
}
// Grab the user's details based on the subscr_id
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Add payment to the payments table
$data = array(
'user_id' => $user->user_id,
'subscr_id' => $user->subscr_id,
'txn_id' => $this->paypal_lib->ipn_data['txn_id'],
'amount' => $this->paypal_lib->ipn_data['mc_gross'],
'package_id' => $custom[1],
'coupon' => (empty($custom[2]) ? '' : $custom[2])
);
$this->payments_model->add_payment($data);
// Set (forced) user as active, and update their current active package
$data1 = array(
'package_id' => $custom[1],
'active' => 1
);
$this->users_model->update_user($data1, $user->user_id);
} # end subscr_payment
###
# subscription failed/cancelled
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_cancel' || $this->paypal_lib->ipn_data['txn_type'] == 'subscr_failed') {
// Grab user
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Make user inactive
$data = array('active' => 0);
$this->users_model->update_user($data, $user->user_id);
} # end subscr_cancel|subscr_failed
###
# subscription modified/payment changed
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_modify') {
// Grab the coupon info, if we have one
$discount = 1;
if(!empty($custom[2])){
$this->load->model('coupons_model');
$couponinfo = $this->coupons_model->get_coupon($custom[2]);
$discount = $couponinfo->discount;
}
// Grab the package info
$package = $this->packages_model->get_package($custom[1]);
$price = $package->monthly * $discount; // Calculate discount, 0.8 = 20% off
// Does the price calculated match the gross price? If not something fishy is going on, block it
if($price != $this->paypal_lib->ipn_data['mc_gross']){
mail(CONTACT_EMAIL, SITE_NAME.' failed payment attempt, possible hack', 'Price paid doesnt match price computed... paid: '.$this->paypal_lib->ipn_data['mc_gross'].' - price worked out: '.$price."\n\n".print_r($this->paypal_lib->ipn_data, true));
exit;
}
// Grab the user's details based on the subscr_id
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Add payment to the payments table
$data = array(
'user_id' => $user->user_id,
'subscr_id' => $user->subscr_id,
'txn_id' => $this->paypal_lib->ipn_data['txn_id'],
'amount' => $this->paypal_lib->ipn_data['mc_gross'],
'package_id' => $custom[1],
'coupon' => (empty($custom[2]) ? '' : $custom[2])
);
$this->payments_model->add_payment($data);
// Set (forced) user as active, and update their current active package
$data1 = array(
'package_id' => $custom[1],
'active' => 1
);
$this->users_model->update_user($data1, $user->user_id);
} # end subscr_modify
}
}
Below is an example of the calls made to my IPN for each transaction (CSV).
paypal_id,txn_id,subscr_id,txn_type,created
1,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:19:43
2,9XM95194MM564230E,I-FMUK0B5KJWKA,subscr_payment,2011-02-03 16:19:45
3,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:19:57
4,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:20:19
6,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:21:03
7,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:22:25
8,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:25:08
10,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:30:33
12,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:41:16
14,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 17:02:42
16,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 17:45:26
Consider this - PayPal is insert profanity. Now revisit the problem.
The chances are this isn't your fault, or CodeIgniter's or the Library's. PayPal is very bad at giving data in a uniform and timely manner, it is also slow and doesn't link data together very well.
My advice to you is save everything into an IPN table whenever a callback is made, even email yourself when ever an IPN call is made. Then work to try and figure out what PayPal is actually sending you, what you want and throw out the rest.
I think an IPN call is made even if the transaction has nothing to do with your web site. So if your Grandma sends you your Christmas money via PayPal it'll appear on the IPN callback.
Hope that helps a bit.
paypal isn't exactly easy to use but let me share 3 tips totackle the problems you are facing.
1) Create a table to store all IPN response from PayPal. Make sure you have a column called "raw" that stores EVERYTHING... do "json_encode($this->paypal_lib->ipn_data)". This will save you... since you can later write a script to pull out data from the raw column into it's own column down the road. This also helps with debugging.
2) For a start just pull out what is necessary out into columns of the ipn table so you can query easily... here's everything I've deem necessary for my use case which is probably similar to yours.
$this->payment_model->create_ipn(array(
'invoice' => $this->paypal_lib->ipn_data['invoice'],
'txn_type' => $this->paypal_lib->ipn_data['txn_id'],
'parent_txn_id' => $this->paypal_lib->ipn_data['parent_txn_id'],
'txn_type' => $this->paypal_lib->ipn_data['txn_type'],
'item_name' => $this->paypal_lib->ipn_data['item_name'],
'item_number' => $this->paypal_lib->ipn_data['item_number'],
'quantity' => $this->paypal_lib->ipn_data['quantity'],
'exchange_rate' => $this->paypal_lib->ipn_data['exchange_rate'],
'settle_amount' => $this->paypal_lib->ipn_data['settle_currency'],
'settle_amount' => $this->paypal_lib->ipn_data['settle_amount'],
'mc_currency' => $this->paypal_lib->ipn_data['mc_currency'],
'mc_fee' => $this->paypal_lib->ipn_data['mc_fee'],
'mc_gross' => $this->paypal_lib->ipn_data['mc_gross'],
'payment_date' => $this->paypal_lib->ipn_data['payment_date'],
'payment_status' => $this->paypal_lib->ipn_data['payment_status'],
'payment_type' => $this->paypal_lib->ipn_data['payment_type'],
'pending_reason' => $this->paypal_lib->ipn_data['pending_reason'],
'reason_code' => $this->paypal_lib->ipn_data['reason_code'],
'subscr_id' => $this->paypal_lib->ipn_data['subscr_id'],
'subscr_date' => $this->paypal_lib->ipn_data['subscr_date'] ? mdate('%Y-%m-%d %H:%i:%s', strtotime($this->paypal_lib->ipn_data['subscr_date'])) : NULL,
'subscr_effective' => $this->paypal_lib->ipn_data['subscr_effective'] ? mdate('%Y-%m-%d %H:%i:%s', strtotime($this->paypal_lib->ipn_data['subscr_effective'])) : NULL,
'period1' => $this->paypal_lib->ipn_data['period1'],
'period2' => $this->paypal_lib->ipn_data['period2'],
'period3' => $this->paypal_lib->ipn_data['period3'],
'amount1' => $this->paypal_lib->ipn_data['amount1'],
'amount2' => $this->paypal_lib->ipn_data['amount2'],
'amount3' => $this->paypal_lib->ipn_data['amount3'],
'mc_amount1' => $this->paypal_lib->ipn_data['mc_amount1'],
'mc_amount2' => $this->paypal_lib->ipn_data['mc_amount2'],
'mc_amount3' => $this->paypal_lib->ipn_data['mc_amount3'],
'recurring' => $this->paypal_lib->ipn_data['recurring'],
'reattempt' => $this->paypal_lib->ipn_data['reattempt'],
'retry_at' => $this->paypal_lib->ipn_data['retry_at'] ? mdate('%Y-%m-%d %H:%i:%s', strtotime($this->paypal_lib->ipn_data['retry_at'])) : NULL,
'recur_times' => $this->paypal_lib->ipn_data['recur_times'],
'payer_id' => $this->paypal_lib->ipn_data['payer_id'],
'payer_email' => $this->paypal_lib->ipn_data['payer_email'],
'payer_status' => $this->paypal_lib->ipn_data['payer_status'],
'payer_business_name' => $this->paypal_lib->ipn_data['payer_business_name'],
'ipn_track_id' => $this->paypal_lib->ipn_data['ipn_track_id'],
'raw' => json_encode($this->paypal_lib->ipn_data_arr),
'test_ipn' => $this->paypal_lib->ipn_data['test_ipn']
));
don't copy my code above since it's only meant to give you some rough ideas... if you do adapt my code do also ensure ipn_data function is like this (else you will get tons of errors)
function ipn_data($key)
{
return isset($this->fields[$key]) ? $this->fields[$key] : NULL;
}
to understand all the possible stuff they can send back this link is gold
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
but ^sigh^ don't trust it to be updated. i have found inconsistencies in what they doc says and what they sent back to me.
3) OK this i have to admit is another silly thing that paypal does - they don't give you an IPN date even tho' they don't guarantee the order in which it arrives at your server. For subscr_payment they give you payment_date... for subscr_signup they give you subscr_date... so what you need to do to get your IPN in the correct order is to have a column called ipn_date.
'ipn_date' => isset($this->paypal_lib->ipn_data['payment_date']) ?
mdate('%Y-%m-%d %H:%i:%s', strtotime($this->paypal_lib->ipn_data['payment_date'])) :
(isset($this->paypal_lib->ipn_data['subscr_date']) ?
mdate('%Y-%m-%d %H:%i:%s', strtotime($this->paypal_lib->ipn_data['subscr_date'])) : NULL),
now all is cool, you can "order by ipn_date" and I assure you everything will be in the correct order.
p.s. note the my first example code doesn't have this column, but it IS meant to be there. i'm just copying and pasting my development code to give you an idea.
What I do is ignore the signup ones and just process (create new user etc) on the actual payment transaction. And I wouldn't bother storing all those IPN trans. Have your IPN script send you an EMail on every one of them though, with an echo of all the fields posted. Then you'll have a record of them.

Categories