Created
November 30, 2015 23:47
-
-
Save gabrielmerovingi/45e58fd5ee60990f6c39 to your computer and use it in GitHub Desktop.
Final code for myCRED Tutorial - http://mycred.me/tutorial/the-buycred-payment-gateway-api/
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
add_filter( 'mycred_setup_gateways', 'register_custom_gateway' ); | |
function register_custom_gateway( $gateways ) { | |
// Using a gateway class | |
$gateways['unique-gateway-id'] = array( | |
'title' => __( 'Gateway Title' ), | |
'callback' => array( 'gateway_class_name' ) | |
); | |
// or Using a gateway function | |
$gateways['unique-gateway-id'] = array( | |
'title' => __( 'Gateway Title' ), | |
'callback' => 'gateway_function_name' | |
); | |
return $gateways; | |
} | |
// Purchases are made locally | |
class My_Custom_Gateway extends myCRED_Payment_Gateway { | |
function __construct( $gateway_prefs ) { | |
parent::__construct( $args, $gateway_prefs ); | |
} | |
function buy() { | |
$this->purchase_header( 'Header / Title' ); | |
echo 'these things needs to be included on this page'; | |
$this->purchase_footer(); | |
} | |
} | |
// Purchases are done remotely | |
class My_Custom_Gateway extends myCRED_Payment_Gateway { | |
function __construct( $gateway_prefs ) { | |
parent::__construct( $args, $gateway_prefs ); | |
} | |
function buy() { | |
$this->purchase_header( 'Header / Title' ); | |
$arguments = array(); | |
$this->form_with_redirect( $arguments ); | |
$this->purchase_footer(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment