Form Processing Question after Credit Card Approval

Posted on 2007-08-01
Last Modified: 2011-09-20
I have a php (I think question) Here is the scenario.
I have an order form for my widget product. A customer orders 1 widget for $10. She complete the order form and on submit is taken to the payment information form where she completes the credit card information.
She complete all the credit card and customer information and hits submit, the form is sent (securly) to a file called PROCESSOR.PHP which lives on the payment processor server (I am using USAepay). During this processing time I want the user to see a message that says "We are processing your card". PROCESSOR.PHP  is doing all the work sending the credit card information  out for approval. If approved, PROCESSOR.PHP is still incontrol and  I have a redirect statement that sends the customer to a success/thankyou page. BUT at the same time I want to send myself an email telling me that so-and-so custome purchased 1 widget for $10 and include the customer information AND I want a custom email receipt sent to the customer. My gateway processor has an automatic confirmation but I would like it to to be more friendly. I have uploaded the processor.php file (without any secure information) to
Question by:MarleneAyers
    LVL 9

    Expert Comment

    Can you upload that again?  I'm getting a 404 trying to view it.

    Author Comment

    Sorry. I had made a copy and then fogot to rename. I am anxious to see your response.

    Author Comment

    I think I am better off just pasting the code here.
    $tran=new umTransaction;
    $tran->card=$_POST['xxx'];            // card number, no dashes, no spaces
    $tran->exp=$_POST['xxxx'];                  // expiration date 4 digits no /
    $tran->amount="1.00";                  // charge amount in dollars (no international support yet)
    $tran->invoice="1234";               // invoice number.  must be unique.
    $tran->cardholder=$_POST['xxxxxx'];       // name of card holder
    $tran->street=$_POST['xxxxxx'];      // street address
    $tran->zip=$_POST['xxxxxxx'];                  // zip code
    $tran->description="Online Order";      // description of charge
    $tran->cvv2=$_POST['xxxxxx'];                  // cvv2 code      
    echo "<h1>Please Wait One Moment While We process your card.<br>\n";
              header ("Location: $URL");
    else {

          header ("Location: $URL");

    LVL 13

    Accepted Solution

    Ok, at first glance, I'd use the php mail() statement, and configure a different message to be sent depending on whether the transaction succeeded or not.

    As for the "Please wait one moment..." message, is there something wrong with the way you have it now? I don't see any statement that you've started an output buffer. If it isn't working right now, then I would try:

    echo "<h1>Please Wait One Moment While We process your card.<br>\n";

    You've explained what you want to happen, but you haven't said explicitly what errors you're seeing, so I'm not sure if this is actually the solution that you need.
    LVL 9

    Assisted Solution

    I would dare venture that if you're seeing errors, it's due to headers already being sent.  To wit, the echo statement begins HTML mode, and the ()flush pushes a full set of HTTP headers for the GET request.  You shouldn't be able send a Location: header after that, since you've already sent headers and are in the middle of delivering the body for the request.

    But yes, you can use mail() to handle sending custom emails.
    LVL 13

    Expert Comment

    That's a very good point about trying to send a location header. Use javascript to redirect the browser instead:

    echo "<script type='text/javascript'>location.href='$URL';</script>";

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Using Quotation Marks in PHP This question ( seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
    Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This video teaches users how to migrate an existing Wordpress website to a new domain.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now