Question : Paypal DirectPayment function SUCCESS but not withdrawing money from account

So I am in the process of using the paypal sandbox to test my scripts using Paypal Express and Pro. I need to make sure  I am doing this right and have an understanding before I ask my question

First

Is it my understanding in using this funtion which allows you to use a Credit Card for payments there is no interaction with the user going to the paypal site to login? What I mean is that the user when they select to use a standard CC then the DirectPayment function is what is called to process the CC payment?

So when you receive a SUCCESS with ack in the function the payment is processed and thats it? In my site at the checkout process I give the users 2 options. Check out with PayPal or Credit Card. In the intergration wizard in the billing section the code allows you to with use PayPal or Credit Card. I guess I am confused to how this script works. When a user on my site selects a CC as payment I pass all the parameters to the billing script and I recieve a SUCCESS but the funds are not being withdrawn from the account. I have the checkout process with paypal working fine. Here is my billing code

Hope I make sense cause I am confused :)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
if ((( $_SESSION['cc_type'] == "Visa") || ( $_SESSION['cc_type'] == "MasterCard") || ($_SESSION['cc_type'] == "Amex") || ($_SESSION['cc_type'] == "Discover"))
			&& ( $_SESSION['PaymentProcessorSelected'] == "PayPal Direct Payment"))

	//'------------------------------------
	//' The paymentAmount is the total value of 
	//' the shopping cart, that was set 
	//' earlier in a session variable 
	//' by the shopping cart page
	//'------------------------------------
	$paymentAmount = $_SESSION["Payment_Amount"];

	//'------------------------------------
	//' The currencyCodeType and paymentType 
	//' are set to the selections made on the Integration Assistant 
	//'------------------------------------
	$currencyCodeType = $_SESSION['currencyCodeType'];
	$paymentType = $_SESSION['paymentType'];
	
	//' Set these values based on what was selected by the user on the Billing page Html form
	
	$creditCardType 		= $_SESSION['creditCardType']; //' Set this to one of the acceptable values (Visa/MasterCard/Amex/Discover) match it to what was selected on your Billing page
	$creditCardNumber 		= $_SESSION['creditCardNumber']; //' Set this to the string entered as the credit card number on the Billing page
	$expDate 				= $_SESSION['expDate']; //' Set this to the credit card expiry date entered on the Billing page
	$cvv2 					= $_SESSION['cvv']; //' Set this to the CVV2 string entered on the Billing page 
	$firstName 				= $_SESSION['firstname']; //' Set this to the customer's first name that was entered on the Billing page 
	$lastName 				= $_SESSION['lastName']; //' Set this to the customer's last name that was entered on the Billing page 
	$street 				= $_SESSION['street']; //' Set this to the customer's street address that was entered on the Billing page 
	$city 					= $_SESSION['city']; //' Set this to the customer's city that was entered on the Billing page 
	$state 					= $_SESSION['state']; //' Set this to the customer's state that was entered on the Billing page 
	$zip 					= $_SESSION['zip']; //' Set this to the zip code of the customer's address that was entered on the Billing page
	$countryCode 			= $_SESSION['countryCode']; //' Set this to the PayPal code for the Country of the customer's address that was entered on the Billing page 
	$currencyCode 			= $_SESSION['currencyCode']; //' Set this to the PayPal code for the Currency used by the customer 
	
	/*	
	'------------------------------------------------
	' Calls the DoDirectPayment API call
	'
	' The DirectPayment function is defined in PayPalFunctions.php included at the top of this file.
	'-------------------------------------------------
	*/
	
	$resArray = DirectPayment ( $paymentType, $paymentAmount, $creditCardType, $creditCardNumber,
							$expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, 
							$countryCode, $currencyCode ); 

	$ack = strtoupper($resArray["ACK"]);
	if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
	{
	
	//Getting transaction ID from API responce. 
	$TransactionID = urldecode($resArray["TRANSACTIONID"]);
		
	unset($_SESSION['cart']);
	session_destroy();
	session_register("ok");
	$ok = "Thank you for shopping with us :)";
	echo '<meta http-equiv="refresh" content="0;url=../">';
				
	}
	else
	{
		//Display a user friendly Error on the page using any of the following error information returned by PayPal
		//goback to checkout.php and display error
		$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
		$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
		$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
		$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
		
		echo "Direct credit card payment API call failed. ";
		echo "Detailed Error Message: " . $ErrorLongMsg;
		echo "Short Error Message: " . $ErrorShortMsg;
		echo "Error Code: " . $ErrorCode;
		echo "Error Severity Code: " . $ErrorSeverityCode;
	}
}

Answer : Paypal DirectPayment function SUCCESS but not withdrawing money from account

You are correct in your assumptions.

when you get SUCCESS or SUCCESSWITHWARNING from the ACK you are paid.

What are you setting for $_SESSION['paymentType']?

If you are setting "Authorization" than you will not be collecting the money.  You have two options.

Authorization - which requires you to later do a "capture"
Sale - this completes the sale without needing to "capture".


Random Solutions  
 
programming4us programming4us