public function refund()
 {
     $logger = new PPLoggingManager('RefundTransaction');
     // ## RefundTransactionReq
     $refundTransactionReq = new RefundTransactionReq();
     $refundTransactionRequest = new RefundTransactionRequestType();
     // Either the `transaction ID` or the `payer ID` must be specified.
     // PayerID is unique encrypted merchant identification number
     // For setting `payerId`,
     // `refundTransactionRequest.setPayerID("A9BVYX8XCR9ZQ");`
     // Unique identifier of the transaction to be refunded.
     $refundTransactionRequest->TransactionID = "1GF88795WC5643301";
     // Type of refund you are making. It is one of the following values:
     //
     // * `Full` - Full refund (default).
     // * `Partial` - Partial refund.
     // * `ExternalDispute` - External dispute. (Value available since
     // version
     // 82.0)
     // * `Other` - Other type of refund. (Value available since version
     // 82.0)
     $refundTransactionRequest->RefundType = "Partial";
     // `Refund amount`, which contains
     //
     // * `Currency Code`
     // * `Amount`
     // The amount is required if RefundType is Partial.
     // `Note:
     // If RefundType is Full, do not set the amount.`
     $amount = new BasicAmountType("USD", "1.00");
     $refundTransactionRequest->Amount = $amount;
     $refundTransactionReq->RefundTransactionRequest = $refundTransactionRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->RefundTransaction($refundTransactionReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Unique transaction ID of the refund.
         $logger->log("Refund Transaction ID" . $response->RefundTransactionID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function capture()
 {
     $logger = new PPLoggingManager('DoCapture');
     // `Amount` to capture which takes mandatory params:
     //
     // * `currencyCode`
     // * `amount`
     $amount = new BasicAmountType("USD", "1.00");
     // `DoCaptureRequest` which takes mandatory params:
     //
     // * `Authorization ID` - Authorization identification number of the
     // payment you want to capture. This is the transaction ID returned from
     // DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
     // point-of-sale transactions, this is the transaction ID returned by
     // the CheckOut call when the payment action is Authorization.
     // * `amount` - Amount to capture
     // * `CompleteCode` - Indicates whether or not this is your last capture.
     // It is one of the following values:
     // * Complete – This is the last capture you intend to make.
     // * NotComplete – You intend to make additional captures.
     // `Note:
     // If Complete, any remaining amount of the original authorized
     // transaction is automatically voided and all remaining open
     // authorizations are voided.`
     $doCaptureReqest = new DoCaptureRequestType("O-4VR15106P7416533H", $amount, "NotComplete");
     // ## DoCaptureReq
     $doCaptureReq = new DoCaptureReq();
     $doCaptureReq->DoCaptureRequest = $doCaptureReqest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->DoCapture($doCaptureReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " . $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // ## Accessing response parameters
         // You can access the response parameters using getter methods in
         // response object as shown below
         // ### Success values
         $logger->log("Authorization ID:" . $response->DoCaptureResponseDetails->AuthorizationID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function doReauth()
 {
     $logger = new PPLoggingManager('DoReauthorization');
     // ## DoAuthorizationReq
     $doReauthorizationReq = new DoReauthorizationReq();
     // `Amount` to reauthorize which takes mandatory params:
     //
     // * `currencyCode`
     // * `amount`
     $amount = new BasicAmountType("USD", "3.00");
     // `DoReauthorizationRequest` which takes mandatory params:
     //
     // * `Authorization Id` - Value of a previously authorized transaction
     // identification number returned by PayPal.
     // * `amount`
     $doReauthorizationRequest = new DoReauthorizationRequestType("9B2288061E685550E", $amount);
     $doReauthorizationReq->DoReauthorizationRequest = $doReauthorizationRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->doReauthorization($doReauthorizationReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Authorization identification number
         $logger->log("Authorization ID:" . $response->AuthorizationID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function getEC()
 {
     $logger = new PPLoggingManager('GetExpressCheckout');
     // ## GetExpressCheckoutDetailsReq
     $getExpressCheckoutDetailsReq = new GetExpressCheckoutDetailsReq();
     // A timestamped token, the value of which was returned by
     // `SetExpressCheckout` response.
     $setEc = new SetExpressCheckout();
     $setEcResponse = $setEc->setExpressCheckout();
     var_dump($setEcResponse->Token);
     $getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($setEcResponse->Token);
     $getExpressCheckoutDetailsReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->GetExpressCheckoutDetails($getExpressCheckoutDetailsReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // PayerID is PayPal Customer Account identification number
         // ($response->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID). This
         // value will be null unless you authorize the payment by
         // redirecting to PayPal after `SetExpressCheckout` call.
         $logger->log("PayerID : " . $response->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function searchTxn()
 {
     $logger = new PPLoggingManager('TransactionSearch');
     // ## TransactionSearchReq
     $transactionSearchReq = new TransactionSearchReq();
     // `TransactionSearchRequestType` which takes mandatory argument:
     //
     // * `Start Date` - The earliest transaction date at which to start the
     // search.
     $transactionSearchRequest = new TransactionSearchRequestType("2013-01-11T00:00:00+0530");
     $transactionSearchReq->TransactionSearchRequest = $transactionSearchRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->TransactionSearch($transactionSearchReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Search Results
         $txnSearchArray = $response->PaymentTransactions;
         foreach ($txnSearchArray as $txn) {
             // Merchant's transaction ID.
             $logger->log("Transaction ID : " . $txn->TransactionID);
         }
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function getBal()
 {
     $logger = new PPLoggingManager('GetBalance');
     // ## GetBalanceReq
     $getBalanceReq = new GetBalanceReq();
     $getBalanceRequest = new GetBalanceRequestType();
     // Indicates whether to return all currencies. It is one of the
     // following values:
     //
     // * 0 – Return only the balance for the primary currency holding.
     // * 1 – Return the balance for each currency holding.
     $getBalanceRequest->ReturnAllCurrencies = "1";
     $getBalanceReq->GetBalanceRequest = $getBalanceRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->GetBalance($getBalanceReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         $balanceHoldingArray = $response->BalanceHoldings;
         foreach ($balanceHoldingArray as $amount) {
             $logger->log("Balance Holdings : " + $amount->value . $amount->currencyID);
         }
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function void()
 {
     $logger = new PPLoggingManager('DoVoid');
     // ## DoVoidReq
     $doVoidReq = new DoVoidReq();
     // DoVoidRequest which takes mandatory params:
     //
     // * `Authorization ID` - Original authorization ID specifying the
     // authorization to void or, to void an order, the order ID.
     // `Important:
     // If you are voiding a transaction that has been reauthorized, use the
     // ID from the original authorization, and not the reauthorization.`
     $doVoidRequest = new DoVoidRequestType("9B2288061E685550E");
     $doVoidReq->DoVoidRequest = $doVoidRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->DoVoid($doVoidReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Authorization identification number you specified in the
         // request.
         $logger->log("Authorization ID:" . $response->AuthorizationID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function getTxnDetails()
 {
     $logger = new PPLoggingManager('GetTransactionDetails');
     // ## GetTransactionDetailsReq
     $getTransactionDetailsReq = new GetTransactionDetailsReq();
     $getTransactionDetailsRequest = new GetTransactionDetailsRequestType();
     // Unique identifier of a transaction.
     // `Note:
     // The details for some kinds of transactions cannot be retrieved with
     // GetTransactionDetails. You cannot obtain details of bank transfer
     // withdrawals, for example.`
     $getTransactionDetailsRequest->TransactionID = "5AT5731435011481X";
     $getTransactionDetailsReq->GetTransactionDetailsRequest = $getTransactionDetailsRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->GetTransactionDetails($getTransactionDetailsReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Unique PayPal Customer Account identification number.
         $logger->log("Payer ID:" . $response->PaymentTransactionDetails->PayerInfo->PayerID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
session_start();
$logger = new PPLoggingManager('GetExpressCheckout');
$token = $_REQUEST['token'];
$getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
$getExpressCheckoutDetailsRequest->Version = 92.0;
$getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
$getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
$getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
echo '<pre>';
print_r($getECResponse);
echo '</pre>';
if ($getECResponse->Ack == 'Success') {
    ?>
	<html>
	<body>

	</body>
	</html>
	<?php 
    require_once '../Response.php';
}
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('GetRecurringPaymentsProfileDetails');
$getRPPDetailsReqest = new GetRecurringPaymentsProfileDetailsRequestType();
$getRPPDetailsReqest->ProfileID = $_REQUEST['profileID'];
$getRPPDetailsReq = new GetRecurringPaymentsProfileDetailsReq();
$getRPPDetailsReq->GetRecurringPaymentsProfileDetailsRequest = $getRPPDetailsReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $getRPPDetailsResponse = $paypalService->GetRecurringPaymentsProfileDetails($getRPPDetailsReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($getRPPDetailsResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$getRPPDetailsResponse->Ack}</div> </td></tr>";
    echo "<tr><td>ProfileID :</td><td><div id='ProfileID'>" . $getRPPDetailsResponse->GetRecurringPaymentsProfileDetailsResponseDetails->ProfileID . "</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($getRPPDetailsResponse);
    echo "</pre>";
}
require_once '../Response.php';
$ownerInfo = new BusinessOwnerInfoType();
$ownerInfo->SSN = $_REQUEST['SSN'];
$ownerInfo->MobilePhone = $_REQUEST['ownerPhone'];
$enterBoardingRequestDetails = new EnterBoardingRequestDetailsType();
$enterBoardingRequestDetails->ProductList = $_REQUEST['prodList'];
$enterBoardingRequestDetails->BankAccount = $bankAccount;
$enterBoardingRequestDetails->BusinessInfo = $businessInfo;
$enterBoardingRequestDetails->MarketingCategory = $_REQUEST['marketingCategory'];
$enterBoardingRequestDetails->OwnerInfo = $ownerInfo;
$enterBoardingRequestDetails->ProgramCode = $_REQUEST['programCode'];
$enterBoardingRequest = new EnterBoardingRequestType();
$enterBoardingRequest->EnterBoardingRequestDetails = $enterBoardingRequestDetails;
$enterBoardingReq = new EnterBoardingReq();
$enterBoardingReq->EnterBoardingRequest = $enterBoardingRequest;
/*
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $enterBoardingResponse = $paypalService->EnterBoarding($enterBoardingReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($enterBoardingResponse)) {
    echo "<pre>";
    print_r($enterBoardingResponse);
    echo "</pre>";
}
require_once '../Response.php';
\<?php 
require_once '../PPBootStrap.php';
$logger = new PPLoggingManager('BMGetButtonDetails');
$bmGetButtonDetailsReqest = new BMGetButtonDetailsRequestType($_REQUEST['hostedID']);
$bmGetButtonDetailsReq = new BMGetButtonDetailsReq();
$bmGetButtonDetailsReq->BMGetButtonDetailsRequest = $bmGetButtonDetailsReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    $bmGetButtonDetailsResponse = $paypalService->BMGetButtonDetails($bmGetButtonDetailsReq);
} catch (Exception $ex) {
    require '../Error.php';
    exit;
}
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>{$bmGetButtonDetailsResponse->Ack}</div> </td></tr>";
echo "<tr><td>HostedButtonID :</td><td><div id='HostedButtonID'>" . $bmGetButtonDetailsResponse->HostedButtonID . "</div> </td></tr>";
echo "<tr><td>Email :</td><td><div id='Email'>" . $bmGetButtonDetailsResponse->Email . "</div> </td></tr>";
echo "</table>";
echo "<pre>";
print_r($bmGetButtonDetailsResponse);
echo "</pre>";
require_once '../Response.php';
Exemple #13
0
    $massPayRequest->MassPayItem[] = $masspayItem;
}
/*
 *  ## MassPayReq
Details of each payment.
`Note:
A single MassPayRequest can include up to 250 MassPayItems.`
*/
$massPayReq = new MassPayReq();
$massPayReq->MassPayRequest = $massPayRequest;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
// required in third party permissioning
if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
    $cred = new PPSignatureCredential(USERNAME, PASSWORD, SIGNATURE);
    $cred->setThirdPartyAuthorization(new PPTokenAuthorization($_POST['accessToken'], $_POST['tokenSecret']));
}
try {
    /* wrap API method calls on the service object with a try catch */
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $massPayResponse = $paypalService->MassPay($massPayReq, $cred);
    } else {
        $massPayResponse = $paypalService->MassPay($massPayReq);
    }
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
session_start();
$logger = new PPLoggingManager('DoExpressCheckout');
$token = urlencode($_REQUEST['token']);
$payerId = urlencode($_REQUEST['payerID']);
$paymentAction = urlencode($_REQUEST['paymentAction']);
// ------------------------------------------------------------------
// this section is optional if parameters required for DoExpressCheckout is retrieved from your database
$getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
$getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
$getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
//----------------------------------------------------------------------------
$orderTotal = new BasicAmountType();
$orderTotal->currencyID = $_REQUEST['currencyCode'];
$orderTotal->value = $_REQUEST['amt'];
$paymentDetails = new PaymentDetailsType();
$paymentDetails->OrderTotal = $orderTotal;
if (isset($_REQUEST['notifyURL'])) {
    $paymentDetails->NotifyURL = $_REQUEST['notifyURL'];
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('TransactionSearch');
$transactionSearchRequest = new TransactionSearchRequestType();
$transactionSearchRequest->StartDate = $_REQUEST['startDate'];
$transactionSearchRequest->EndDate = $_REQUEST['endDate'];
$transactionSearchRequest->TransactionID = $_REQUEST['transactionID'];
$tranSearchReq = new TransactionSearchReq();
$tranSearchReq->TransactionSearchRequest = $transactionSearchRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $transactionSearchResponse = $paypalService->TransactionSearch($tranSearchReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($transactionSearchResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$transactionSearchResponse->Ack}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($transactionSearchResponse);
    echo "</pre>";
}
require_once '../Response.php';
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('GetAuthDetails');
$reqType = new GetAuthDetailsRequestType($_REQUEST['token']);
$req = new GetAuthDetailsReq();
$req->GetAuthDetailsRequest = $reqType;
$logger->info("created GetAuthDetailsRequest Object");
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $getAuthDetailsResponse = $paypalService->GetAuthDetails($req);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($getAuthDetailsResponse)) {
    echo "<pre>";
    print_r($getAuthDetailsResponse);
    echo "</pre>";
    if ($getAuthDetailsResponse->Ack == 'Success') {
        $payPalURL = 'https://www.sandbox.paypal.com/webscr&cmd=_account-authenticate-logout&token=' . $token;
        echo "<a href={$payPalURL}><b>* Redirect to paypal to logout</b></a><br>";
    }
}
require_once '../Response.php';
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('ManageRecurringPaymentsProfileStatus');
$manageRPPStatusReqestDetails = new ManageRecurringPaymentsProfileStatusRequestDetailsType();
$manageRPPStatusReqestDetails->Action = $_REQUEST['action'];
$manageRPPStatusReqestDetails->ProfileID = $_REQUEST['profileID'];
$manageRPPStatusReqest = new ManageRecurringPaymentsProfileStatusRequestType();
$manageRPPStatusReqest->ManageRecurringPaymentsProfileStatusRequestDetails = $manageRPPStatusReqestDetails;
$manageRPPStatusReqest->Version = 92;
$manageRPPStatusReq = new ManageRecurringPaymentsProfileStatusReq();
$manageRPPStatusReq->ManageRecurringPaymentsProfileStatusRequest = $manageRPPStatusReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
$manageRPPStatusResponse = $paypalService->ManageRecurringPaymentsProfileStatus($manageRPPStatusReq);
echo "<pre>";
print_r($manageRPPStatusResponse);
echo "</pre>";
require_once '../Response.php';
    $creditCardNumberType->CreditCardType = $_REQUEST['creditCardType'];
    $creditCard = new ReferenceCreditCardDetailsType();
    $creditCard->CardOwnerName = $cardOwner;
    $creditCard->BillingAddress = $billingAddress;
    $creditCard->CreditCardNumberType = $creditCardNumberType;
    $creditCard->CVV2 = $_REQUEST['CVV2'];
    $creditCard->ExpMonth = $_REQUEST['expMonth'];
    $creditCard->ExpYear = $_REQUEST['expYear'];
}
$paymentDetails = new PaymentDetailsType();
$paymentDetails->OrderTotal = $amount;
$paymentDetails->ShipToAddress = $shippingAddress;
$RTRequestDetails = new DoReferenceTransactionRequestDetailsType();
if (isset($_REQUEST['ReferenceCreditCardDetails']) && $_REQUEST['ReferenceCreditCardDetails'] == "ON") {
    $RTRequestDetails->CreditCard = $creditCard;
}
$RTRequestDetails->PaymentDetails = $paymentDetails;
$RTRequestDetails->ReferenceID = $_REQUEST['referenceID'];
$RTRequestDetails->PaymentAction = $_REQUEST['paymentAction'];
$RTRequestDetails->PaymentType = $_REQUEST['paymentType'];
$RTRequest = new DoReferenceTransactionRequestType();
$RTRequest->DoReferenceTransactionRequestDetails = $RTRequestDetails;
$RTRequest->Version = 92;
$RTReq = new DoReferenceTransactionReq();
$RTReq->DoReferenceTransactionRequest = $RTRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
$RTResponse = $paypalService->DoReferenceTransaction($RTReq);
echo "<pre>";
print_r($RTResponse);
echo "</pre>";
require_once '../Response.php';
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
/**
 * Get required parameters from the web form for the request
 */
$logger = new PPLoggingManager('GetBillingAgreementCustomerDetails');
$BACustomerDetailRequest = new GetBillingAgreementCustomerDetailsRequestType($_REQUEST['token']);
$BACustomerDetailReq = new GetBillingAgreementCustomerDetailsReq();
$BACustomerDetailReq->GetBillingAgreementCustomerDetailsRequest = $BACustomerDetailRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $BACustomerDetailResponse = $paypalService->GetBillingAgreementCustomerDetails($BACustomerDetailReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($BACustomerDetailResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$BACustomerDetailResponse->Ack}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($BACustomerDetailResponse);
    echo "</pre>";
}
require_once '../Response.php';
$PaymentDetails->PaymentAction = 'Sale';
$PaymentDetails->ItemTotal = $orderTotal;
$PaymentDetails->TaxTotal = $taxTotal;
$setECReqDetails = new SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $PaymentDetails;
$setECReqDetails->CancelURL = $cancelUrl;
$setECReqDetails->ReturnURL = $returnUrl;
$setECReqDetails->ReqConfirmShipping = 0;
$setECReqDetails->NoShipping = 1;
$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReqType->Version = '92.0';
$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
// storing in session to use in DoExpressCheckout
$_SESSION['amount'] = $_REQUEST['amount'];
$_SESSION['currencyID'] = $_REQUEST['currencyId'];
$PayPal_service = new PayPalAPIInterfaceServiceService();
$setECResponse = $PayPal_service->SetExpressCheckout($setECReq);
// echo '<pre>';
//print_r($setECResponse);
// echo '</pre>';
if ($setECResponse->Ack == 'Success') {
    $token = $setECResponse->Token;
    /*
    		$payPalURL = 'https://www.sandbox.paypal.com/incontext?token=' . $token;
    	header("Location: ".$payPalURL);*/
    echo "<br><br><br><br><br><br><br><br><a href=https://www.sandbox.paypal.com/incontext?token={$token} />Click here to continue to https://www.sandbox.paypal.com/incontext?token={$token}</a>";
} else {
    echo "error in SetEC API call";
}
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('billing agreement update');
$BAUpdateRequest = new BAUpdateRequestType($_REQUEST['referenceID']);
$BAUpdateRequest->BillingAgreementStatus = $_REQUEST['billingAgreementStatus'];
$BAUpdateRequest->BillingAgreementDescription = $_REQUEST['billingAgreementDescription'];
$billingAgreementUpdateReq = new BillAgreementUpdateReq();
$billingAgreementUpdateReq->BAUpdateRequest = $BAUpdateRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $BAUpdatResponse = $paypalService->BillAgreementUpdate($billingAgreementUpdateReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($BAUpdatResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$BAUpdatResponse->Ack}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($BAUpdatResponse);
    echo "</pre>";
}
require_once '../Response.php';
Exemple #22
0
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('BMGetButtonDetails');
$itemTrackingDetails = new ItemTrackingDetailsType();
$itemTrackingDetails->ItemQty = $_REQUEST['itemQty'];
$itemTrackingDetails->ItemCost = $_REQUEST['itemCost'];
$BMSetInventoryReqest = new BMSetInventoryRequestType();
$BMSetInventoryReqest->HostedButtonID = $_REQUEST['hostedID'];
$BMSetInventoryReqest->Version = 86.0;
$BMSetInventoryReqest->TrackInv = $_REQUEST['trackInv'];
$BMSetInventoryReqest->TrackPnl = $_REQUEST['trackPnl'];
$BMSetInventoryReqest->ItemTrackingDetails = $itemTrackingDetails;
$BMSetInventoryReq = new BMSetInventoryReq();
$BMSetInventoryReq->BMSetInventoryRequest = $BMSetInventoryReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
$BMSetInventoryResponse = $paypalService->BMSetInventory($BMSetInventoryReq);
echo "<pre>";
print_r($BMSetInventoryResponse);
echo "</pre>";
require_once '../Response.php';
 private function pay_vendors($vendors)
 {
     if (empty($vendors)) {
         $return = array('status' => 'error', 'msg' => __('No vendors found to pay. Maybe they haven\'t set a PayPal address?', 'eddc'));
         $this->mail_results($return);
         return $return;
     }
     $this->include_paypal_sdk();
     $logger = new PPLoggingManager('MassPay');
     $massPayRequest = new MassPayRequestType();
     $massPayRequest->MassPayItem = array();
     $total_pay = 0;
     foreach ($vendors as $user_paypal => $user) {
         // Don't attempt to process payments for users that owe the admin money
         if ($user['total_due'] <= 0) {
             continue;
         }
         $total_pay += $user['total_due'];
         $masspayItem = new MassPayRequestItemType();
         $masspayItem->Amount = new BasicAmountType(edd_get_currency(), $user['total_due']);
         $masspayItem->ReceiverEmail = $user_paypal;
         $massPayRequest->MassPayItem[] = $masspayItem;
     }
     $massPayReq = new MassPayReq();
     $massPayReq->MassPayRequest = $massPayRequest;
     $paypalService = new PayPalAPIInterfaceServiceService();
     // Wrap API method calls on the service object with a try catch
     try {
         $massPayResponse = $paypalService->MassPay($massPayReq);
     } catch (Exception $ex) {
         $return = array('status' => 'error', 'msg' => sprintf(__('Error: %s', 'eddc'), $ex->getMessage()), 'total' => $total_pay);
         return $return;
     }
     $return = array();
     if (isset($massPayResponse)) {
         if ($massPayResponse->Ack === 'Success') {
             if ($this->purge_user_meta($vendors)) {
                 $return = array('status' => 'updated', 'msg' => __('All due commission has been paid for.', 'eddc'), 'total' => $total_pay);
             } else {
                 $return = array('status' => 'error', 'msg' => __('All due commission has been paid for, but I could not clear it from their profiles due to an internal error. Commission will still be listed as due. Please manually mark the commission as paid from the Commissions page.', 'eddc'), 'total' => $total_pay);
             }
         } else {
             $return = array('status' => 'error', 'msg' => sprintf('%s. %s (%s): %s.', $massPayResponse->Ack, $massPayResponse->Errors->ShortMessage, $massPayResponse->Errors->ErrorCode, $massPayResponse->Errors->LongMessage), 'total' => $total_pay);
         }
     }
     $this->mail_results($return);
     return $return;
 }
 public function doEC()
 {
     $logger = new PPLoggingManager('DoExpressCheckout');
     // ## DoExpressCheckoutPaymentReq
     $doExpressCheckoutPaymentReq = new DoExpressCheckoutPaymentReq();
     $doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
     // The timestamped token value that was returned in the
     // `SetExpressCheckout` response and passed in the
     // `GetExpressCheckoutDetails` request.
     $doExpressCheckoutPaymentRequestDetails->Token = "EC-2XW434901C650622T";
     // Unique paypal buyer account identification number as returned in
     // `GetExpressCheckoutDetails` Response
     $doExpressCheckoutPaymentRequestDetails->PayerID = "A9BVYX8XCR9ZQ";
     // ### Payment Information
     // list of information about the payment
     $paymentDetailsList = array();
     // information about the first payment
     $paymentDetails1 = new PaymentDetailsType();
     // Total cost of the transaction to the buyer. If shipping cost and tax
     // charges are known, include them in this value. If not, this value
     // should be the current sub-total of the order.
     //
     // If the transaction includes one or more one-time purchases, this field must be equal to
     // the sum of the purchases. Set this field to 0 if the transaction does
     // not include a one-time purchase such as when you set up a billing
     // agreement for a recurring payment that is not immediately charged.
     // When the field is set to 0, purchase-specific fields are ignored.
     //
     // * `Currency Code` - You must set the currencyID attribute to one of the
     // 3-character currency codes for any of the supported PayPal
     // currencies.
     // * `Amount`
     $orderTotal1 = new BasicAmountType("USD", "2.00");
     $paymentDetails1->OrderTotal = $orderTotal1;
     // How you want to obtain payment. When implementing parallel payments,
     // this field is required and must be set to `Order`. When implementing
     // digital goods, this field is required and must be set to `Sale`. If the
     // transaction does not include a one-time purchase, this field is
     // ignored. It is one of the following values:
     //
     // * `Sale` - This is a final sale for which you are requesting payment
     // (default).
     // * `Authorization` - This payment is a basic authorization subject to
     // settlement with PayPal Authorization and Capture.
     // * `Order` - This payment is an order authorization subject to
     // settlement with PayPal Authorization and Capture.
     // Note:
     // You cannot set this field to Sale in SetExpressCheckout request and
     // then change the value to Authorization or Order in the
     // DoExpressCheckoutPayment request. If you set the field to
     // Authorization or Order in SetExpressCheckout, you may set the field
     // to Sale.
     $paymentDetails1->PaymentAction = "Order";
     // Unique identifier for the merchant. For parallel payments, this field
     // is required and must contain the Payer Id or the email address of the
     // merchant.
     $sellerDetails1 = new SellerDetailsType();
     $sellerDetails1->PayPalAccountID = "*****@*****.**";
     $paymentDetails1->SellerDetails = $sellerDetails1;
     // A unique identifier of the specific payment request, which is
     // required for parallel payments.
     $paymentDetails1->PaymentRequestID = "PaymentRequest1";
     // Your URL for receiving Instant Payment Notification (IPN) about this transaction. If you do not specify this value in the request, the notification URL from your Merchant Profile is used, if one exists.
     $paymentDetails1->NotifyURL = "http://localhost/ipn";
     // information about the second payment
     $paymentDetails2 = new PaymentDetailsType();
     // Total cost of the transaction to the buyer. If shipping cost and tax
     // charges are known, include them in this value. If not, this value
     // should be the current sub-total of the order.
     //
     // If the transaction includes one or more one-time purchases, this field must be equal to
     // the sum of the purchases. Set this field to 0 if the transaction does
     // not include a one-time purchase such as when you set up a billing
     // agreement for a recurring payment that is not immediately charged.
     // When the field is set to 0, purchase-specific fields are ignored.
     //
     // * `Currency Code` - You must set the currencyID attribute to one of the
     // 3-character currency codes for any of the supported PayPal
     // currencies.
     // * `Amount`
     $orderTotal2 = new BasicAmountType("USD", "4.00");
     $paymentDetails2->OrderTotal = $orderTotal2;
     // How you want to obtain payment. When implementing parallel payments,
     // this field is required and must be set to `Order`. When implementing
     // digital goods, this field is required and must be set to `Sale`. If the
     // transaction does not include a one-time purchase, this field is
     // ignored. It is one of the following values:
     //
     // * `Sale` - This is a final sale for which you are requesting payment
     // (default).
     // * `Authorization` - This payment is a basic authorization subject to
     // settlement with PayPal Authorization and Capture.
     // * `Order` - This payment is an order authorization subject to
     // settlement with PayPal Authorization and Capture.
     // `Note:
     // You cannot set this field to Sale in SetExpressCheckout request and
     // then change the value to Authorization or Order in the
     // DoExpressCheckoutPayment request. If you set the field to
     // Authorization or Order in SetExpressCheckout, you may set the field
     // to Sale.`
     $paymentDetails2->PaymentAction = "Order";
     // Unique identifier for the merchant. For parallel payments, this field
     // is required and must contain the Payer Id or the email address of the
     // merchant.
     $sellerDetails2 = new SellerDetailsType();
     $sellerDetails2->PayPalAccountID = "*****@*****.**";
     $paymentDetails2->SellerDetails = $sellerDetails2;
     // A unique identifier of the specific payment request, which is
     // required for parallel payments.
     $paymentDetails2->PaymentRequestID = "PaymentRequest2";
     // Your URL for receiving Instant Payment Notification (IPN) about this transaction. If you do not specify this value in the request, the notification URL from your Merchant Profile is used, if one exists.
     $paymentDetails2->NotifyURL = "http://localhost/ipn";
     $paymentDetailsList[0] = $paymentDetails1;
     $paymentDetailsList[1] = $paymentDetails2;
     $doExpressCheckoutPaymentRequestDetails->PaymentDetails = $paymentDetailsList;
     $doExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType($doExpressCheckoutPaymentRequestDetails);
     $doExpressCheckoutPaymentReq->DoExpressCheckoutPaymentRequest = $doExpressCheckoutPaymentRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->DoExpressCheckoutPayment($doExpressCheckoutPaymentReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Transaction identification number of the transaction that was
         // created.
         // This field is only returned after a successful transaction
         // for DoExpressCheckout has occurred.
         if ($doExpressCheckoutPaymentResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo != null) {
             $paymentInfoArray = $doExpressCheckoutPaymentResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo;
             foreach ($paymentInfoArray as $payInfo) {
                 $logger->log("Transaction ID : " . $payInfo->TransactionID);
             }
         }
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
$cardDetails->CreditCardType = $_POST['creditCardType'];
$cardDetails->ExpMonth = $_POST['expDateMonth'];
$cardDetails->ExpYear = $_POST['expDateYear'];
$cardDetails->CVV2 = $_POST['cvv2Number'];
$cardDetails->CardOwner = $payer;
$ddReqDetails = new DoDirectPaymentRequestDetailsType();
$ddReqDetails->CreditCard = $cardDetails;
$ddReqDetails->PaymentDetails = $paymentDetails;
$doDirectPaymentReq = new DoDirectPaymentReq();
$doDirectPaymentReq->DoDirectPaymentRequest = new DoDirectPaymentRequestType($ddReqDetails);
/*
 * 		 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $doDirectPaymentResponse = $paypalService->DoDirectPayment($doDirectPaymentReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($doDirectPaymentResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$doDirectPaymentResponse->Ack}</div> </td></tr>";
    echo "<tr><td>TransactionID :</td><td><div id='TransactionID'>{$doDirectPaymentResponse->TransactionID}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($doDirectPaymentResponse);
    echo "</pre>";
$bmManageButtonStatusReqest = new BMManageButtonStatusRequestType();
/*
 * (Required) The ID of the hosted button whose status you want to change.
 */
$bmManageButtonStatusReqest->HostedButtonID = $_REQUEST['hostedID'];
/*
 *  (Required) The new status of the button. It is one of the following values:
   DELETE - the button is deleted from PayPal
*/
$bmManageButtonStatusReqest->ButtonStatus = $_REQUEST['buttonStatus'];
$BMManageButtonStatusReq = new BMManageButtonStatusReq();
$BMManageButtonStatusReq->BMManageButtonStatusRequest = $bmManageButtonStatusReqest;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    $bmManageButtonStatusResponse = $paypalService->BMManageButtonStatus($BMManageButtonStatusReq);
} catch (Exception $ex) {
    require '../Error.php';
    exit;
}
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>{$bmManageButtonStatusResponse->Ack}</div> </td></tr>";
echo "</table>";
echo "<pre>";
print_r($bmManageButtonStatusResponse);
echo "</pre>";
require_once '../Response.php';
Exemple #27
0
<?php

$path = '../../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('Bill User');
$amount = new BasicAmountType();
$amount->currencyID = $_REQUEST['currencyID'];
$amount->value = $_REQUEST['amt'];
$MPPaymentDetails = new MerchantPullPaymentType();
$MPPaymentDetails->Amount = $amount;
$MPPaymentDetails->PaymentType = $_REQUEST['paymentCodeType'];
$MPPaymentDetails->EmailSubject = $_REQUEST['mailSubject'];
$MPPaymentDetails->ItemName = $_REQUEST['itemName'];
$MPPaymentDetails->ItemNumber = $_REQUEST['itemNum'];
$MPPaymentDetails->Memo = $_REQUEST['memo'];
$MPPaymentDetails->MpID = $_REQUEST['billingAgreementID'];
$billUserReqest = new BillUserRequestType();
$billUserReqest->MerchantPullPaymentDetails = $MPPaymentDetails;
$billUserReqest->Version = 92;
$billUserReq = new BillUserReq();
$billUserReq->BillUserRequest = $billUserReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
$billUserResponse = $paypalService->BillUser($billUserReq);
echo "<pre>";
print_r($billUserResponse);
echo "</pre>";
require_once '../Response.php';
<?php

require_once '../PPBootStrap.php';
/*
 * Use the BMGetInventory API operation to determine the inventory levels and other inventory-related information for a button and menu items associated with the button. Typically, you call BMGetInventory to obtain field values before calling BMSetInventory to change the inventory levels. 
 */
/*
 * (Required) The ID of the hosted button whose inventory information you want to obtain.
 */
$bmGetInventoryReqest = new BMGetInventoryRequestType($_REQUEST['hostedID']);
$bmGetInventoryReq = new BMGetInventoryReq();
$bmGetInventoryReq->BMGetInventoryRequest = $bmGetInventoryReqest;
/*
 * Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    $bmGetInventoryResponse = $paypalService->BMGetInventory($bmGetInventoryReq);
} catch (Exception $ex) {
    require '../Error.php';
    exit;
}
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>{$bmGetInventoryResponse->Ack}</div> </td></tr>";
echo "<tr><td>HostedButtonID :</td><td><div id='HostedButtonID'>{$bmGetInventoryResponse->HostedButtonID}</div> </td></tr>";
echo "</table>";
echo "<pre>";
print_r($bmGetInventoryResponse);
echo "</pre>";
require_once '../Response.php';
Exemple #29
0
* `CompleteCode` - Indicates whether or not this is your last capture.
It is one of the following values:
* Complete – This is the last capture you intend to make.
* NotComplete – You intend to make additional captures.
`Note:
If Complete, any remaining amount of the original authorized
transaction is automatically voided and all remaining open
authorizations are voided.`
*/
$doCaptureReqest = new DoCaptureRequestType($_REQUEST['authID'], $amount, $_REQUEST['completeCodeType']);
$doCaptureReq = new DoCaptureReq();
$doCaptureReq->DoCaptureRequest = $doCaptureReqest;
/*
 *  ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $doCaptureResponse = $paypalService->DoCapture($doCaptureReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($doCaptureResponse)) {
    echo "<pre>";
    print_r($doCaptureResponse);
    echo "</pre>";
}
require_once '../Response.php';
 public function actionPay($id)
 {
     $reservation = Reservation::model()->findByPk($id);
     if (isset($reservation)) {
         Yii::app()->session['llegada'] = $reservation->arrival_date;
         Yii::app()->session['salida'] = $reservation->departure_date;
         Yii::app()->session['maxPersonas'] = $reservation->number_people;
         Yii::app()->session['total'] = $reservation->total;
         $count = 0;
         $habitacion = [];
         foreach (RoomsBooked::model()->findAllByAttributes(array('reservation_id' => $reservation->id)) as $i => $rb) {
             $count += $rb->quantity;
             for ($i = 0; $i < $rb->quantity; $i++) {
                 $n = 'room_' . TypeRoom::model()->findByPk($rb->type_room_id)->name . '_name';
                 array_push($habitacion, Yii::t('rooms', $n));
             }
         }
         Yii::app()->session['habitacion'] = $habitacion;
         Yii::app()->session['habitaciones'] = $count;
         /* paypal */
         require_once 'paypal/PPBootStrap.php';
         $buttonVar = array("item_name=reservacion", "item_number=" . $this->generateRandomString(3) . $reservation->id . $this->generateRandomString(1), "return=" . Yii::app()->request->getBaseUrl(true) . "#cuenta", "business=marisaloorv@yahoo.com", "amount=" . $reservation->total, "notify_url=" . Yii::app()->request->getBaseUrl(true) . "/site/ipn", "no_shipping=1", "cancel_return=" . Yii::app()->request->getBaseUrl(true) . "#cuenta");
         $createButtonRequest = new BMCreateButtonRequestType();
         $createButtonRequest->ButtonCode = "ENCRYPTED";
         $createButtonRequest->ButtonType = "BUYNOW";
         $createButtonRequest->ButtonSubType = 'SERVICES';
         $createButtonRequest->BuyNowText = 'PAYNOW';
         $createButtonRequest->ButtonLanguage = 'es';
         $createButtonRequest->ButtonImageURL = Yii::app()->request->getBaseUrl(true) . "/images/paypal.png";
         $createButtonRequest->ButtonVar = $buttonVar;
         $createButtonReq = new BMCreateButtonReq();
         $createButtonReq->BMCreateButtonRequest = $createButtonRequest;
         $paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
         try {
             $createButtonResponse = $paypalService->BMCreateButton($createButtonReq);
             if ($createButtonResponse->Ack == 'Success') {
                 Yii::app()->session['button'] = $createButtonResponse->Website;
             } else {
                 $this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
             }
         } catch (Exception $ex) {
             print_r($ex);
             die;
         }
         /* --- */
         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#pagar');
     } else {
         $this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
     }
 }