- added capacity in plugin tool to take urls
- test front end integration ok
This commit is contained in:
@@ -37,6 +37,7 @@ PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__)
|
||||
inclusions
|
||||
*/
|
||||
include_once(PLGNTLS_class::get_path() . '/php/utils/globals.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/utils/console_log.php');
|
||||
include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php');
|
||||
|
||||
//include_once(PLGNTLS_class::get_path() . '/php/images/image_edit_shortcode.php');
|
||||
@@ -183,6 +184,7 @@ add_action('template_redirect', 'check_paypal_request');
|
||||
|
||||
function paypal_shortcode_content()
|
||||
{
|
||||
$fipfcard_paypal = new PLGNTLS_class();
|
||||
/*
|
||||
<input type="hidden" name="custom" value="5678" />
|
||||
|
||||
@@ -203,62 +205,21 @@ function paypal_shortcode_content()
|
||||
$pp_sdk_attributes="src='$pp_sdk_src'";
|
||||
$pp_sdk_html_script="<script $pp_sdk_attributes></script>";
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<h1>old button :</h1>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
<input type="hidden" name="cmd" value="_s-xclick" />
|
||||
<input type="hidden" name="hosted_button_id" value="H876N9DGSCLKS" />
|
||||
<input type="hidden" name="currency_code" value="EUR" />
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Buy Now" />
|
||||
</form>
|
||||
<h1>new button :</h1>
|
||||
<script>console.log(<?php echo json_encode($pp_sdk_attributes, JSON_HEX_TAG) ?>);</script>
|
||||
<?php echo $pp_sdk_html_script; ?>
|
||||
<div id="paypal-button-container"></div>
|
||||
<p id="result-message"></p>
|
||||
<script>
|
||||
console.log("paypal:");
|
||||
console.log(paypal);
|
||||
|
||||
paypal.Buttons({
|
||||
style: {
|
||||
layout: 'vertical',
|
||||
color: 'blue',
|
||||
shape: 'rect',
|
||||
label: 'paypal',
|
||||
},
|
||||
// Order is created on the server and the order id is returned
|
||||
createOrder() {
|
||||
return fetch("/my-server/create-paypal-order", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
// Use the "body" param to optionally pass additional order information
|
||||
// such as product SKUs and quantities
|
||||
body: JSON.stringify({
|
||||
cart: [
|
||||
{
|
||||
sku: "YOUR_PRODUCT_STOCK_KEEPING_UNIT",
|
||||
quantity: "YOUR_PRODUCT_QUANTITY",
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((order) => order.id);
|
||||
}
|
||||
}).render('#paypal-button-container');
|
||||
|
||||
</script>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
return $fipfcard_paypal->add_to_front(
|
||||
array(
|
||||
$pp_sdk_src,
|
||||
"js/paypal/paypal.js",
|
||||
"html/paypal/paypal.html",
|
||||
),
|
||||
compact(
|
||||
),
|
||||
);
|
||||
}
|
||||
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content');
|
||||
|
||||
|
||||
|
||||
|
||||
//function my_custom_url_handler($query)
|
||||
//{
|
||||
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )
|
||||
|
||||
Reference in New Issue
Block a user