Example #1
0
/**
 * Create order record from IPN data
 */
function ipn_create_order_array($new_order_id, $txn_type)
{
    $sql_data_array = array('order_id' => $new_order_id, 'txn_type' => $txn_type, 'module_name' => 'paypal (ipn-handler)', 'module_mode' => 'IPN', 'reason_code' => $_POST['reason_code'], 'payment_type' => $_POST['payment_type'], 'payment_status' => $_POST['payment_status'], 'pending_reason' => $_POST['pending_reason'], 'invoice' => $_POST['invoice'], 'mc_currency' => $_POST['mc_currency'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'payer_business_name' => $_POST['payer_business_name'], 'address_name' => $_POST['address_name'], 'address_street' => $_POST['address_street'], 'address_city' => $_POST['address_city'], 'address_state' => $_POST['address_state'], 'address_zip' => $_POST['address_zip'], 'address_country' => $_POST['address_country'], 'address_status' => $_POST['address_status'], 'payer_email' => $_POST['payer_email'], 'payer_id' => $_POST['payer_id'], 'payer_status' => $_POST['payer_status'], 'payment_date' => datetime_to_sql_format($_POST['payment_date']), 'business' => $_POST['business'], 'receiver_email' => $_POST['receiver_email'], 'receiver_id' => $_POST['receiver_id'], 'txn_id' => $_POST['txn_id'], 'parent_txn_id' => $_POST['parent_txn_id'], 'num_cart_items' => $_POST['num_cart_items'], 'mc_gross' => $_POST['mc_gross'], 'mc_fee' => $_POST['mc_fee'], 'settle_amount' => $_POST['settle_amount'], 'settle_currency' => $_POST['settle_currency'], 'exchange_rate' => $_POST['exchange_rate'], 'notify_version' => $_POST['notify_version'], 'verify_sign' => $_POST['verify_sign'], 'date_added' => 'now()', 'memo' => $_POST['memo']);
    return $sql_data_array;
}
Example #2
0
 /**
  * Post-processing activities
  * When the order returns from the processor, if PDT was successful, this stores the results in order-status-history and logs data for subsequent reference
  *
  * @return boolean
  */
 function after_process()
 {
     global $insert_id, $db, $order;
     if ($_SESSION['paypal_transaction_PDT_passed'] != true) {
         $_SESSION['order_created'] = '';
         unset($_SESSION['paypal_transaction_PDT_passed']);
         return false;
     } else {
         // PDT found order to be approved, so add a new OSH record for this order's PP details
         unset($_SESSION['paypal_transaction_PDT_passed']);
         $sql_data_array = array(array('fieldName' => 'orders_id', 'value' => $insert_id, 'type' => 'integer'), array('fieldName' => 'orders_status_id', 'value' => $this->order_status, 'type' => 'integer'), array('fieldName' => 'date_added', 'value' => 'now()', 'type' => 'noquotestring'), array('fieldName' => 'customer_notified', 'value' => 0, 'type' => 'integer'), array('fieldName' => 'comments', 'value' => 'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency'] . '.', 'type' => 'string'));
         $db->perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
         ipn_debug_email('PDT NOTICE :: Order added: ' . $insert_id . "\n" . 'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency']);
         // store the PayPal order meta data -- used for later matching and back-end processing activities
         $sql_data_array = array('order_id' => $insert_id, 'txn_type' => $this->pdtData['txn_type'], 'module_name' => $this->code . ' ' . $this->codeVersion, 'module_mode' => 'PDT', 'reason_code' => $this->pdtData['reasoncode'], 'payment_type' => $this->pdtData['payment_type'], 'payment_status' => $this->pdtData['payment_status'], 'pending_reason' => $this->pdtData['pendingreason'], 'invoice' => $this->pdtData['invoice'], 'first_name' => $this->pdtData['first_name'], 'last_name' => $this->pdtData['last_name'], 'payer_business_name' => $order->billing['company'], 'address_name' => $order->billing['name'], 'address_street' => $order->billing['street_address'], 'address_city' => $order->billing['city'], 'address_state' => $order->billing['state'], 'address_zip' => $order->billing['postcode'], 'address_country' => $this->pdtData['residence_country'], 'address_status' => $this->pdtData['address_status'], 'payer_email' => $this->pdtData['payer_email'], 'payer_id' => $this->pdtData['payer_id'], 'payer_status' => $this->pdtData['payer_status'], 'payment_date' => datetime_to_sql_format($this->pdtData['payment_date']), 'business' => $this->pdtData['business'], 'receiver_email' => $this->pdtData['receiver_email'], 'receiver_id' => $this->pdtData['receiver_id'], 'txn_id' => $this->pdtData['txn_id'], 'parent_txn_id' => $this->pdtData['parent_txn_id'], 'num_cart_items' => (double) $this->pdtData['num_cart_items'], 'mc_gross' => (double) $this->pdtData['mc_gross'], 'mc_fee' => (double) $this->pdtData['mc_fee'], 'mc_currency' => $this->pdtData['mc_currency'], 'settle_amount' => (double) $this->pdtData['settle_amount'], 'settle_currency' => $this->pdtData['settle_currency'], 'exchange_rate' => $this->pdtData['exchange_rate'] > 0 ? $this->pdtData['exchange_rate'] : 1.0, 'notify_version' => (double) $this->pdtData['notify_version'], 'verify_sign' => $this->pdtData['verify_sign'], 'date_added' => 'now()', 'memo' => '{Successful PDT Confirmation - Record auto-generated by payment module}');
         // TODO: $db->perform vs zen_db_perform
         zen_db_perform(TABLE_PAYPAL, $sql_data_array);
         ipn_debug_email('PDT NOTICE :: paypal table updated: ' . print_r($sql_data_array, true));
     }
 }
