wip paypal with sdk not working
This commit is contained in:
@@ -164,10 +164,10 @@ add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
|
|||||||
function check_paypal_request()
|
function check_paypal_request()
|
||||||
{
|
{
|
||||||
error_log("----");
|
error_log("----");
|
||||||
if (is_page('paypal_ok'))
|
if (is_page('test_paypal_ok'))
|
||||||
error_log("on paypal_ok");
|
error_log("on test_paypal_ok");
|
||||||
else if (is_page('paypal_infos'))
|
else if (is_page('test_paypal_infos'))
|
||||||
error_log("on paypal_infos");
|
error_log("on test_paypal_infos");
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
error_log("_GET");
|
error_log("_GET");
|
||||||
@@ -179,22 +179,57 @@ add_action('template_redirect', 'check_paypal_request');
|
|||||||
|
|
||||||
function paypal_shortcode_content()
|
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¤cy=$pp_sdk_currency&debug=$pp_sdk_debug";
|
||||||
|
$pp_sdk_attributes="src='$pp_sdk_src' data-client-token='$pp_sdk_client_token'";
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
<script <?php echo $pp_sdk_attributes ?> ></script>
|
||||||
<input type="hidden" name="cmd" value="_s-xclick" />
|
<div id="paypal-button-container"></div>
|
||||||
<input type="hidden" name="hosted_button_id" value="83KQ9F8BSP7NQ" />
|
<p id="result-message"></p>
|
||||||
<input type="hidden" name="currency_code" value="EUR" />
|
<script>
|
||||||
<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" />
|
paypal.Buttons({
|
||||||
</form>
|
// Order is created on the server and the order id is returned
|
||||||
<?php
|
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 ob_get_clean();
|
||||||
|
|
||||||
}
|
}
|
||||||
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content');
|
add_shortcode('fipf_paypal_shortcode', 'paypal_shortcode_content');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//function my_custom_url_handler($query)
|
//function my_custom_url_handler($query)
|
||||||
//{
|
//{
|
||||||
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )
|
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )
|
||||||
|
|||||||
2
private
2
private
Submodule private updated: 498434c7fc...926bb3b415
Reference in New Issue
Block a user