Reputation: 15925
UPDATE 2:
The code I currentlly have is as follows:
paypalplatform.php:
https://www.paypal-labs.com/integrationwizard/adaptive/code2.php
basic_payment.php: (the script in 4b in the link below)
https://www.paypal-labs.com/integrationwizard/adaptive/paymenttypes.php
ipn.php: (the IPN listener)
If the boxes in the second link above are empty, just click on "start over" and click next until you get to step 4, or click here: https://www.paypal-labs.com/integrationwizard/adaptive/main.php
UPDATE 1:
I think this is the code initiating the payment, do I need to specify a custom value here? if so, how?
<?php
//-------------------------------------------------
// When you integrate this code
// look for TODO as an indication
// that you may need to provide a value or take action
// before executing this code
//-------------------------------------------------
require_once ("paypalplatform.php");
// ==================================
// PayPal Platform Basic Payment Module
// ==================================
// Request specific required fields
$actionType = "PAY";
$cancelUrl = "some url here"; // TODO - If you are not executing the Pay call for a preapproval,
// then you must set a valid cancelUrl for the web approval flow
// that immediately follows this Pay call
$returnUrl = "some url here"; // TODO - If you are not executing the Pay call for a preapproval,
// then you must set a valid returnUrl for the web approval flow
// that immediately follows this Pay call
$currencyCode = "USD";
// A basic payment has 1 receiver
// TODO - specify the receiver email
$receiverEmailArray = array(
'receivers email here'
);
// TODO - specify the receiver amount as the amount of money, for example, '5' or '5.55'
$receiverAmountArray = array(
'receivers amount here'
);
// for basic payment, no primary indicators are needed, so set empty array
$receiverPrimaryArray = array();
// TODO - Set invoiceId to uniquely identify the transaction associated with the receiver
// You can set this to the same value as trackingId if you wish
$receiverInvoiceIdArray = array(
'1234abc'
);
// Request specific optional or conditionally required fields
// Provide a value for each field that you want to include in the request, if left as an empty string the field will not be passed in the request
$senderEmail = ""; // TODO - If you are executing the Pay call against a preapprovalKey, you should set senderEmail
// It is not required if the web approval flow immediately follows this Pay call
$feesPayer = "";
$ipnNotificationUrl = "some url here";
$memo = ""; // maxlength is 1000 characters
$pin = ""; // TODO - If you are executing the Pay call against an existing preapproval
// the requires a pin, then you must set this
$preapprovalKey = ""; // TODO - If you are executing the Pay call against an existing preapproval, set the preapprovalKey here
$reverseAllParallelPaymentsOnError = ""; // Do not specify for basic payment
$trackingId = generateTrackingID(); // generateTrackingID function is found in paypalplatform.php
//-------------------------------------------------
// Make the Pay API call
//
// The CallPay function is defined in the paypalplatform.php file,
// which is included at the top of this file.
//-------------------------------------------------
$resArray = CallPay ($actionType, $cancelUrl, $returnUrl, $currencyCode, $receiverEmailArray,
$receiverAmountArray, $receiverPrimaryArray, $receiverInvoiceIdArray,
$feesPayer, $ipnNotificationUrl, $memo, $pin, $preapprovalKey,
$reverseAllParallelPaymentsOnError, $senderEmail, $trackingId
);
$ack = strtoupper($resArray["responseEnvelope.ack"]);
if($ack=="SUCCESS")
{
if ("" == $preapprovalKey)
{
// redirect for web approval flow
$cmd = "cmd=_ap-payment&paykey=" . urldecode($resArray["payKey"]);
RedirectToPayPal ( $cmd );
}
else
{
// payKey is the key that you can use to identify the payment resulting from the Pay call
$payKey = urldecode($resArray["payKey"]);
// paymentExecStatus is the status of the payment
$paymentExecStatus = urldecode($resArray["paymentExecStatus"]);
}
}
else
{
//Display a user friendly Error on the page using any of the following error information returned by PayPal
//TODO - There can be more than 1 error, so check for "error(1).errorId", then "error(2).errorId", and so on until you find no more errors.
$ErrorCode = urldecode($resArray["error(0).errorId"]);
$ErrorMsg = urldecode($resArray["error(0).message"]);
$ErrorDomain = urldecode($resArray["error(0).domain"]);
$ErrorSeverity = urldecode($resArray["error(0).severity"]);
$ErrorCategory = urldecode($resArray["error(0).category"]);
echo "Preapproval API call failed. ";
echo "Detailed Error Message: " . $ErrorMsg;
echo "Error Code: " . $ErrorCode;
echo "Error Severity: " . $ErrorSeverity;
echo "Error Domain: " . $ErrorDomain;
echo "Error Category: " . $ErrorCategory;
}
?>
ORIGINAL QUESTION:
I have some script from paypal which allows users to make payments from my website.
In the first step when they send the payment using the basic payment script, I get these values back:
Array (
[responseEnvelope.timestamp] => 2011-04-08T01:34:03.578-07:00
[responseEnvelope.ack] => Success
[responseEnvelope.correlationId] => a2de97aaf57f0
[responseEnvelope.build] => 1822511
[payKey] => AP-8AW04791DK417062F
[paymentExecStatus] => CREATED )
When the payment is confirmed from paypal, using their ipn system, I get these values back:
test_ipn = 1
payment_type = instant
payment_date = 01:11:38 Apr 08, 2011 PDT
payment_status = Completed
address_status = confirmed
payer_status = verified
first_name = John
last_name = Smith
payer_email = [email protected]
payer_id = TESTBUYERID01
address_name = John Smith
address_country = United States
address_country_code = US
address_zip = 95131
address_state = CA
address_city = San Jose
address_street = 123, any street
business = [email protected]
receiver_email = [email protected]
receiver_id = TESTSELLERID1
residence_country = US
item_name = something
item_number = AK-1234
quantity = 1
shipping = 3.04
tax = 2.02
mc_currency = USD
mc_fee = 0.44
mc_gross = 12.34
mc_gross_1 = 9.34
txn_type = web_accept
txn_id = 3848811
notify_version = 2.1
custom = xyz123
charset = windows-1252
verify_sign = AWPjjtnKgiQkL5dH.EojlIO6uUy9AijwJCRexi2IglsAajCxoIkbVEq-
I can't see any values which allow me to make a connection, allowing me to update the correct database record to say that the payment has been successfully completed.
Upvotes: 3
Views: 1867
Reputation: 24604
txn_id = 3848811 is the transaction ID from paypal. If you want paypal to send back a reference to some identifier in your system (your payment identifier) you could use the "custom" field which you would send in your request to begin with.
if you use NVP, it would be PAYMENTREQUEST_n_CUSTOM, don't know about the SOAP interface.
Upvotes: 1