Page 1 of 1

Processing Credit Cards

Posted: Wed Mar 24, 2010 9:52 am
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?

Re: Processing Credit Cards

Posted: Wed Mar 24, 2010 3:38 pm
by Christopher
Check the PayPal site. There is code and information available there.

Re: Processing Credit Cards

Posted: Fri Mar 26, 2010 2:23 am
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 ?

Re: Processing Credit Cards

Posted: Fri Mar 26, 2010 7:39 am
by requinix
Well, you... store the stuff into a database and access it later?

I don't see where the difficulty is.

Re: Processing Credit Cards

Posted: Fri Mar 26, 2010 8:00 am
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..

Re: Processing Credit Cards

Posted: Fri Mar 26, 2010 8:03 am
by rahulsonar
I am making a system similar to groupon.com