Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

update MYsql Database once results return from payment centre

Engaged ,
Feb 06, 2013 Feb 06, 2013

I am working on the final part to a shopping cart, i have the return values coming through from the payment centre. But what i need to do now is pass the relevent information to my database to show the transaction status ...then in turn update the stock ( i know how to do this part)

the main variable i need is the $StatusCode ( for the particular payment system "0" means passed )

if this is successful this is

if ($StatusCode == "0")

any other values has failed and i just need to display a failed notification

I have a table in my database called Orders with a collumn called fullfilled this i where i want to update the $StatusCode value in to.

I can then make an if statement with the results based on the value of the column "fullfilled"

so i need to know how to update the table based on the results

thanks in advance

TOPICS
Server side applications
878
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 06, 2013 Feb 06, 2013

Not clear on what you want. Are you asking how to write a SQL update statement? A PHP IF condition?  I'm sure you must already know how to do these, so it must be something else you are after. Please be clear on exactly what you do not know how to do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 06, 2013 Feb 06, 2013

sorry, yes should have been more clear, yes i know how to write an update statement but i need to make an update statement based on the results of the return from the payment centre.

does that make sense?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 06, 2013 Feb 06, 2013

>does that make sense?

Not really - that's just a basic update statement so I'm still not sure where you are having trouble.

UPDATE myTable SET myColumn = '$statusCode' WHERE OrderID = 12

or use a sprintf statement with parameters. Let me know if you're still talking about something else.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 07, 2013 Feb 07, 2013
LATEST

Thats what i need to do but am a little confused how and where to put it. Basically i have the rest of the code from the return but dont know how to implement the update with the information i have.

<div class="<?= $MessageClass ?>">

          <div class="TransactionResultsItem">

                    <div class="TransactionResultsLabel">Payment Processor Response:</div>

                    <div class="TransactionResultsText">

                              <?= $Message ?>

                    </div>

          </div>

<?php if ($DuplicateTransaction == true) { ?>

          <div style="color:#000;margin-top:10px">

                    A duplicate transaction means that a transaction with these details

                    has already been processed by the payment provider. The details of

                    the original transaction are given below

          </div>

          <div class="TransactionResultsItem" style="margin-top:10px">

                    <div class="TransactionResultsLabel">

                              Previous Transaction Response:

                    </div>

                    <div class="TransactionResultsText">

                              <?= $PreviousTransactionMessage ?>

                    </div>

          </div>

<?php } ?>

<div style="margin-top:10px">

<hr/>

<?php

echo "<strong>Variables Passed Back From The Gateway</strong>";

echo "<hr/>";

echo "Message: " . $Message . "<br/>";

echo "Status Code: " . $StatusCode . "<br/>";

echo "Previous Status Code: ". $PreviousStatusCode . "<br/>";

echo "Previous Message: " . $PreviousMessage . "<br/>";

echo "Cross Referrence: " . $CrossReference . "<br/>";

echo "Card Type: " . $CardType . "<br/>";

echo "Card Class: " . $CardClass . "<br/>";

echo "Card Issuer: " . $CardIssuer . "<br/>";

echo "Card Issuer Country Code: " . $CardIssuerCountryCode . "<br/>";

echo "Amount: " . $Amount . "<br/>";

echo "Currency Code: " . $CurrencyCode . "<br/>";

echo "Order ID: " . $OrderID . "<br/>";

echo "Transaction Type: " . $TransactionType . "<br/>";

echo "Transaction Date Time: " . $TransactionDateTime . "<br/>";

echo "Order Description: " . $OrderDescription . "<br/>";

echo "Customer Name: " . $CustomerName . "<br/>";

echo "Address Line 1: " . $Address1 . "<br/>";

echo "Address Line 2: " . $Address2 . "<br/>";

echo "Address Line 3: " . $Address3 . "<br/>";

echo "Address Line 4: " . $Address4 . "<br/>";

echo "City: " . $City . "<br/>";

echo "State: " . $State . "<br/>";

echo "PostCode: " . $PostCode . "<br/>";

echo "Country Code: " . $CountryCode . "<br/>";

echo "Email Address: " . $EmailAddress . "<br/>";

echo "Phone Number: " . $PhoneNumber . "<br/>";

echo "<hr/>";

?>

</div>

          <div style="margin-top:10px">

                    <a href="index.html">Process Another</a>

          </div>

</div>

<!-- Database update using PHP -->

<?php

/*

$host="";

$user="";

$password="";

$database_connection = mysql_connect($host,$user,$password);

if (!$database_connection)

  {

  die('Could not connect: ' . mysql_error());

  }

if ($StatusCode == "0")

{

// Update database for successful transaction (status, stock etc)

}

else

{

// Update database for Failed transaction

}

*/

?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines