Payment is a new feature in Tiki5
The Payment API is built to be hooked from multiple parts of the system. While there is a user interface, the primary purpose of it is for management. Payment requests should be hooked to actions in the system. A good example is the PluginMemberPayment.
A payment request is like an Invoice.
A registered payment will execute a set of behaviors when events occur. Supported events are 'complete', for when the payment is fully paid, and 'cancel' when the payment is abandoned. The behaviors can only be registered through the API. Manually created payments must be handled manually.
Behaviors are stored in lib/payment/behavior/ and are named like the behavior called ('sample' would be in sample.php). Inside those files, a function named payment_behavior_sample is expected to be present. When the behavior is registered, an array is provided.
<?php global $paymentlib; require_once 'lib/payment/paymentlib.php'; $user = 'test123'; // ... $invoice = $paymentlib->request_payment( 'Some payment', 100, 30 ); $paymentlib->register_behavior( $invoice, 'complete', 'notify_admin', array( $user, 'All good!' ) ); $paymentlib->register_behavior( $invoice, 'cancel', 'notify_admin', array( $user, 'Forget it.' ) ); ?>
Upon payment, the following call will be made indirectly:
payment_behavior_notify_admin( 'test123', 'All good!' );
For Shopping Cart and Payments.
Open & Pending
In themselves, the payments only handle the actual request for money and tracking of the payment made, regardless of the payment technique used. In a full payment process, you may have something that looks like this:
- Product selection
- Applying discount
- Calculate shipping charges
- Calculate applicable taxes
- Proceed to payment (register the payment, as we care about it here)
- Perform payment from gateway
Currently, the product selection can be handled through the cart module and add to cart plugin. Other elements in-between are not implemented at this time. When extending, please keep in mind the entire process and avoid adding too many features to the payment handling directly.
- Louis-Philippe Huberdeau
To help with development, here you are create a sandbox account
- Payments Pro
- PayPal Subscription
- Community Currencies
Alias names of this page: