Skip to content

Commit

Permalink
send extra user info to form
Browse files Browse the repository at this point in the history
  • Loading branch information
afatsini committed Dec 12, 2016
1 parent 149d053 commit ea44ed0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function getMajorVersion()
*/
public static function getMinorVersion()
{
return '10';
return '11';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function processCallback(\XLite\Model\Payment\Transaction $transaction)
$temp['data']['id']
);

$signature_check_sha512 = hash('sha512',
$signature_check_sha512 = hash(
'sha512',
$this->secret_key .
$temp['account_id'] .
$temp['api_version'] .
Expand Down Expand Up @@ -249,6 +250,33 @@ protected function getFormFields()
$this->discount = 'false';
}

//extra user parameters
$sign_up_date = '';
$toal_amount = 0;
$num_refunds = 0;
$amount_refunded = 0;
$total_orders = 0;
$profile = \XLite\Core\Auth::getInstance()->getProfile();
if (trim($profile != '')) {
$sign_up_date = date('Y/m/d', $profile->getAdded());
$cnd = new \XLite\Core\CommonCell();
$cnd->profile = $profile;
$orders = \XLite\Core\Database::getRepo('XLite\Model\Order')->search($cnd);
foreach ($orders as $o) {

if ($o->getPaymentStatusCode() == \XLite\Model\Order\Status\Payment::STATUS_PART_PAID ||
$o->getPaymentStatusCode() == \XLite\Model\Order\Status\Payment::STATUS_PAID
) {
$toal_amount += $o->getTotal();
$total_orders++;
} elseif ($o->getPaymentStatusCode() == \XLite\Model\Order\Status\Payment::STATUS_REFUNDED) {
$num_refunds++;
$amount_refunded += $o->getTotal();
}
}
}


$string = $this->secret_key
. $this->public_key
. $trx_id
Expand Down Expand Up @@ -286,7 +314,11 @@ protected function getFormFields()
'discount[full]' => $this->discount,
'order_id' => $trx_id,
'description' => $trx_id,
'pay_method' => 'CC',
'metadata[member_since]' => $sign_up_date,
'metadata[num_orders]' => $total_orders,
'metadata[amount_orders]' => $toal_amount,
'metadata[num_full_refunds]' => $num_refunds,
'metadata[amount_refunds]' => $amount_refunded
);

$i=0;
Expand Down

0 comments on commit ea44ed0

Please sign in to comment.