A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 59 of 59

Thread: Problems sending variable to XML Message

  1. #41
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    do you know that - on the test server - you can create various error conditions by using odd amounts, e.g. $5.01 => 'stolen card', $5.02 => 'not enough balance'. The actual cent amounts and the associated errors are somewhere in the docs
    You should probably go through these tests and see how the results are presented to a customer

  2. #42
    Offline
    Join Date
    Nov 2007
    Posts
    116
    that's excellent! thanks

    i'll start customising tonight and see how i go

    if it's ok with you, if i have any questions i'll let you know.

  3. #43
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Musicman the site works beautifully, client is over the moon the payment gateway is working now Thanks

    As I said, I may have a few questions, here's the first:

    If the order is approved, I need the customer redirected to a link where an swf will have text saying it's been approved and show their order number for future references.
    If the order is not approved, I need the customer redirected back to the swf, to frame 7 of the movie clip name "sprite 405".

    I know it's this area that must be modified but i'm not php savvy like you :/

    Code:
    if(eregi("yes", $approved))
    {       mail($admin, "Website order", "Order from:
    Name: $customer_name
           
    Ordered product for $payment_amount", "From: www.***********.com.au");
    }
    If they are approved, instead of having a seperate swf they can even be redirected to the same swf, but frame 8 of movie clip "sprite 405".

    Thanks!

  4. #44
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    probably you should switch from send() to sendAndLoad() in your movie, and change like that
    Code:
    reply = new LoadVars();
    reply.onLoad = function(success) {
        if(success) {
            if(this.approved == 'yes')
                 gotoAndStop(5);
        }
        gotoAndStop(4);
    }
    lv.sendAndLoad("..../payment.php", reply, "POST");
    Musicman

  5. #45
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Musicman,

    Thanks! Exactly what I was after and now it all runs through flash rather than opening that php window
    This is the last thing left to configure, instead of send the invoice in plain text looking very unprofessional..
    How can I have formatted HTML and company logo invoice with the variables inserted into it to then be sent to the customer?
    This is the current php:


    Code:
    if(eregi("yes", $approved))
    {       // Client Invoice
    mail($admin, "Website Order - Approved", "Invoice:
    
    Name: $customer_name1
    Address: $customer_address
    Address: $customer_address2
    Suburb: $customer_suburb
    State: $customer_state
    Postcode: $customer_postcode
    Telephone: $customer_telephone
    Email: $customer_email
    
    Baby's Name: $baby_name
    Date of Birth: $baby_dob
    Sex: $baby_sex
    Birth Time: $baby_birth_time
    Blood Type: $baby_blood_type
    Weight: $baby_weight
    Length: $baby_length
    Bithplace: $baby_birth_place
    
    Engraving? $engrave_chk
    Font: $font_chk
    
    Photo? $photo_chk
    File: $file_name
    
    Ordered ****** for $payment_amount", "From: www.******.com.au");
    
    
    //Customer Invoice
    
    mail($customer_email, "Website Order - Approved", "Hi,
    
    Congratulations and Thank you for your order.
    
    Your transaction has been approved and your medallion will be shipped within 1 business day. Please allow up to 3 days for delivery.
    
    Your invoice is below, if there are any errors please contact us immediately to make necessary changes.
    
    If you have any queries, you may use the online contact form.
    
    Alternatively you may contact us by phone, ******, or via email, ******.com.au
    
    Sincerely,
    
    
    ******
    Director
    __________
    
    Invoice:
    
    Name: $customer_name1
    Address: $customer_address
    Address: $customer_address2
    Suburb: $customer_suburb
    State: $customer_state
    Postcode: $customer_postcode
    Telephone: $customer_telephone
    Email: $customer_email
    
    Baby's Name: $baby_name
    Date of Birth: $baby_dob
    Sex: $baby_sex
    Birth Time: $baby_birth_time
    Blood Type: $baby_blood_type
    Weight: $baby_weight
    Length: $baby_length
    Bithplace: $baby_birth_place
    
    Engraving? $engrave_chk
    Font: $font_chk
    
    Photo? $photo_chk
    File: $file_name
    
    Ordered ****** for $payment_amount", "From: www.******.com.au");
    }
    Thanks!

  6. #46
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    have a look at that thread http://board.flashkit.com/board/show...ight=html+mail

    While you can probably go with a simpler solution (e.g. just put a content/type text/html headerand a html page), you should be aware that some spam filters might drop the mail in that case .... probably because, on the other hand, some spammers have a tendency to convey their messages as html with no plaintext version

    Musicman

  7. #47
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Thanks musicman, i'll have a read through it this evening and see how i go

    cheers

  8. #48
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Musicman that thread confused the hell out of me hehe
    no idea...

    can we go the simpler solution? client wants the customer to receive a receipt straight away and will also send one out in the post with their product.
    are you able to post up some HTML for the HTML page so it shows the variables and what code i'd have to put in php from here:

    Code:
    if(eregi("yes", $approved))
    {       // Client Invoice
    mail($admin, "Website Order - Approved", "Invoice:

  9. #49
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    it is quite obvious that, if you have a plain text version
    --------------
    Dear $name,

    thank you for purchasing $something
    spec1: $spec1
    spec2: $spec2

    The amount of $amount has been billed to your card account
    ------------
    The html version could be
    -------------
    <html>
    Dear $name,<br><br>
    Thank you for purchasing $something<br>
    <table>
    <tr><td>spec1</td><td>$spec1</td></tr>
    <tr><td>spec2</td><td>$spec2</td></tr>
    </table>
    <br>
    The amount of <b>$amount</b> has been billed to your card account
    </html>
    ------------------
    My point is that you should send your mail using a properly constructed mixed (text+plain) mail, the same format you would usually use when sending from your outlook or whatever program

    Musicman

  10. #50
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Tried including html in the payment.php but the order and receipt both did not go through..this is my test php code, please make necessary corrections:

    if(eregi("yes", $approved))
    { mail($customer_email, "Invoice", "<html><font = "tahoma"><b>Invoice:</b>
    <br>
    Name: $customer_name<br>
    Address: $customer_address<br>
    <p>Total Amount: $payment_amount </p></font></html>"

    Don't know where to put the quotes before/after the html tags...can you let me know what i'm doing wrong? Thanks musicman


    EDIT: I also tried putting the html and body tags at the top before the opening php tag
    I closed the tags at the bottom of the php

    Order and email went through, but receipt said <b>Invoice:</b>
    It didn't do the tags in html format only plain text?
    Last edited by supraicer69; 01-09-2008 at 11:19 AM.

  11. #51
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    if you have quotes within the quoted text, like here
    "<html><font = "tahoma"><b>Invoice:</b>
    you need to put backslashes there
    "<html><font = \"tahoma\"><b>Invoice:</b>

    Musicman

  12. #52
    Offline
    Join Date
    Nov 2007
    Posts
    116
    I tried the following...without using <font>

    mail($customer_email, "Website Order - Approved", "<html><b>Hi,

    Thank you for your order....

    </b></html>"

    order didn't go through and no receipt sent?
    if i remove the html tags it goes through?

  13. #53
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    order going through (or not) might be a problem with script error (like extra quote marks) in the php file.
    You can test by creating a html form with the same fields posting to the php file. You would expect "approved=no" (unless you make real payment) in the browser window for working script, or either blank screen or error message with line number for script error
    Be sure that your php tags are at the very start and end of the script.
    If it did send a receipt before, the order goes through, and no receipt is received, something does not like the mail

    Musicman
    Last edited by Musicman; 01-10-2008 at 01:57 AM.

  14. #54
    Offline
    Join Date
    Nov 2007
    Posts
    116
    approved=no

    no errors in the script, checked it a few times and no extra quotes

    i'll post exact script just taking out the merchant id and password and contact info:


    Code:
    <?php
    
    // Do not allow browser to cache this page.
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    
    // NOTE. Apache on Windows can generate the following warning: Warning: fgets(): SSL: fatal
    // protocol error in ...  This is not really fatal, so we set the following:
    error_reporting(E_ERROR | E_PARSE);
    
    /*
    SecureXML Example.
    ----------------------------
    This example is based on the SecureXML documentation and should be used in conjunction with
     that documentation. Please feel free to edit this code to suit your own requirements. This
     example comes with no warranty or support. Use at your own risk.
    */
    
    // the names here correspond to data fields in the actionscript
    $vars = array("card_number", "card_expiry", "card_cvv", "customer_name", "payment_amount", "customer_name1", "customer_address", "customer_address2", "customer_suburb", "customer_state", "customer_postcode", "customer_telephone", "customer_email", "baby_name", "baby_dob", "baby_sex", "baby_birth_time", "baby_blood_type", "baby_weight", "baby_length", "baby_birth_place", "engrave_chk", "font_chk", "photo_chk", "file_name");
    if(count($_POST))
    {       $ok = 1;
            foreach($vars as $var)
                    if(isset($_POST[$var]))
                            $$var = $_POST[$var];
                    else
                            $ok = 0;
            if($ok)
                    if ((!ereg('^[0-9]{13}$', $card_number) && !ereg('^[0-9]{16}$', $card_number)) || !ereg('^[0-9]{1,2}/[0-9][0-9]$', $card_expiry))
                            $ok = 0;
    }
    if(!$ok)
    {       print "&status=no&message=missing data&";
            exit;
    }
    
    // at this point we might have a valid request
    
    // $host = "www.securepay.com.au/xmlapi/payment";  // real
    $host = "www.securepay.com.au/test/payment";    // testing
    
    $merchant = "*******";
    $merchant_pass = "*******";
    $currency = "AUD";
    $admin = "*******";
                    
    $timestamp = getGMTtimestamp();
    $time = time();
    $messageid = md5($time . $name);
    // use current time for transaction id (order nr)
    $orderno = $time;
    
    $vars = 
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
    "<SecurePayMessage>" .
            "<MessageInfo>" .
                    "<messageID>$messageid</messageID>" .
                    "<messageTimestamp>" .urlencode($timestamp). "</messageTimestamp>" .
                    "<timeoutValue>60</timeoutValue>" .
                    "<apiVersion>xml-4.2</apiVersion>" .
            "</MessageInfo>" .
            "<MerchantInfo>" .
                    "<merchantID>$merchant</merchantID>" .
                    "<password>$merchant_pass</password>" .
            "</MerchantInfo>" .
            "<RequestType>Payment</RequestType>" .
            "<Payment>" .
                    "<TxnList count=\"1\">" .
                            "<Txn ID=\"1\">" .
                                    "<txnType>0</txnType>" .
                                    "<txnSource>23</txnSource>" .
                                    "<amount>" .str_replace(".", "", urlencode($payment_amount)
    ). "</amount>" .
                                    "<purchaseOrderNo>$orderno</purchaseOrderNo>" .
                                    "<currency>$currency</currency>" .
                                    "<CreditCardInfo>" .
                                            "<cardNumber>$card_number</cardNumber>" .
                                            "<cvv>$card_cvv</cvv>" .
                                            "<expiryDate>$card_expiry</expiryDate>" .
                                    "</CreditCardInfo>" .
                            "</Txn>" .
                    "</TxnList>" .
            "</Payment>" .
    "</SecurePayMessage>";
    
    $response = openSocket($host, $vars);
    
    $xmlres = array();
    $xmlres = makeXMLTree ($response);
    
    $statusDescription = trim($xmlres[SecurePayMessage][Status][statusDescription]);
    $approved = trim($xmlres[SecurePayMessage][Payment][TxnList][Txn][approved]);
    $responseCode = trim($xmlres[SecurePayMessage][Payment][TxnList][Txn][responseCode]);
    $responseText = trim($xmlres[SecurePayMessage][Payment][TxnList][Txn][responseText]);
    
    print "&status=ok&approved=$approved&code=$responseCode&text1=$statusDescription&text2=$responseText&";
    if(eregi("no", $approved))
    {       mail($admin, "Website Order - Declined", "Invoice:
    
    Name: $customer_name1
    Address: $customer_address
    Address: $customer_address2
    Suburb: $customer_suburb
    State: $customer_state
    Postcode: $customer_postcode
    Telephone: $customer_telephone
    Email: $customer_email
    
    Baby's Name: $baby_name
    Date of Birth: $baby_dob
    Sex: $baby_sex
    Birth Time: $baby_birth_time
    Blood Type: $baby_blood_type
    Weight: $baby_weight
    Length: $baby_length
    Bithplace: $baby_birth_place
    
    Engraving? $engrave_chk
    Font: $font_chk
    
    Photo? $photo_chk
    File: $file_name
    
    Ordered ******* for $payment_amount", "From: *******");
    
    mail($customer_email, "Website Order - Declined", "Hi,
    
    Thank you for your order, however your credit card has declined for the total of $payment_amount
    
    This could be due to a number of reasons:
    1. Insufficient funds
    2. You mistyped your card number or your card number is invalid
    3. Your card has expired
     
    We can also accept Money order, Cheque or Bank Deposit as a method of payment.
    
    If you have any queries, you may use the online contact form, contact us by phone, *******, or via email, *******
    
    Sincerely,
    
    
    *******
    Director", "From: *******");
    }
    
    if(eregi("yes", $approved))
    {       mail($admin, "Website Order - Approved", "Invoice:
    
    Name: $customer_name1
    Address: $customer_address
    Address: $customer_address2
    Suburb: $customer_suburb
    State: $customer_state
    Postcode: $customer_postcode
    Telephone: $customer_telephone
    Email: $customer_email
    
    Baby's Name: $baby_name
    Date of Birth: $baby_dob
    Sex: $baby_sex
    Birth Time: $baby_birth_time
    Blood Type: $baby_blood_type
    Weight: $baby_weight
    Length: $baby_length
    Bithplace: $baby_birth_place
    
    Engraving? $engrave_chk
    Font: $font_chk
    
    Photo? $photo_chk
    File: $file_name
    
    Ordered ******* for $payment_amount", "From: www.*******.com.au");
    
    mail($customer_email, "Website Order - Approved", "Hi,
    
    Congratulations and Thank you for your order.
    
    Your transaction has been approved and your medallion will be shipped within 1 business day. Please allow up to 3 days for delivery.
    
    Your invoice is below, if there are any errors please contact us immediately to make necessary changes.
    
    If you have any queries, you may use the online contact form.
    
    Alternatively you may contact us by phone, *******, or via email, *******
    
    Sincerely,
    
    
    *******
    Director
    __________
    
    Invoice:
    
    Name: $customer_name1
    Address: $customer_address
    Address: $customer_address2
    Suburb: $customer_suburb
    State: $customer_state
    Postcode: $customer_postcode
    Telephone: $customer_telephone
    Email: $customer_email
    
    Baby's Name: $baby_name
    Date of Birth: $baby_dob
    Sex: $baby_sex
    Birth Time: $baby_birth_time
    Blood Type: $baby_blood_type
    Weight: $baby_weight
    Length: $baby_length
    Bithplace: $baby_birth_place
    
    Engraving? $engrave_chk
    Font: $font_chk
    
    Photo? $photo_chk
    File: $file_name
    
    Ordered ******* for $payment_amount", "From: www.*******.com.au");
    }
    
    function getGMTtimeStamp()
    {
            $stamp = date("YmdGis")."000+1000";
            return $stamp;
    }
    
    /**************************/
    /* Secure Socket/cURL Function */
    /**************************/
    function openSocket($host,$query){
            // Break the URL into usable parts
            $path = explode('/',$host);
            $host = $path[0];
            unset($path[0]);
            $path = '/'.(implode('/',$path));
    
                    $ch = curl_init();
                    $header = array();
                    $header[] = "Content-type: text/xml";
                    curl_setopt($ch, CURLOPT_URL, "https://$host$path");
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);  
                    curl_setopt($ch, CURLOPT_POST, 1); 
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $query);           
    
                    $body = curl_exec($ch);
    
            // Close the socket
            curl_close($ch);
    
            // Return the body of the response
            return $body;
    }
    
    	function makeXMLTree ($data) {
    	   $output = array();
    	   
    	   $parser = xml_parser_create();
    
    	   xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    	   xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    	   xml_parse_into_struct($parser, $data, $values, $tags);
    	   xml_parser_free($parser);
    	   
    	   $hash_stack = array();
    	   
    	   foreach ($values as $key => $val)
    	   {
    		   switch ($val['type'])
    		   {
    			   case 'open':
    				   array_push($hash_stack, $val['tag']);
    				   break;
    		   
    			   case 'close':
    				   array_pop($hash_stack);
    				   break;
    		   
    			   case 'complete':
    				   array_push($hash_stack, $val['tag']);
    				   eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['value']}\";");
    				   array_pop($hash_stack);
    				   break;
    		   }
    	   }
    
    	   return $output;
       }
    ?>

  15. #55
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    when I tried sending to the same "payment.php" as before, I saw an error message about "output started on line 3". This could happen if there is any text before the starting php tag

    Musicman

  16. #56
    Offline
    Join Date
    Nov 2007
    Posts
    116
    <?php opening php tag is in line 1 on my end...

    try sending to the above php i pasted in my last post...can't include html for some reason :/

    just read this up...

    If you want to send email in html format instead of plain text for mat, just set Content-type = "text/html" in header. See the example script :

    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

    // Mail it
    mail($to, $subject, $message, $headers);


    but i'm sending text/xml...
    Last edited by supraicer69; 01-10-2008 at 06:32 AM.

  17. #57
    Offline
    Join Date
    Nov 2007
    Posts
    116
    Hi Musicman, any luck with further testing? I've tried everything I can think of yet it keeps sending the tags inplain text format
    ( <b> Thank you... </b> instead of Thank you... )

  18. #58
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    the error message is gone now, but I cannot send enough data ...
    I tried to set all fields as they appear above
    "card_number", "card_expiry", "card_cvv", .....
    but I just get "missing data" response. Maybe inability to type

    BTW: what is that filename variable used for?

    Musicman

  19. #59
    Offline
    Join Date
    Nov 2007
    Posts
    116
    the filename corresponds to the customers uploaded file

    they are given the option to upload a photo of max 1.5mb size to be put on the product

    variable "filename" is "www.theserver.com.au/images/customer_image.extension"

    can't figure out how to format the receipt in html! i code in html on a daily basis, just hardly any idea how to do it with php so it sends in html format instead of plain text.

    no luck on your end im guessing? haha
    Last edited by supraicer69; 01-13-2008 at 11:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center