• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "PHP email string problem"

Collapse

  • NickFitz
    replied
    Originally posted by xoggoth View Post
    Hey! urlencode the sent string, urldecode the received string works! Any sane person would imagine the string would end up as it was!

    Anyway cheers Nick (again). Definitely going for a drink now.

    Leave a comment:


  • xoggoth
    replied
    Hey! urlencode the sent string, urldecode the received string works! Any sane person would imagine the string would end up as it was!

    Anyway cheers Nick (again). Definitely going for a drink now.

    Leave a comment:


  • NickFitz
    replied
    In the callback, try

    PHP Code:
    $description urldecode($_POST['description']); 
    (or whatever). Although it seems a bit odd that they send back the URL encoded version, presumably double-encoded if PHP's automatic processing is decoding it to the encoded version

    Leave a comment:


  • xoggoth
    replied
    Cheers again. urlencode does ensure sending of the full text but this is a plain text email, so now the customer gets:

    1+Plant+Guides+Pack+%26pound%3B11.50+each%2C+total ++%26pound%3B11.50+%0D% etc

    The way a WP callback normally works is pretty simple, you post a value to Worldpay eg:

    <form name="order" action="https://secure.worldpay.com/wcc/purchase" method=post>
    <input type="text" name="name">
    etc

    and then process their callback exactly as if it had been submitted directly from your form eg:

    <?php
    $name = $_POST['name']

    I had no problems at all creating variables with my jscript cart but having trouble doing what appears to be exactly the same darn thing in PHP!

    Anyway, its Friday, off to the village club. Ta very much all. You are dismissed for now, will rehire you (for unpaid work experience) on Monday.

    Leave a comment:


  • NickFitz
    replied
    Originally posted by mudskipper View Post
    Looks like different languages do different things...

    http - URL encoding the space character: + or %20? - Stack Overflow
    Either way, PHP's urlencode() uses + for space, which is almost certainly what WorldPay wants

    Leave a comment:


  • mudskipper
    replied
    Looks like different languages do different things...

    http - URL encoding the space character: + or %20? - Stack Overflow

    Leave a comment:


  • NickFitz
    replied
    Originally posted by mudskipper View Post
    From: http://www.worldpay.com/support/kb/bg/pdf/rhtml.pdf



    Is this the mechanism you're using? Looks like you need + for space as doodab suggested. (I always thought URLEncode stuck in %20?)
    I just checked with:

    PHP Code:
    <?php
    $foo 
    = array("foo""bar bar");
    $bar 1;
    echo 
    urlencode("blah $foo[$bar]\n");
    ?>
    and got the output:

    Code:
    blah+bar+bar%0A

    Leave a comment:


  • mudskipper
    replied
    From: http://www.worldpay.com/support/kb/bg/pdf/rhtml.pdf

    URL Order Details String

    You do not have to use an HTML form to create and submit order details, or to integrate - you
    can also submit order details in a URL string. For example, you can integrate with this single
    URL string:

    https:// secure-test.worldpay.com/wcc/purchase?instId=123456&cartId=WorldPay+Test&amount =40.00&currency=GBP&desc=WorldPay+Test&testMode=10 0

    As with form-based submissions, the URL order details string must contain the four
    mandatory parameters, as shown in the example.
    Is this the mechanism you're using? Looks like you need + for space as doodab suggested. (I always thought URLEncode stuck in %20?)

    (Edit: I added the space after the // to stop it from being turned into a link...)
    Last edited by mudskipper; 15 November 2013, 18:25.

    Leave a comment:


  • doodab
    replied
    Is it submitted as a URL? Do you need to encode the spaces as + signs?

    Leave a comment:


  • NickFitz
    replied
    Originally posted by xoggoth View Post
    Ta for comments but that ain't it. I deliberately put the 1st item in quotes to fix the same problem with my own email code and it did, just not working with the Worldpay callback email. Really don't need the . as just put vars in the string but that has the same problem, this also stops at first space and just shows 3

    $description .= "$num[$i] $descs[$i] $fprice[$i] each, total = $fcost[$i] \r\n";

    If I put:

    $description .= "$num[$i]xxx$descs[$I]yyy$fprice[$i] each, total = $fcost[$i] \r\n";

    I get xxx1yyyBird, it stops at the next space instead.
    Is there anything in the WorldPay docs about escaping spaces? If it's being sent as part of a URL you'll need to use URL encoding, e.g. add

    PHP Code:
    $description urlencode($description); 
    after you've built the string to get the value to use. Dunno if that's right though; check their documentation for anything along those lines.

    As it happens I spent May to September this year contracting in the same building as WorldPay on Cambridge Science Park; if I was still there I could just stop people in reception and ask them until I found somebody who knew. But I'm not there any more, so I can't. Ho hum

    Leave a comment:


  • xoggoth
    replied
    Ta, but tried that as said in previous. Only way I can get it through WP callback is with all spaces replaced by #, newlines by ## and change 'em all back when it reaches my code. Messy.

    Leave a comment:


  • NickFitz
    replied
    Originally posted by Bunk View Post
    I'm no expert in PHP but haven't you got double quotes around the first variable?

    Shouldn't it be:

    PHP Code:
    $description .= $num[$i]." ".$descs[$i]." ".$fprice[$i]." each, total = ".$fcost[$i]." \r\n"
    PHP interpolates variable values for references in double-quoted strings: PHP: Strings - Manual

    However this means it's unnecessary to do the concatenations. The following should work, and is easier to read:

    PHP Code:
    $description .= "$num[$i] $descs[$i] $fprice[$i] each, total = $fcost[$i] \r\n"
    Not sure if this will help solve xog's problem though

    Leave a comment:


  • xoggoth
    replied
    Ta for comments but that ain't it. I deliberately put the 1st item in quotes to fix the same problem with my own email code and it did, just not working with the Worldpay callback email. Really don't need the . as just put vars in the string but that has the same problem, this also stops at first space and just shows 3

    $description .= "$num[$i] $descs[$i] $fprice[$i] each, total = $fcost[$i] \r\n";

    If I put:

    $description .= "$num[$i]xxx$descs[$I]yyy$fprice[$i] each, total = $fcost[$i] \r\n";

    I get xxx1yyyBird, it stops at the next space instead.

    Leave a comment:


  • petergriffin
    replied
    Originally posted by Bunk View Post
    I'm no expert in PHP but haven't you got double quotes around the first variable?

    Shouldn't it be:

    PHP Code:
    $description .= $num[$i]." ".$descs[$i]." ".$fprice[$i]." each, total = ".$fcost[$i]." \r\n"
    Actually yes, this is better.

    Haven't done php for ages.

    Leave a comment:


  • Bunk
    replied
    I'm no expert in PHP but haven't you got double quotes around the first variable?

    Shouldn't it be:

    PHP Code:
    $description .= $num[$i]." ".$descs[$i]." ".$fprice[$i]." each, total = ".$fcost[$i]." \r\n"

    Leave a comment:

Working...
X