wip payment kind of works with bugs
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
/*
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_utils.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/user_can_pay.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/update_user_payment.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/shortcode.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_orders.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_orders_capture.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/paypal/routes.php');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,72 +46,5 @@ add_action('template_redirect', 'check_paypal_request');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* call to paypal_shortcode_content()
|
||||
*/
|
||||
function paypal_shortcode_content_FIPF()
|
||||
{
|
||||
$fipfcard_paypal = new PLGNTLS_class();
|
||||
|
||||
$pp_sdk_currency = "EUR";
|
||||
$pp_sdk_base_url = "https://www.paypal.com";
|
||||
$pp_sdk_url = "$pp_sdk_base_url/sdk/js?client-id=" . PAYPAL_CLIENT_ID . "¤cy=$pp_sdk_currency";
|
||||
|
||||
$paypal_redirection_success = PAYPAL_REDIRECTION_SUCCESS;
|
||||
$paypal_redirection_failure = PAYPAL_REDIRECTION_FAILURE;
|
||||
$paypal_message_success = PAYPAL_MESSAGE_SUCCESS;
|
||||
$paypal_message_failure = PAYPAL_MESSAGE_FAILURE;
|
||||
|
||||
$added_to_front = $fipfcard_paypal->add_to_front(
|
||||
array(
|
||||
$pp_sdk_url,
|
||||
array("js/paypal/paypal.js", 'type'=>'module'),
|
||||
"html/paypal/paypal.html",
|
||||
),
|
||||
compact (
|
||||
'paypal_redirection_success',
|
||||
'paypal_redirection_failure',
|
||||
'paypal_message_success',
|
||||
'paypal_message_failure',
|
||||
),
|
||||
);
|
||||
|
||||
return $added_to_front;
|
||||
}
|
||||
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content_FIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* the js file paypal.js needs to be imported as a module to use import
|
||||
* @see https://developer.wordpress.org/reference/hooks/script_loader_tag/
|
||||
function add_id_to_script_FIPF( $tag, $handle, $src ) {
|
||||
if ( $handle === 'PLGNTLS_paypal_js' ) {
|
||||
$tag = '<script type="module" src="' . esc_url( $src ) . '" ></script>';
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
add_filter( 'script_loader_tag', 'add_id_to_script_FIPF', 10, 3 );
|
||||
*/
|
||||
|
||||
|
||||
// handling routes and endpoints
|
||||
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
|
||||
function routes_endpoints_FIPF()
|
||||
{
|
||||
$base_rest_route = "fipf_plugin/api/v1";
|
||||
register_rest_route($base_rest_route, '/orders', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_orders_request_FIPF',
|
||||
));
|
||||
// https://local_fipfcard_plugin.com/wp-json/fipf_plugin/api/v1/orders/21T129305J264761D/capture
|
||||
register_rest_route($base_rest_route, '/orders/(?P<orderID>[a-zA-Z0-9]+)/capture', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_orders_capture_request_FIPF',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'routes_endpoints_FIPF');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user