- wip payment
- already solved success and failure messages and redirection - solved increase date multiple times - users redirection works if error AND partner to posts instead of project
This commit is contained in:
@@ -42,36 +42,36 @@ add_action('template_redirect', 'check_paypal_request');
|
||||
/**
|
||||
* call to paypal_shortcode_content()
|
||||
*/
|
||||
function fipf_paypal_shortcode_content()
|
||||
function paypal_shortcode_content_FIPF()
|
||||
{
|
||||
$fipfcard_paypal = new PLGNTLS_class();
|
||||
|
||||
$pp_sdk_currency = "EUR";
|
||||
$pp_sdk_debug = "true";
|
||||
$pp_sdk_base_url="https://sandbox.paypal.com";
|
||||
$pp_sdk_base_url="https://www.paypal.com";
|
||||
// $pp_sdk_client_token="abc123xyz==";
|
||||
$pp_sdk_src="$pp_sdk_base_url/sdk/js?client-id=" . PAYPAL_CLIENT_ID . "¤cy=$pp_sdk_currency&debug=$pp_sdk_debug";
|
||||
$pp_sdk_src="$pp_sdk_base_url/sdk/js?client-id=" . PAYPAL_CLIENT_ID ;
|
||||
// $pp_sdk_attributes="src='$pp_sdk_src' data-client-token='$pp_sdk_client_token'";
|
||||
// $pp_sdk_attributes="src='$pp_sdk_src'";
|
||||
// $pp_sdk_html_script="<script $pp_sdk_attributes></script>";
|
||||
$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_src,
|
||||
// 'js/paypal/result_message.js',
|
||||
// 'js/paypal/create_order.js',
|
||||
// 'js/paypal/on_approve.js',
|
||||
//"js/paypal/paypal.js",
|
||||
$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', 'fipf_paypal_shortcode_content');
|
||||
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content_FIPF');
|
||||
|
||||
|
||||
|
||||
@@ -79,32 +79,32 @@ add_shortcode('fipf_paypal_shortcode', 'fipf_paypal_shortcode_content');
|
||||
/**
|
||||
* 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 fipf_add_id_to_script( $tag, $handle, $src ) {
|
||||
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', 'fipf_add_id_to_script', 10, 3 );
|
||||
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 fipf_routes_endpoints()
|
||||
function routes_endpoints_FIPF()
|
||||
{
|
||||
$base_rest_route = "fipf_plugin/api/v1";
|
||||
register_rest_route($base_rest_route, '/orders', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'fipf_handle_orders_request',
|
||||
'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' => 'fipf_handle_orders_capture_request',
|
||||
'callback' => 'handle_orders_capture_request_FIPF',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'fipf_routes_endpoints');
|
||||
add_action('rest_api_init', 'routes_endpoints_FIPF');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user