Function __global->handle_confirmed_transaction

Definitions

sources/ecommerce.php

  • Handle IPN's that have been confirmed as backed up by real money.Variables largely emulate PayPal's IPN API.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$trans_expecting_id ?ID_TEXT No No required parameter N/A N/A Our internal temporary transaction ID (null: an immediate transaction that didn't require this table). For a live payment you should always pass a $trans_expecting_id in case tax rates or price changes over the interim, which can cause a mismatch or tax filing errors.
$txn_id ?ID_TEXT No No Null N/A N/A The transaction ID (null: randomised - for debugging only)
$type_code ?ID_TEXT No No Null N/A N/A The product codename (null: lookup from $trans_expecting_id - for debugging only)
$item_name ?SHORT_TEXT No No Null N/A N/A The human-readable product title (blank: doing a subscription cancellation, unknown item name; but can get from $found) (null: lookup from $trans_expecting_id - for debugging only)
$purchase_id ?ID_TEXT No No Null N/A N/A The ID of the purchase-type (meaning depends on item_name) (null: lookup from $trans_expecting_id - for debugging only)
$is_subscription boolean No No False N/A N/A Whether this is a subscription
$status ID_TEXT No No Completed Pending Completed SModified SCancelled N/A The status this transaction is telling of
$reason SHORT_TEXT No No Blank (empty string) N/A N/A A reason for the transaction's status (blank: unknown or N/A)
$price ?REAL No No Null N/A N/A Transaction price paid excluding tax, shipping, and transaction fees (null: lookup from $trans_expecting_id - for debugging only)
$tax ?REAL No No Null N/A N/A Transaction tax (null: not separated out, find the tax due and take it out of $price)
$shipping ?REAL No No Null N/A N/A Transaction shipping (null: not separated out, find the shipping due and take it out of $price)
$transaction_fee ?REAL No No Null N/A N/A The transaction fee (null: we do not know; run get_transaction_fee to determine this)
$currency ?ID_TEXT No No Null N/A N/A The currency (points: was done fully with points) (null: lookup from $trans_expecting_id - for debugging only)
$check_amounts boolean No No True N/A N/A Check the amounts related to this transaction; if not set no points will be charged
$parent_txn_id ID_TEXT No No Blank (empty string) N/A N/A The ID of the parent transaction (blank: unknown or N/A)
$pending_reason SHORT_TEXT No No Blank (empty string) N/A N/A The reason it is in pending status (if it is) (blank: unknown or N/A)
$memo LONG_TEXT No No Blank (empty string) N/A N/A A note attached to the transaction (blank: not set)
$period string No No Blank (empty string) N/A N/A The subscription period (blank: N/A or unknown because trust is checked on the gateway's code)
$member_id_paying ?MEMBER No No Null N/A N/A The member ID of who is doing the transaction (null: unknown)
$payment_gateway ID_TEXT No No Blank (empty string) N/A N/A The payment gateway (manual: was a manual transaction, not through a real gateway)
$silent_fail boolean No No False N/A N/A Always return null on failure rather than showing any error message. Used when not sure a valid & finalised transaction is in the POST environment, but you want to try just in case (e.g. on a redirect back from the gateway).
$send_notifications boolean No No True N/A N/A Whether to send notifications. Set to false if this is not the primary payment handling (e.g. a POST redirect rather than the real IPN).

Returns

  • ID_TEXT A pair: The product purchased, The purchasing member ID (or null) (null: silent error)
  • Type: ?array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Handle IPN's that have been confirmed as backed up by real money.Variables largely emulate PayPal's IPN API.
 *
 * @param  ?ID_TEXT $trans_expecting_id Our internal temporary transaction ID (null: an immediate transaction that didn't require this table). For a live payment you should always pass a $trans_expecting_id in case tax rates or price changes over the interim, which can cause a mismatch or tax filing errors.
 * @param  ?ID_TEXT $txn_id The transaction ID (null: randomised - for debugging only)
 * @param  ?ID_TEXT $type_code The product codename (null: lookup from $trans_expecting_id - for debugging only)
 * @param  ?SHORT_TEXT $item_name The human-readable product title (blank: doing a subscription cancellation, unknown item name; but can get from $found) (null: lookup from $trans_expecting_id - for debugging only)
 * @param  ?ID_TEXT $purchase_id The ID of the purchase-type (meaning depends on item_name) (null: lookup from $trans_expecting_id - for debugging only)
 * @param  boolean $is_subscription Whether this is a subscription
 * @param  ID_TEXT $status The status this transaction is telling of
 * @set Pending Completed SModified SCancelled
 * @param  SHORT_TEXT $reason A reason for the transaction's status (blank: unknown or N/A)
 * @param  ?REAL $price Transaction price paid excluding tax, shipping, and transaction fees (null: lookup from $trans_expecting_id - for debugging only)
 * @param  ?REAL $tax Transaction tax (null: not separated out, find the tax due and take it out of $price)
 * @param  ?REAL $shipping Transaction shipping (null: not separated out, find the shipping due and take it out of $price)
 * @param  ?REAL $transaction_fee The transaction fee (null: we do not know; run get_transaction_fee to determine this)
 * @param  ?ID_TEXT $currency The currency (points: was done fully with points) (null: lookup from $trans_expecting_id - for debugging only)
 * @param  boolean $check_amounts Check the amounts related to this transaction; if not set no points will be charged
 * @param  ID_TEXT $parent_txn_id The ID of the parent transaction (blank: unknown or N/A)
 * @param  SHORT_TEXT $pending_reason The reason it is in pending status (if it is) (blank: unknown or N/A)
 * @param  LONG_TEXT $memo A note attached to the transaction (blank: not set)
 * @param  string $period The subscription period (blank: N/A or unknown because trust is checked on the gateway's code)
 * @param  ?MEMBER $member_id_paying The member ID of who is doing the transaction (null: unknown)
 * @param  ID_TEXT $payment_gateway The payment gateway (manual: was a manual transaction, not through a real gateway)
 * @param  boolean $silent_fail Always return null on failure rather than showing any error message. Used when not sure a valid & finalised transaction is in the POST environment, but you want to try just in case (e.g. on a redirect back from the gateway).
 * @param  boolean $send_notifications Whether to send notifications. Set to false if this is not the primary payment handling (e.g. a POST redirect rather than the real IPN).
 * @return ?array ID_TEXT A pair: The product purchased, The purchasing member ID (or null) (null: silent error)
 */

function handle_confirmed_transaction(?string $trans_expecting_id, ?string $txn_id = null, ?string $type_code = null, ?string $item_name = null, ?string $purchase_id = null, bool $is_subscription = false, string $status = 'Completed', string $reason = '', ?float $price = null, ?float $tax = null, ?float $shipping = null, ?float $transaction_fee = null, ?string $currency = null, bool $check_amounts = true, string $parent_txn_id = '', string $pending_reason = '', string $memo = '', string $period = '', ?int $member_id_paying = null, string $payment_gateway = '', bool $silent_fail = false, bool $send_notifications = true) : ?array