/** * Checks if specified member was subscribed by specified provider and then * initiates new transaction basing on data from transaction, which was created * on subscription * * @param int $localTranID - ID of transaction which was created on subscription * Function initiates new transaction using data from * this transaction * * @return int/bool - ID of initiated transaction on success, false otherwise * * */ function initiateSubscriptionTransaction($localTranID) { // arguments validation $localTranID = (int) $localTranID; // select dummy transaction info $tranRes = db_res("SELECT `IDProvider`, `Data` FROM `Transactions`\r\n\t\t\t\t\t\t\tWHERE `ID` = {$localTranID}"); if (!$tranRes || mysql_num_rows($tranRes) == 0) { return false; } $tranArr = mysql_fetch_assoc($tranRes); $tranData = transStringToData($tranArr['Data']); // check if member subscribed $subsArr = db_arr("SELECT `TransactionID`, `ChargesNumber` FROM `PaymentSubscriptions`\r\n\t\t\t\t\t\t\tWHERE `TransactionID` = {$localTranID}"); if (!$subsArr) { return false; } $checkoutData['checkout_action'] = $tranData['action']; $checkoutData['amount'] = $tranData['amount']; $checkoutData['data'] = $tranData['data']; $checkoutData['description'] = returnDescByAction($tranData['action'], $tranData['data'], true); $res = initiateTransaction($checkoutData, $tranData['memberID'], $tranArr['IDProvider']); if (!$res) { return false; } else { return $res; } }
<tr class=panel> <td align="left" nowrap>Order number</td> <td align="left" nowrap>Date</td> <td align="left" nowrap>Member</td> <td align="left" nowrap>Provider</td> <td align="center" nowrap>Info</td> <td align="right" nowrap>Sum paid, <?php echo $currency_code; ?> </td> </tr> <?php while ($tr_arr = mysql_fetch_array($tr_res)) { $tranDataArray = transStringToData($tr_arr['Data']); $tranTypeString = '<b>Type:</b> ' . $tranDataArray['action']; $tranDataString = '<b>Description:</b> ' . returnDescByAction($tranDataArray['action'], $tranDataArray['data'], false); $tranNoteString = strlen($tr_arr['Note']) ? '<b>Note:</b> ' . $tr_arr['Note'] : ''; ?> <tr class=table> <td><?php echo $tr_arr['gtwTransactionID']; ?> </td> <td align="left" nowrap><?php echo $tr_arr['Date']; ?> </td> <td align="left" nowrap><?php echo "<a href=\"{$site['url']}profile.php?ID={$tr_arr['IDMember']}\">{$tr_arr['IDMember']}</a>"; ?> </td>
/** * collect data from source */ function CollectCheckoutInfo($source) { global $collectDataArr; global $collectDataInputs; if (!isset($source['checkout_action']) || strlen($source['data']) == 0) { return false; } $collectDataArr['checkout_action'] = process_pass_data($source['checkout_action']); $collectDataArr['amount'] = process_pass_data($source['amount']); $collectDataArr['data'] = process_pass_data($source['data']); if (isset($source['allow_subscribe'])) { $collectDataArr['allow_subscribe'] = process_pass_data($source['allow_subscribe']); } if (isset($source['subscribe_days'])) { $collectDataArr['subscribe_days'] = process_pass_data($source['subscribe_days']); } $collectDataArr['description'] = returnDescByAction($collectDataArr['checkout_action'], $collectDataArr['data'], true); if (strlen($collectDataArr['description']) == 0) { return false; } $collectDataInputs = ''; $collectDataInputs .= "<input type=\"hidden\" name=\"checkout_action\" value=\"{$collectDataArr['checkout_action']}\" />\n"; $collectDataInputs .= "<input type=\"hidden\" name=\"amount\" value=\"{$collectDataArr['amount']}\" />\n"; $collectDataInputs .= "<input type=\"hidden\" name=\"data\" value=\"{$collectDataArr['data']}\" />\n"; if (isset($source['allow_subscribe'])) { $collectDataInputs .= "<input type=\"hidden\" name=\"allow_subscribe\" value=\"{$collectDataArr['allow_subscribe']}\" />\n"; } if (isset($source['subscribe_days'])) { $collectDataInputs .= "<input type=\"hidden\" name=\"subscribe_days\" value=\"{$collectDataArr['subscribe_days']}\" />\n"; } return true; }