The user has an email with a link from my organisation.
This link goes direct to my account https://mdepayments.epdq.co.uk/ncol/test/
i.e. it does not reference my organisation's website first.
This is all on the Test environment not Live (real money).
I am trying to use parameters after the url as html email may sometimes not be allowed by a user.
I've not found example code on how to do this.
I was given some pseudo code originally from EPDQ.
Sample url
https://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp?
amount=12500&
CURRENCY=PND&
LANGUAGE=en_US&
OrderID=order123_001&
PSPID=XXXXX
SHASIGN=XXXX0C75B23EDBAE523E165176882C19BEACB7E7DEB38955224186BC66C2678FEEA4E4CA2512789001CC7A4E68XXXX3EFD35242BFEFBB7B1D4D7E19CBE80XXXX
(SHASIGN some chars changed to XXXX &PSPID changed to XXXXX for security)
Webpage result
<--------start---------->
Payment confirmation
>
> Order reference : order123_001 Total charge : --- Beneficiary
> : ---
>
> An error has occurred; please try again later. If you are the owner or
> the integrator of this website, please log into the Barclaycard back
> office to see the details of the error.
<--------end--------->
I used this code to generate the SHA
<?php
//- integration user details - //
$PW ="16char_SHA_code";
$PSPID = "XXXXX";
$OrderID ="order123_001";
$PaymentAmount =12500;
$CurrencyCode ="GBP";
$DigestivePlain =
"AMOUNT=" . $PaymentAmount . $PW .
"CURRENCY=" . $CurrencyCode . $PW .
"LANGUAGE=en_US" . $PW .
"ORDERID=" . $OrderID . $PW .
"PSPID=" . $PSPID . $PW .
"";
$strHashedString_plain = strtoupper(hash('sha512',($DigestivePlain)));
print $strHashedString_plain;
?>
I have a working HTML form which goes through my organisation website. It allows the user to enter details and a successful payment is made by EPDQ.
$DigestivePlain is based on a EPDQ example and works on my HTML form.
This PHP is to generate the SHASIGN
<?php
//- integration user details - //
$PW ="MyShaInPassPhrase";
$PSPID = "MyPSPID";
$OrderID ="order123_001";
$PaymentAmount =12500;
$CurrencyCode ="GBP";
//important to order alphabetically
$DigestivePlain =
"AMOUNT=" . $PaymentAmount . $PW .
"CURRENCY=" . $CurrencyCode . $PW .
"LANGUAGE=en_US" . $PW .
"ORDERID=" . $OrderID . $PW .
"PMLISTTYPE=2". $PW .
"PSPID=" . $PSPID . $PW .
"";
$strHashedString_plain = strtoupper(hash('sha512',($DigestivePlain)));
print $strHashedString_plain;
?>
Now the url
PSPID: 5 character PSPID (not XXXXX)
SHASIGN - created by php code above 128 characters (not YYYY...)
https://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp
?AMOUNT=12500&CURRENCY=GBP&LANGUAGE=en_US&ORDERID=order123_001&PMLISTTYPE=2&PSPID=XXXXX&
SHASIGN=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
This took me to the EPDQ Card selection screen and then on to the payments screen and a successfull transaction.
Related
My QuickBooks Online Application needs to create a Service Item in a QuickBooks Account.
When creating a Service Item through QBO API, I need to query the account for ExpenseAccountRef.Name, ExpenseAccountRef.Value, IncomeAccountRef.Name and IncomeAccountRef.Value first. How can this be done?
I have tried running the following query first but it simply:
$table = "Account";
$entities = $dataService->Query("Select * from $table");
$error = $dataService->getLastError();
if ($error) {
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
echo "The Response message is: " . $error->getResponseBody() . "\n";
exit();
}
But it does not provide any of the fields I need listed above.
I'm fetching a Webhook that is coming from Braintree. The Webhook is return a success and also creates the log file. This is the code I'm using:
if( isset($_POST["bt_signature"]) && isset($_POST["bt_payload"])){
$webhookNotification = \Braintree_WebhookNotification::parse(
$_POST["bt_signature"], $_POST["bt_payload"]
);
$message = "[Webhook Received "
. $webhookNotification->timestamp->format('Y-m-d H:i:s') . "] "
. "Kind: " . $webhookNotification->kind . " | "
. "Payment ID: " . $webhookNotification->localPaymentCompleted->paymentId . "\n";
file_put_contents("/tmp/webhook.log", $message, FILE_APPEND);
// if everything went fine, send confirmation to the buyer
$this->artikelRepository->sendConfirmationAction(null, $webhookNotification->localPaymentCompleted->paymentId);
}
To confirm the payment I need the paymentId of the local payment. I tried with various methods, but this should work: $webhookNotification->localPaymentCompleted->paymentId according to the test file.
The log file returns this, though:
How am I able to retrieve the Payment ID of a local payment inside the webhook function?
Update: I just noticed that we used a totally outdated SDK. The functions we tried to use were not even added in the old version.
Here is my code
$user_id = $_GET["user_id"];
$user = get_user_by('id',$user_id);
$balance = mycred_get_users_balance($user_id);
$user_info = get_userdata($user_id);
$first_name = $user_info->first_name;
$last_name = $user_info->last_name;
echo $first_name;
if ($balance > "0") {
mycred_subtract( 'Check-in',$user_id, -1, 'Checked in.' );
echo "Welcome " .$first_name." ".$last_name. "You are checked in.";
}
else{ echo "Welcome " .$first_name." ".$last_name;
echo "<br/>";
echo "You have a balance of " . $balance . ".";
echo "<br/>";
echo "Please purchase more credits at our website
I am trying to display the User first name and last name, this was working previously on my wordpress website, now the $user object is empty I'm quite sure because nothing is being echoed.
I am able to parse the $user_id from the URL and echo it, but when I try to echo the $first_name, get nothing.
I do get
Welcome You are checked in
Hence I know that the get_user_by is not working, the $user_id DOES exist in the database, I'm testing #1 which is my ID.
I feel like it is something to do with a mobile optimization because we are scanning a QR code to redirect to this page and passing the user_id through the URL.
EDIT* I switched off JetPack smartphone optimization and got the functions working, except still no $first_name
Any ideas???
So it turns out I did not have a field stored as $first_name as I updated the registration form. I changed the $first_name to call for $user_nicename instead and it shows the users account display name.
I am writing plugin which sends coupon code for every X spent at shop and this feature works pretty well but I have troubles with sending coupon to a new registered user.
Sending mail function (XYZ here on purpose):
function sendFirstVoucher($to_email, $discount, $name, $coupon){
$headers = 'From: XYZ' . "";
$subject = 'Your ' . $discount . '% discount voucher for XYZ';
$message = 'Hi . ' . $name . 'and thank you for registering with XYZ! \r\n\r\n' .
"blah blah blah " . $coupon . " when you check out on our website, you can apply the code in either the cart page or check out page. \r\n\r\n" .
"From now on when you make purchases you will also receive additional discount codes for every $100 spent. More information can be found at our website (link to membership program page). \r\n" .
"If you have any questions please feel free to contact us at XYZ \r\n\r\n" .
"Kind Regards, \r\nThe XYZ";
wp_mail($to_email, $subject, $message, $headers);
}
And in the main plugin file:
function send_coupon_to_freshly_registered_user($customer_id, $new_customer_data, $password_generated) {
$coupon_code = generateCoupon(5);
$user_email = $new_customer_data["user_email"];
$user_login = $new_customer_data["user_login"];
sendFirstVoucher($user_email, "5", $user_login, $coupon_code);
}
finally at the nearly end of file there is:
add_action('woocommerce_created_customer', 'send_coupon_to_freshly_registered_user',10,3);
But once I am creating user via dashboard or register myself via wp-login page (because site is in maintenace mode) it's not sending any email nor creating coupon (it works perfectly for similar function for X voucher per 100$)
Have anyone got idea how to acomplish this?
Kind regards,
Tom
Ok, I have achieved this by using core wp functions:
add_action('user_register', 'send_coupon_to_freshly_registered_user',10,1);
function send_coupon_to_freshly_registered_user($user_id) {
$user = get_user_by('id',$user_id); //new line
$user_login = stripslashes($user->user_login); //changed line
$user_email = stripslashes($user->user_email); //changed line
$coupon_code = generateCoupon(5);
sendFirstVoucher($user_email, "5", $user_login, $coupon_code);
}
I hope it will help someone. Maybe it's not a real answer but the one that works for me.
Regards,
Tom
I am trying to create a web page using php. The problem is that sometimes I get server errors and sometime I get nothing in return at all. At one point the server changed the file type itself. I have NO idea what the problem can be.
And since I have actually no idea what the problem is I paste the entire file here, even though I expect that it's the first few rows that is the problem (I put it here: http://www.iandapp.com/smic/subscription.php) :
<?php header('Content-Type: text/html; charset=ISO-8859-1');
echo("<div id='subscribe'>");
$mail = $_POST['email1'];
//Set the locale format, etc. of date and time
date_default_timezone_set('Europe/Stockholm');
setlocale(LC_TIME, "sv_SV");
//Create the db-connection
$mysqli = mysqli_connect("mydb", "myuser", "mupsw", "myschema", "3306");
//If verifying the subscription, makse sure the db is updated accordingly
if($_GET['newid'] != ""){
//Make the subscriber a verified subscriber
$result = mysqli_query($mysqli,"UPDATE users SET subscriber = 1 WHERE id = " . $_GET['newid']);
if($result){
echo("<p>Welcome to our newsletter! We will send you information about any new application or update. This will not happen too often, but once it does we hope you will have the opportunity to look into our site again.<p/>");
echo("<p><br/>If you wish to unsubscribe from this mail-list, please visit out subscription page: http://" . $_SERVER['HTTP_HOST'] . "/subscription.php <p/>");
}else{
echo("<p>Somthing went wrong, please click the link again!<p/>");
}
}elseif($_POST['email1'] != ""){ //Only do things if there is an e-mail posted
//Make sure the ID is unique
do{
$rand_int = rand(100000000, 999999999);
$result = mysqli_query($mysqli, "SELECT id FROM users WHERE id = " . $rand_int);
$no_of_rows = mysqli_num_rows($result);
}while($no_of_rows != 0);
echo("RAND :".$rand_int);
//Create query for saving the new user e-mail
$query = "INSERT INTO users(id, email, first_name, surname) VALUES ('" . $rand_int . "', '".$_POST['email1']."', '". $_POST['first_name']."','".$_POST['surname']."')";
$re = mysqli_query($mysqli, $query);
echo("Result: ".$re);
//Check if mail already exist (Error code 1062 = dublicate entries for unique fields)
$existing = 0;
if(mysqli_errno($mysqli)==1062){
echo("It seems like your e-mail already is registered. Perhaps you have been a subscriber earlier? By clicking the link that you will receive in your mail box you subscribe to the newsletter again. ");
$existing = 1;
$result = mysqli_query($mysqli,"SELECT id FROM users WHERE email = '" . $_POST['email1'] . "'");
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$rand_int = $row['id'];
mysqli_query($mysqli,"UPDATE users SET waiting_for_unsubscribe = 0 WHERE email = '" . $_POST['email1'] . "'");
if(mysqli_errno($mysqli)){
echo("Error code " . mysqli_errno($mysqli) . "<br/>");
echo("Error text " . mysqli_errno($mysqli) . "<br/>");
}
//echo("ID------ " . $row['id'] . " ri---- " . $rand_int);
}
//Create the link for the user to verify the subscription
$url = "http://" . $_SERVER['HTTP_HOST'] . "/smic/subscription.php?newid=" . $rand_int;
$mymail = $_POST['email1'];
$esubject = "Please verify your subscription to iAndApp's newsletter ";
$body = "Click the link in order to verify your subscription (If you cannot click the link, just copy it and paste it into the adress field of your browser): " . $url;
$eemail = "NoReply#iandapp.com";
$sent = mail($mymail,$esubject,$body,"From: $eemailn");
if($sent){
if($existing != 1){
echo "<br/>An e-mail with a link has been sent to ". $mymail . ". Please click the link in order to verify your subscription";
}
}else{
echo "Something went wrong. Please try again and make sure you enter a correct e-mail adress.";
}
$existing = 0;
mysqli_free_result($result);
//If unsubscribing
}elseif($_POST['unsubscribedmail'] != ""){
//echo("Unsubscribe........");
//echo($_POST['unsubscribedmail']);
$result = mysqli_query($mysqli,"UPDATE users SET waiting_for_unsubscribe = 1 WHERE email = '" . $_POST['unsubscribedmail'] . "'");
//echo("Err code " . mysqli_errno($mysqli));
//echo("Err text " . mysqli_error($mysqli));
if(mysqli_errno($mysqli)){
echo("Error code " . mysqli_errno($mysqli) . "<br/>");
echo("Error text " . mysqli_errno($mysqli) . "<br/>");
}
$result = mysqli_query($mysqli,"SELECT id FROM users WHERE email = '" . $_POST['unsubscribedmail'] . "'");
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
//echo("ID------ " . $row['id']);
//Create the link for the user to verify that he/she unsubscribes
$url = "http://" . $_SERVER['HTTP_HOST'] . "/smic/subscription.php?unsubscribeid=" . $row['id'];
$mymail = $_POST['unsubscribedmail'];
$esubject = "Please verify that you want to unsubscribe from iAndApp's newsletter ";
$body = "Click the link in order to verify that you want to unsubscribe from iAndApp's newsletter (If you cannot click the link, just copy it and paste it into the adress field of your browser): " . $url;
$eemail = "NoReply#iandapp.com";
$sent = mail($mymail,$esubject,$body,"From: $eemailn");
if ($sent) echo "<br/>A mail with a link has been sent to ". $mymail . ". Please click the link in order to verify that you will unsubscribe from the newsletters.";
else echo "Something went wrong. Please try again and make sure you enter a correct e-mail adress.";
mysqli_free_result($result);
}elseif($_GET['unsubscribeid'] != ""){
$result = mysqli_query($mysqli,"UPDATE users SET subscriber = 0, waiting_for_unsubscribe = 0 WHERE id = " . $_GET['unsubscribeid']);
if($result){
echo("<p>You have now unsubscribed to the newsletter. Thank you for this time and we hope to see you again in the future. /iAndApp.<p/>");
}else{
echo("<p>Somthing went wrong, please click the link again!<p/> ".$result);
}
}else{
echo("<div class="subscribe">
<h4>Subscribe</h4>
<p>Subscribe to iAndApp's newsletter in order to get information about new and updated iPhone games and iPhone applications, that has been released by iAndApp. </p>
<form action="subscription.php" name="subscribe" method="post" onsubmit="return isValidEmailAndEqual()">
<p class="formlabel">Förnamn</p> <input type="text" name="first_name"/><br/>
<p class="formlabel">Efternamn</p> <input type="text" name="surname"/> <br/>
<p class="formlabel">E-mail</p> <input type="text" name="email1"/>
<br/>
<p class="formlabel">Repeat e-mail</p> <input type="text" name="email2"/> <br/>
<input class="inputsubmit" type="submit" value="Subscribe"/>
</form>
</div>");
echo("<div class="footer"></div>");
echo("<div class="subscribe">
<h4>Unsubscribe</h4>
<p>Fill in your e-mail address and submit in order to unsubscribe from iAndApp's newsletter. </p>
<form action="subscription.php" name="unsubscribe" method="post" onsubmit="return isValidEmail()">
<p class="formlabel">E-mail</p> <input type="text" name="unsubscribedmail"/><br/>
<input class="inputsubmit" name="submitbutton" type="submit" value="Unsubscribe"/>
</form>
</div>");
}
mysqli_close($mysqli);
echo("</div>");
?>
Of course, I don't expect you to go through and debug the entire application, but perhaps for the more expreienced folks out there, you know where to look.
I'm starting to get a bit stressed out here...
Please advice what the problem is and how I can solve it.
Thank you in advance!
eror in code:
echo("<div class="subscribe">
<h4>Subscribe</h4>
<p>Subscribe to i
in 1-st line you just close the string by 2-nd quote
you just need to correct code
You have to escape double quotes inside html tags or use single quotes. Right now, echo thinks it's closed after "<div class=". Use one of these:
echo "<div class=\"class\">";
or
echo '<div class="class">';
or
echo "<div class='class'>";
If you dont get any reposne from server (document is clear) or you have server errors but this is not all the time and sometimes script works fine it could be memory limit problem.
do{
$rand_int = rand(100000000, 999999999);
$result = mysqli_query($mysqli, "SELECT id FROM users WHERE id = " . $rand_int);
$no_of_rows = mysqli_num_rows($result);
}while($no_of_rows != 0);
This part of code dosn't look good for me, I suggest you to use auto_increment at id field in db (so id will be unique all the time)