没有从paypal adaptivepayments返回的详细信息

时间:2015-04-12 08:40:40

标签: paypal paypal-adaptive-payments

我正在使用https://github.com/paypal/adaptivepayments-sdk-php

从paypal付款后我无法获得金额,cc,产品名称和相关值作为回报 我的代码 通过点击从此页面重定向URL到完成付款来传递到PayPal

<?php

/*
 * Use the Pay API operation to transfer funds from a sender�s PayPal account to one or more receivers� PayPal accounts. You can use the Pay API operation to make simple payments, chained payments, or parallel payments; these payments can be explicitly approved, preapproved, or implicitly approved.

 Use the Pay API operation to transfer funds from a sender's PayPal account to one or more receivers' PayPal accounts. You can use the Pay API operation to make simple payments, chained payments, or parallel payments; these payments can be explicitly approved, preapproved, or implicitly approved. 

 A chained payment is a payment from a sender that is indirectly split among multiple receivers. It is an extension of a typical payment from a sender to a receiver, in which a receiver, known as the primary receiver, passes part of the payment to other receivers, who are called secondary receivers

 * Create your PayRequest message by setting the common fields. If you want more than a simple payment, add fields for the specific kind of request, which include parallel payments, chained payments, implicit payments, and preapproved payments.
 */
require_once('../PPBootStrap.php');
require_once('../Common/Constants.php');
define("DEFAULT_SELECT", "- Select -");

if(isset($_POST['receiverEmail'])) {
    $receiver = array();
    /*
     * A receiver's email address 
     */
    for($i=0; $i<count($_POST['receiverEmail']); $i++) {
        $receiver[$i] = new Receiver();
        $receiver[$i]->email = $_POST['receiverEmail'][$i];
        /*
         *      Amount to be credited to the receiver's account 
         */
        $receiver[$i]->amount = $_POST['receiverAmount'][$i];
        /*
         * Set to true to indicate a chained payment; only one receiver can be a primary receiver. Omit this field, or set it to false for simple and parallel payments. 
         */
        $receiver[$i]->primary = $_POST['primaryReceiver'][$i];

    }
    $receiverList = new ReceiverList($receiver);
}

/*
 * The action for this request. Possible values are:

    PAY - Use this option if you are not using the Pay request in combination with ExecutePayment.
    CREATE - Use this option to set up the payment instructions with SetPaymentOptions and then execute the payment at a later time with the ExecutePayment.
    PAY_PRIMARY - For chained payments only, specify this value to delay payments to the secondary receivers; only the payment to the primary receiver is processed.

 */
/*
 * The code for the currency in which the payment is made; you can specify only one currency, regardless of the number of receivers 
 */
/*
 * URL to redirect the sender's browser to after canceling the approval for a payment; it is always required but only used for payments that require approval (explicit payments) 
 */
/*
 * URL to redirect the sender's browser to after the sender has logged into PayPal and approved a payment; it is always required but only used if a payment requires explicit approval 
 */
$payRequest = new PayRequest(new RequestEnvelope("en_US"), $_POST['actionType'], $_POST['cancelUrl'], $_POST['currencyCode'], $receiverList, $_POST['returnUrl']);
// Add optional params

if($_POST["memo"] != "") {
    $payRequest->memo = $_POST["memo"];
}


/*
 *   ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
 */
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $response = $service->Pay($payRequest);
} catch(Exception $ex) {
    require_once '../Common/Error.php';
    exit;
}
/* Make the call to PayPal to get the Pay token
 If the API call succeded, then redirect the buyer to PayPal
to begin to authorize payment.  If an error occured, show the
resulting errors */


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>PayPal Adaptive Payments - Pay Response</title>
<link href="../Common/sdk.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Common/tooltip.js">
    </script>
</head>

<body>  
    <div id="wrapper">
        <img src="https://devtools-paypal.com/image/bdg_payments_by_pp_2line.png"/>
        <div id="response_form">
            <h3>Pay - Response</h3>         
<?php
$ack = strtoupper($response->responseEnvelope->ack);
if($ack != "SUCCESS") {
    echo "<b>Error </b>";
    echo "<pre>";
    echo "</pre>";
} else {
    $payKey = $response->payKey;
    $payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $payKey;
    ?>





    <?php 

            echo "<table>";
            echo "<tr><td>Ack :</td><td><div id='Ack'>$ack</div> </td></tr>";
            echo "<tr><td>PayKey :</td><td><div id='PayKey'>$payKey</div> </td></tr>";
            echo "<tr><td><a href=$payPalURL><b>Redirect URL to Complete Payment </b></a></td></tr>";
            echo "</table>";
    echo "<pre>";
    print_r($response);
    echo "</pre>";  
}
require_once '../Common/Response.php';
?>
<?php
$_REQUEST['item_number'];

?>

        </div>
    </div>
</body>
</html>

及以下代码是返回网页

<?php
                    foreach($_GET as $variable => $value)
                    {
                        echo "<tr><td>" . $variable . "</td>";
                        echo "<td>" . $value . "</td></tr>";
                    }
                    ?>

此致

1 个答案:

答案 0 :(得分:1)

自适应付款不会以与PayPal付款标准相同的方式返回返回网址中的数据。相反,你必须出去向PayPal索取数据。

如果您在回复网址中加入${payKey},则在将买家重定向回您的网站时,PayPal会将其替换为付款密钥 - 例如:

https://example.com/paypal_return?paykey=${payKey}

当买家回到您的网站时,PayPal会将其替换为实际的付款密钥 - 例如:

https://example.com/paypal_return?paykey=AP-1234567890ABCDEF

获得付款密钥后,您可以运行PaymentDetails调用(https://developer.paypal.com/docs/classic/api/adaptive-payments/PaymentDetails_API_Operation/)以查找交易ID,收款人,金额等。