This function executes in gateways/gateway.php to process the payment.
To learn more about processing payments in ClassiPress, read this tutorial.
Usage
This hook provides the order values to process as the first and only argument. In your code, you need to check the cp_payment_method
element of the order values array to make sure it corresponds to your payment processor. If it isn’t, you should return.
function your_payment_processor( $order_values ){ if( $order_values['cp_payment_method'] != "your_payment_processor" ){ return; } // process order here... } add_action( 'cp_action_gateway', 'your_payment_processor', 10, 1 ); |
Example
<?php function buy_stuff_processor( $order_values ){ // Only handle BuyStuff payments if( $order_values['cp_payment_method'] != "buystuff" ){ return; } // Process the payment with library function bs_process_payment( $order_values ); // Send email with information $email = ''; $email .= __( 'Thanks for purchasing ', 'bs' ) . $order_values['item_name'] . '.'; $email .= __( ' Your total is ', 'bs' ) . $order_values['item_amount']. '.'; $email .= __( ' Please come again!', 'bs' ); // Send email with library function bs_email_customer( $email ); } add_action( 'cp_action_gateway', 'buy_stuff_processor', 10, 1 ); ?> |
Changelog
- since 1.1
Source File
cp_action_gateway()
is located in gateways/gateway.php
.