Processing Credit Cards

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rahulsonar
Forum Newbie
Posts: 10
Joined: Wed Mar 11, 2009 8:54 am

Processing Credit Cards

Post by rahulsonar »

I am in need to following system:

On one site, the users will purchase a product. At the time of purchasing it, they will just enter the CC details, and I will store it to my database. (in encrypted form).

Then, after some days, I need to perform the transaction. I want to use Paypal for the same. Is there any class or tutorial for the same?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Processing Credit Cards

Post by Christopher »

Check the PayPal site. There is code and information available there.
(#10850)
rahulsonar
Forum Newbie
Posts: 10
Joined: Wed Mar 11, 2009 8:54 am

Re: Processing Credit Cards

Post by rahulsonar »

Christopher

I think you dint get my question.. I know how to process Credit cards live(on the spot).

In my site, users confirm that they want to purchase the product. However, they don't get that product at that time. After a specific time (say, 15 days), if certain conditions are fulfilled, we need to charge him.

So, I need to save the cc details and charge him when I want. I am not sure how to do this.

Do anyone know ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Processing Credit Cards

Post by requinix »

Well, you... store the stuff into a database and access it later?

I don't see where the difficulty is.
rahulsonar
Forum Newbie
Posts: 10
Joined: Wed Mar 11, 2009 8:54 am

Re: Processing Credit Cards

Post by rahulsonar »

Well, this is the code I have:

Code: Select all

<?php
    /*==================================================================
     Payflow Direct Payment Call
     ===================================================================
    */
require_once ("paypalfunctions.php");
 
if ( $PaymentOption == "Visa" || $PaymentOption == "MasterCard" || $PaymentOption == "Amex" || $PaymentOption == "Discover" )
{
    /*
    '------------------------------------
    ' The paymentAmount is the total value of 
    ' the shopping cart, that was set 
    ' earlier in a session variable 
    ' by the shopping cart page
    '------------------------------------
    */
    
    $finalPaymentAmount =  $_SESSION["Payment_Amount"];
 
    $creditCardType         = "<<Visa/MasterCard/Amex/Discover>>"; //' Set this to one of the acceptable values (Visa/MasterCard/Amex/Discover) match it to what was selected on your Billing page
    $creditCardNumber   = "<<CC number>>"; // ' Set this to the string entered as the credit card number on the Billing page
    $expDate                = "<<Expiry Date>>"; // ' Set this to the credit card expiry date entered on the Billing page
    $cvv2               = "<<cvv2>>"; // ' Set this to the CVV2 string entered on the Billing page 
    $firstName          = "<<firstName>>"; // ' Set this to the customer's first name that was entered on the Billing page 
    $lastName           = "<<lastName>>"; // ' Set this to the customer's last name that was entered on the Billing page 
    $street                 = "<<street>>"; // ' Set this to the customer's street address that was entered on the Billing page 
    $city               = "<<city>>"; // ' Set this to the customer's city that was entered on the Billing page 
    $state              = "<<state>>"; // ' Set this to the customer's state that was entered on the Billing page 
    $zip                    = "<<zip>>"; // ' Set this to the zip code of the customer's address that was entered on the Billing page 
    $countryCode            = "<<PayPal Country Code>>"; // ' Set this to the PayPal code for the Country of the customer's address that was entered on the Billing page 
    $currencyCode       = "<<PayPal Currency Code>>"; // ' Set this to the PayPal code for the Currency used by the customer
    $orderDescription   = "<<OrderDescription>>"; // ' Set this to the textual description of this order 
 
    $paymentType            = "Authorization";
    
    /*
    '------------------------------------
    '
    ' The DirectPayment function is defined in the file PayPalFunctions.php,
    ' that is included at the top of this file.
    '-------------------------------------------------
    */
 
    $resArray = DirectPayment ( $paymentType, $finalPaymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $orderDescription );
    $ack = $resArray["RESULT"];
    if( $ack != "0" ) 
    {
        // See pages 50 through 65 in https://cms.paypal.com/cms_content/US/e ... _Guide.pdf for a list of RESULT values (error codes)
        //Display a user friendly Error on the page using any of the following error information returned by Payflow
        $ErrorCode = $ack;
        $ErrorMsg = $resArray["RESPMSG"];
 
        echo "Credit Card transaction failed. ";
        echo "Error Message: " . $ErrorMsg;
        echo "Error Code: " . $ErrorCode;
    }
}       
        
?>
Now, I will need to "Post" the cc details, correct? how can I "Post" them if they are in DB?

Thanks for your help..
rahulsonar
Forum Newbie
Posts: 10
Joined: Wed Mar 11, 2009 8:54 am

Re: Processing Credit Cards

Post by rahulsonar »

I am making a system similar to groupon.com
Post Reply