Exemplo n.º 1
0
function GetPaymentOption($token)
{
    $getPaymentOptionsRequest = new GetPaymentOptionsRequest();
    $getPaymentOptionsRequest->payKey = $token;
    $getPaymentOptionsRequest->requestEnvelope = new RequestEnvelope();
    $getPaymentOptionsRequest->requestEnvelope->errorLanguage = "en_US";
    $ap = new AdaptivePayments();
    $response = $ap->GetPaymentOptions($getPaymentOptionsRequest);
    if (strtoupper($ap->isSuccess) == 'FAILURE') {
        $FaultMsg = $ap->getLastError();
        echo "GetPaymentDetails API call Failed: error Id: ";
        if (is_array($FaultMsg->error)) {
            echo $FaultMsg->error[0]->errorId . ", error message: " . $FaultMsg->error[0]->message;
        } else {
            echo $FaultMsg->error->errorId . ", error message: " . $FaultMsg->error->message;
        }
    } else {
        if ($response->responseEnvelope->ack == "Success") {
            echo "GetPaymentDetails API call was Successful! \n";
        }
    }
}
session_start();
try {
    $serverName = $_SERVER['SERVER_NAME'];
    $serverPort = $_SERVER['SERVER_PORT'];
    $url = dirname('http://' . $serverName . ':' . $serverPort . $_SERVER['REQUEST_URI']);
    /* The returnURL is the location where buyers return when a
    	 payment has been succesfully authorized.
    	 The cancelURL is the location buyers are sent to when they hit the
    	 cancel button during authorization of payment during the PayPal flow                 */
    $payKey = $_REQUEST["payKey"];
    $getPaymentOptionsRequest = new GetPaymentOptionsRequest();
    $getPaymentOptionsRequest->payKey = $payKey;
    $getPaymentOptionsRequest->requestEnvelope = new RequestEnvelope();
    $getPaymentOptionsRequest->requestEnvelope->errorLanguage = "en_US";
    $ap = new AdaptivePayments();
    $response = $ap->GetPaymentOptions($getPaymentOptionsRequest);
    if (strtoupper($ap->isSuccess) == 'FAILURE') {
        $_SESSION['FAULTMSG'] = $ap->getLastError();
        $location = "APIError.php";
        header("Location: {$location}");
    } else {
        if ($response->responseEnvelope->ack == "Success") {
            $GPOResponse = new GetPaymentOptionsResponse();
            ?>

<html>
<head>
<title>PayPal Platform SDK - Get Payment Option Receipt</title>

<link href="sdk.css" rel="stylesheet" type="text/css" />
</head>