Using the smart button code

Tudsy
Contributor
Contributor

Hi

 

I generated the smart button code to put in my website. The smart button code is in the file process1.txt (attached) along with some php code.

When I run my program that calls process1.txt (php) I get a white screen.

 

The full code for process1.txt (php) is below:

 

<html>
<head>

<script src='https://code.jquery.com/jquery-3.6.1.min.js'></script>

</head>

<body>

<?php


if(!empty($_POST['Age'])){

$age =$_POST['Age'];

}


if ($age <= 13){

echo "You are under 13-You need parental consent to buy from this site. -";
echo "<a href='https://ecovib2d.com.au/index.php'> Back to my site </a>";
exit();

} // End of if age <= 13 block


if ($age > 13) {

 


include 'config.php';

$name = $_POST['Full_Name'];
$Email = $_POST['Email_Address'];


$graphic = $_POST['Graphic'];
$Price = $_POST['Price'];
$url = $_POST['Url'];
$today=time();
$Dateof = date('Y-m-d H:i:s T',strtotime('+0 day',$today));
$itemid = 0;

$con = mysqli_connect($servername,$user,$password,"ecovibdc_Subscribers");

// Check connection

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}

//add the information to the Crazy Domain database

$query = "INSERT INTO CustomersArt (idart,Email,Graphic,memberName,PriceofArt,Age,Dateof)
VALUES ('$itemid','$Email','$graphic','$name','$Price','$age','$Dateof')";

mysqli_query($con,$query);

mysqli_close($con);

} // End of if age > 13 block


?>

<input type = "hidden" id = "Cost" name="Price" value = "<?php echo $Price; ?>" />
<input type = "hidden" id = "pic" name="Graphic" value = "<?php echo $graphic; ?>" />
<input type = "hidden" id = "URL" name="Url" value = "<?php echo $url; ?>" />

<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>

<script src="https://www.paypal.com/sdk/js?client-id=AaLDmfGRW7SN2FObL3__zQAF3IR1uEO6MTjXToqY6JAgi4Vt6nsCQ-fWhuZ-..." data-sdk-integration-source="button-factory"></script>

<script>

function initPayPalButton() {

paypal.Buttons({
style: {
shape: "rect",
color: "gold",
layout: "horizontal",
label: "PayPal",

},

 

createOrder: function(data, actions) {

var graphic2 = document.getElementById("pic").value;
console.log(graphic2);

var Price2 = document.getElementById("Cost").value;
console.log(Price2);


return actions.order.create ({
purchase_units: [{"description":"Graphic from Ecovib2d: " + graphic2 ,"amount":{"currency_code":"AUD","value": Price2 }}]
});
},

onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {

// Full available details
console.log("Capture result", orderData, JSON.stringify(orderData, null, 2));

// Show a success message within this page, e.g.

const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';

var url2 = document.getElementById("URL").value;
console.log(url2);

actions.redirect(url2);

});
},

onError: function(err) {
console.log(err);
}
}).render("#paypal-button-container");
}

initPayPalButton();

</script>
</body>
</html>

Login to Me Too
2 REPLIES 2

Tudsy
Contributor
Contributor

HI

 

Just to add more information. The following programs are involved:

 

https://ecovib2d.com.au/workfromhome/yourart/yourart1.php      -> https://ecovib2d.com.au/workfromhome/yourart/form.php  --> https://ecovib2d.com.au/workfromhome/yourart/twoaction.php 

 

yourart1.php is the calling program and I have split the php and javascript code into two files (twoaction.php) 

Login to Me Too

MTS_Chiranjeevi
Moderator
Moderator

Good day @Tudsy,

 

Thank you for contacting PayPal community.

 

Our sincere apologies for the inconvenience caused.

 

I have tried to reproduce the issue by processing a test checkout via "Buy Now" button mentioned in https://ecovib2d.com.au/workfromhome/yourart/form.php  and the payment attempt failed due to the EWP_SETTINGS error code.

 

Screenshot 2022-11-18 at 1.05.51 PM.png

 

By default, you accept payments from both encrypted and unencrypted buttons. For added security, it may prevent buyers from sending you payments via unencrypted buttons.

 

After changing this setting, we will decline payments from customers who click on unencrypted "Buy Now", "Donate" or "Subscription" buttons. In those cases you will see the EWP_SETTINGS error message.

 

If you previously blocked payments from unencrypted buttons, here's how to accept all payments:

 

Login to PayPal.com> Settings> Account Settings> Website Payments> Website preferences > Encrypted website payments > Block non-encrypted website payment > select "Off".

 

Thank you so much for your patience and understanding.

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.