cp_action_gateway

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.

Your rating: none
Rating: 0 - 0 votes

Popular Add-ons

BetterMobile

Enhance the mobile experience of your ClassiPress website!


(3)
$10

Ads By Category or Ad Tag

Display ads from specific category or categories by using a filter widget.


(5)
$12

2Checkout

Accept up to eight payment methods, fifteen languages, & twenty six…


(4)
$39