Skip to content

Instantly share code, notes, and snippets.

View ajayghaghretiya's full-sized avatar

Ajay Ghaghretiya ajayghaghretiya

  • Ahmedabad
View GitHub Profile
@ajayghaghretiya
ajayghaghretiya / functions.php
Created December 28, 2017 12:57
Do Payment via WooCommerce REST API for Stripe
add_action( 'rest_api_init', 'custom_api_endpoints' );
function custom_api_endpoints() {
/**
* Handle Payment Method request.
*/
register_rest_route( 'wc/v2', 'payment', array(
'methods' => 'POST',
'callback' => 'custom_payment_endpoint_handler',
@ajayghaghretiya
ajayghaghretiya / functions.php
Created December 28, 2017 12:38
For the Get the Active Payment Method In WooCommerce REST API
add_action( 'rest_api_init', 'custom_api_endpoints' );
function custom_api_endpoints() {
/**
* Handle Get Payment Method request.
*/
register_rest_route( 'wc/v2', 'get_payment_methods', array(
'methods' => 'POST',
'callback' => 'custom_get_payment_methods_endpoint_handler',
//removes extra keys from the wc orders rest api
function change_shop_order_response( $response, $object, $request ) {
$response_data = $response->data;
$remove_keys = array('version','currency','customer_ip_address','customer_user_agent','');
$filtered_res = array_diff_key( $response_data, array_flip( $remove_keys ) );
$response->data = $filtered_res;
return $response;
}