/**
 * Create order record from IPN data
 */
function ipn_create_order_array($new_order_id, $txn_type)
{
    $sql_data_array = array('order_id' => $new_order_id, 'txn_type' => $txn_type, 'module_name' => 'paypal (ipn-handler)', 'module_mode' => 'IPN', 'reason_code' => $_POST['reason_code'], 'payment_type' => $_POST['payment_type'], 'payment_status' => $_POST['payment_status'], 'pending_reason' => $_POST['pending_reason'], 'invoice' => $_POST['invoice'], 'mc_currency' => $_POST['mc_currency'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'payer_business_name' => $_POST['payer_business_name'], 'address_name' => $_POST['address_name'], 'address_street' => $_POST['address_street'], 'address_city' => $_POST['address_city'], 'address_state' => $_POST['address_state'], 'address_zip' => $_POST['address_zip'], 'address_country' => $_POST['address_country'], 'address_status' => $_POST['address_status'], 'payer_email' => $_POST['payer_email'], 'payer_id' => $_POST['payer_id'], 'payer_status' => $_POST['payer_status'], 'payment_date' => datetime_to_sql_format($_POST['payment_date']), 'business' => $_POST['business'], 'receiver_email' => $_POST['receiver_email'], 'receiver_id' => $_POST['receiver_id'], 'txn_id' => $_POST['txn_id'], 'parent_txn_id' => $_POST['parent_txn_id'], 'num_cart_items' => (int) $_POST['num_cart_items'], 'mc_gross' => $_POST['mc_gross'], 'mc_fee' => $_POST['mc_fee'], 'settle_amount' => isset($_POST['settle_amount']) && $_POST['settle_amount'] != '' ? $_POST['settle_amount'] : 0, 'settle_currency' => $_POST['settle_currency'], 'exchange_rate' => isset($_POST['exchange_rate']) && $_POST['exchange_rate'] != '' ? $_POST['exchange_rate'] : 1, 'notify_version' => $_POST['notify_version'], 'verify_sign' => $_POST['verify_sign'], 'date_added' => 'now()', 'memo' => '{Record generated by IPN}');
    if (isset($_POST['protection_eligibility']) && $_POST['protection_eligibility'] != '') {
        $sql_data_array['memo'] .= ' [ProtectionEligibility:' . $_POST['protection_eligibility'] . ']';
    }
    if (isset($_POST['memo']) && $_POST['memo'] != '') {
        $sql_data_array['memo'] .= ' [Customer Comments:' . $_POST['memo'] . ']';
    }
    return $sql_data_array;
}
Example #4
0
 } else {
     $txn_type = 'parent';
 }
 if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
     mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', '9. txn type = ' . $txn_type);
 }
 switch ($txn_type) {
     case 'unique':
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', 'handling unique entry');
         }
         $new_order_id = $order->create($order_totals);
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', 'new order id = ' . $new_order_id);
         }
         $paypal_order = array(zen_order_id => $new_order_id, txn_type => $_POST['txn_type'], reason_code => $_POST['reason_code'], payment_type => $_POST['payment_type'], payment_status => $_POST['payment_status'], pending_reason => $_POST['pending_reason'], invoice => $_POST['invoice'], mc_currency => $_POST['mc_currency'], first_name => $_POST['first_name'], last_name => $_POST['last_name'], payer_business_name => $_POST['payer_business_name'], address_name => $_POST['address_name'], address_street => $_POST['address_street'], address_city => $_POST['address_city'], address_state => $_POST['address_state'], address_zip => $_POST['address_zip'], address_country => $_POST['address_country'], address_status => $_POST['address_status'], payer_email => $_POST['payer_email'], payer_id => $_POST['payer_id'], payer_status => $_POST['payer_status'], payment_date => datetime_to_sql_format($_POST['payment_date']), business => $_POST['business'], receiver_email => $_POST['receiver_email'], receiver_id => $_POST['receiver_id'], txn_id => $_POST['txn_id'], parent_txn_id => $_POST['parent_txn_id'], num_cart_items => $_POST['num_cart_items'], mc_gross => $_POST['mc_gross'], mc_fee => $_POST['mc_fee'], settle_amount => $_POST['settle_amount'], settle_currency => $_POST['settle_currency'], exchange_rate => $_POST['exchange_rate'], notify_version => $_POST['notify_version'], verify_sign => $_POST['verify_sign'], date_added => 'now()', memo => $_POST['memo']);
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', '10. Created Paypal Order');
         }
         zen_db_perform(TABLE_PAYPAL, $paypal_order);
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', '10.0 Created Paypal Order');
         }
         $insert_id = $db->Insert_ID();
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', '10.1 Created Paypal Order');
         }
         $paypal_order_history = array('paypal_ipn_id' => $insert_id, 'txn_id' => $_POST['txn_id'], 'parent_txn_id' => $_POST['parent_txn_id'], 'payment_status' => $_POST['payment_status'], 'pending_reason' => $_POST['pending_reason'], 'date_added' => 'now()');
         zen_db_perform(TABLE_PAYPAL_PAYMENT_STATUS_HISTORY, $paypal_order_history);
         if (MODULE_PAYMENT_PAYPAL_IPN_DEBUG == 'Yes') {
             mail(MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS, 'IPN DEBUG MESSAGE', '10.2. Created Paypal Order history');