Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out the database functions and iproved the inclusion of remote …
…libs.
- Loading branch information
Bèr Kessels
committed
Feb 10, 2010
1 parent
057234b
commit 00538e5
Showing
2 changed files
with
88 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Database functions for ideal_payment API. | ||
* CRUD for orders | ||
*/ | ||
|
||
/** | ||
* Save order | ||
*/ | ||
function ideal_payment_api_order_save(&$order) { | ||
$now = time(); | ||
$order['order_id'] = db_next_id('ideal_payment_api_orders'); | ||
$order['description'] = theme('ideal_payment_api_description', $order); | ||
|
||
$inserted = db_query("INSERT INTO {ideal_payment_api_orders} (oid, user_id, description, amount, issuer_id, transaction_id, payment_status, foreign_id, created_at, updated_at) VALUES | ||
(%d, %d,'%s', %d, '%s', '%s', %d, %d, %d, %d)", $order['order_id'], $order['user_id'], $order['description'],$order['amount'], $order['issuer_id'], $order['transaction_id'], $order['payment_status'], $order['foreign_id'], $now, $now); | ||
|
||
|
||
if ($inserted) { | ||
return TRUE; | ||
} | ||
else { | ||
return FALSE; | ||
} | ||
} | ||
|
||
/** | ||
* Update order status | ||
*/ | ||
function ideal_payment_api_order_update($order_id, $payment_status, $transaction_id = NULL) { | ||
$status = FALSE; | ||
$now = time(); | ||
|
||
if (!$transaction_id) { | ||
if (db_query("UPDATE {ideal_payment_api_orders} SET payment_status = %d, transaction_id = '%s', updated_at = %d WHERE oid = %d", $payment_status, $transaction_id, $now, $order_id)) { | ||
$status = TRUE; | ||
} | ||
} | ||
else { | ||
if (db_query("UPDATE {ideal_payment_api_orders} SET payment_status = %d, updated_at = %d WHERE oid = %d", $payment_status, $now, $order_id)) { | ||
$status = TRUE; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Delete order | ||
*/ | ||
function ideal_payment_api_order_delete($order_id) { | ||
if (db_query("DELETE FROM {ideal_payment_api_orders} WHERE oid = %d", $order_id)) { | ||
return TRUE; | ||
} | ||
else { | ||
return FALSE; | ||
} | ||
} | ||
|
||
/** | ||
* Load order | ||
*/ | ||
function ideal_payment_api_order_load($order_id) { | ||
$result = db_query("SELECT * FROM {ideal_payment_api_orders} WHERE oid = %d", $order_id); | ||
$order = db_fetch_array($result); | ||
if (is_array($order)) { | ||
return $order; | ||
} | ||
else { | ||
return FALSE; | ||
} | ||
} |