wip paypal with sdk not working

This commit is contained in:
asus
2024-02-22 20:30:01 +01:00
parent 1046390f59
commit 45532c497d
2 changed files with 49 additions and 14 deletions

View File

@@ -164,10 +164,10 @@ add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
function check_paypal_request()
{
error_log("----");
if (is_page('paypal_ok'))
error_log("on paypal_ok");
else if (is_page('paypal_infos'))
error_log("on paypal_infos");
if (is_page('test_paypal_ok'))
error_log("on test_paypal_ok");
else if (is_page('test_paypal_infos'))
error_log("on test_paypal_infos");
else
return;
error_log("_GET");
@@ -179,22 +179,57 @@ add_action('template_redirect', 'check_paypal_request');
function paypal_shortcode_content()
{
$pp_live_client_id = "Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO";
$pp_sandbox_client_id = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
$pp_client_id = $pp_live_client_id;
$pp_client_id = $pp_sandbox_client_id;
$pp_sdk_currency = "EUR";
$pp_sdk_debug = "true";
$pp_sdk_base_url="https://www.paypal.com";
$pp_sdk_base_url="https://sandbox.paypal.com";
$pp_sdk_client_token="abc123xyz==";
$pp_sdk_src="$pp_sdk_base_url/sdk/js?client-id=$pp_client_id&currency=$pp_sdk_currency&debug=$pp_sdk_debug";
$pp_sdk_attributes="src='$pp_sdk_src' data-client-token='$pp_sdk_client_token'";
ob_start();
?>
<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="83KQ9F8BSP7NQ" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="image" src="https://www.paypalobjects.com/fr_XC/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" title="PayPal, votre réflexe sécurité pour payer en ligne." alt="Acheter" />
</form>
<?php
?>
<script <?php echo $pp_sdk_attributes ?> ></script>
<div id="paypal-button-container"></div>
<p id="result-message"></p>
<script>
paypal.Buttons({
// 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();
}
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content');
//function my_custom_url_handler($query)
//{
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )

Submodule private updated: 498434c7fc...926bb3b415