并行paypal支付不工作

时间:2015-12-15 07:25:30

标签: php paypal

我在项目中工作我需要集成自适应支付网关。我引用了来自here的代码,它看起来很简单,但是一旦我下载并运行代码就无法正常工作

我发现的问题是..在流程页面中,变量$ack正在返回失败

如何解决此问题

以下是示例代码

Process.php

<?php
    session_start();
    require_once('../PPBootStrap.php');
    require_once('../Common/Constants.php');
    define("DEFAULT_SELECT", "- Select -");
    $returnUrl = "http://www.formget.com/tutorial/paypal-adaptive-    payment/parallel/success.php";
    $cancelUrl = "http://www.formget.com/tutorial/paypal-adaptive-    payment/parallel/index.php";
    $memo = "Adaptive Payment";
    $actionType = "PAY";
    $currencyCode = "USD";

    if ($_POST['booking'] == 'f') {
        $receiverEmail = array("airline@outlook.com");
        $receiverAmount = array("300.00");
        $primaryReceiver = array("false");
        $_SESSION['facilty_provider'] = array("AirGo Airline's Test Store");
    } elseif ($_POST['booking'] == 'h') {
        $receiverEmail = array("hotel@outlook.com");
        $receiverAmount = array("200.00");
        $primaryReceiver = array("false");
        $_SESSION['facilty_provider'] = array("Hotel TheCompany's Test Store");
    } elseif ($_POST['booking'] == 'c') {
        $receiverEmail = array("car-merchants@outlook.com");
        $receiverAmount = array("100.00");
        $primaryReceiver = array("false");
        $_SESSION['facilty_provider'] = array("MyCar Car Company's Test Store");
    } elseif ($_POST['booking'] == 'fh') {
        $receiverEmail = array("airline@outlook.com", "hotel@outlook.com");
        $receiverAmount = array("300.00", "200.00");
        $primaryReceiver = array("false", "false");
        $_SESSION['facilty_provider'] = array("AirGo Airline's Test Store", "Hotel     TheCompany's Test Store");
    } elseif ($_POST['booking'] == 'fc') {
        $receiverEmail = array("airline@outlook.com", "car-merchants@outlook.com");
        $receiverAmount = array("300.00", "100.00");
        $primaryReceiver = array("false", "false");
        $_SESSION['facilty_provider'] = array("AirGo Airline's Test Store", "MyCar     Car Company's Test Store");
    } elseif ($_POST['booking'] == 'hc') {
        $receiverEmail = array("hotel@outlook.com", "car-merchants@outlook.com");
        $receiverAmount = array("200.00", "100.00");
        $primaryReceiver = array("false", "false");
        $_SESSION['facilty_provider'] = array("Hotel TheCompany's Test Store",     "MyCar Car Company's Test Store");
    } elseif ($_POST['booking'] == 'fhc') {
        $receiverEmail = array("airline@outlook.com", "hotel@outlook.com", "car-merchants@outlook.com");
        $receiverAmount = array("295.00", "195.00", "95.00");
        $primaryReceiver = array("false", "false", "false");
        $_SESSION['facilty_provider'] = array("AirGo Airline's Test Store", "Hotel     TheCompany's Test Store", "MyCar Car Company's Test Store");
    } else {
        $receiverEmail = array("airline@outlook.com");
        $receiverAmount = array("300.00");
        $primaryReceiver = array("false");
        $_SESSION['facilty_provider'] = array("AirGo Airline's Test Store");
    }
    if (isset($receiverEmail)) {
        $receiver = array();
        /*
         * A receiver's email address
        */
        for ($i = 0; $i < count($receiverEmail); $i++) {
        $receiver[$i] = new Receiver();
        $receiver[$i]->email = $receiverEmail[$i];
        /*
        * Amount to be credited to the receiver's account
        */
        $receiver[$i]->amount = $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 = $primaryReceiver[$i];
    }
        $receiverList = new ReceiverList($receiver);
}
$payRequest = new PayRequest(new RequestEnvelope("en_US"), $actionType, $cancelUrl, $currencyCode, $receiverList, $returnUrl);
// Add optional params
if ($memo != "") {
    $payRequest->memo = $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);
    echo $ack = strtoupper($response->responseEnvelope->ack);
    if ($ack == "SUCCESS") {
        $_SESSION['pay_key'] = $payKey = $response->payKey;
        $payKey = $response->payKey;
        $payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $payKey;
        header('Location: ' . $payPalURL);
    }
} catch (Exception $ex) {
    require_once '../Common/Error.php';
    exit;
}

1 个答案:

答案 0 :(得分:0)

我在这里发现了问题,问题出在配置文件中。有一个acct1.AppId变量。默认情况下,此示例代码的创建者已对其进行评论,因此您在不包含App ID的情况下发送请求。要解决这个问题,您应该取消注释。之后再试一次。

enter image description here