public function details()
 {
     $logger = new PPLoggingManager('PaymentDetails');
     // ##PaymentDetailsRequest
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope("en_US");
     // PaymentDetailsRequest which takes,
     // `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     $paymentDetailsReq = new PaymentDetailsRequest($requestEnvelope);
     // You must specify either,
     //
     // * `Pay Key` - The pay key that identifies the payment for which you want to retrieve details. This is the pay key returned in the PayResponse message.
     // * `Transaction ID` - The PayPal transaction ID associated with the payment. The IPN message associated with the payment contains the transaction ID.
     // `paymentDetailsRequest.setTransactionId(transactionId)`
     // * `Tracking ID` - The tracking ID that was specified for this payment in the PayRequest message.
     // `paymentDetailsRequest.setTrackingId(trackingId)`
     $paymentDetailsReq->payKey = "AP-86H50830VE600922B";
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new AdaptivePaymentsService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->PaymentDetails($paymentDetailsReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " . $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters in
     // response object as shown below
     // ### Success values
     if ($response->responseEnvelope->ack == "Success") {
         // The status of the payment. Possible values are:
         //
         // * CREATED - The payment request was received; funds will be
         // transferred once the payment is approved
         // * COMPLETED - The payment was successful
         // * INCOMPLETE - Some transfers succeeded and some failed for a
         // parallel payment or, for a delayed chained payment, secondary
         // receivers have not been paid
         // * ERROR - The payment failed and all attempted transfers failed
         // or all completed transfers were successfully reversed
         // * REVERSALERROR - One or more transfers failed when attempting
         // to reverse a payment
         // * PROCESSING - The payment is in progress
         // * PENDING - The payment is awaiting processing
         $logger->log("Payment Status : " . $response->status);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
 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 search()
 {
     $logger = new PPLoggingManager('SearchInvoices');
     // ##SearchInvoicesRequest
     // Use the SearchInvoiceRequest message to search an invoice.
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->ErrorLanguage = "en_US";
     $parameters = new SearchParametersType();
     // Invoice amount search. It specifies the smallest amount to be
     // returned. If you pass a value for this field, you must also pass a
     // currencyCode value.
     $parameters->UpperAmount = "4.00";
     // Currency used for lower and upper amounts. It is required when you
     // specify lowerAmount or upperAmount.
     $parameters->CurrencyCode = "USD";
     // SearchInvoicesRequest which takes mandatory params:
     //
     // * `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     // * `Merchant Email` - Email address of invoice creator.
     // * `SearchParameters` - Parameters constraining the search.
     // * `Page` - Page number of result set, starting with 1.
     // * `Page Size` - Number of results per page, between 1 and 100.
     $searchInvoicesRequest = new SearchInvoicesRequest($requestEnvelope, "*****@*****.**", $parameters, "1", "10");
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new InvoiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->SearchInvoices($searchInvoicesRequest);
     } 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->responseEnvelope->ack == "Success") {
         // Number of invoices that matched the request.
         $logger->log("Count : " . $response->count);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     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 getDetails()
 {
     $logger = new PPLoggingManager('GetInvoiceDetails');
     // ##GetInvoiceDetailsRequest
     // Use the GetInvoiceDetailsRequest message to get detailed information
     // about an invoice.
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->ErrorLanguage = "en_US";
     // GetInvoiceDetailsRequest which takes mandatory params:
     //
     // * `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     // * `Invoice ID` - ID of the invoice to retrieve.
     $getInvoiceDetailsRequest = new GetInvoiceDetailsRequest($requestEnvelope, "INV2-ZC9R-X6MS-RK8H-4VKJ");
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new InvoiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->GetInvoiceDetails($getInvoiceDetailsRequest);
     } 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->responseEnvelope->ack == "Success") {
         // Status of the invoice searched.
         $logger->log("Status : " . $response->invoiceDetails->status);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
 public function send()
 {
     $logger = new PPLoggingManager('SendInvoice');
     // ##SendInvoiceRequest
     // Use the SendInvoiceRequest message to send an invoice to a payer, and
     // notify the payer of the pending invoice.
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->ErrorLanguage = "en_US";
     // SendInvoiceRequest which takes mandatory params:
     //
     // * `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     // * `Invoice ID` - ID of the invoice to send.
     $sendInvoiceRequest = new SendInvoiceRequest($requestEnvelope, "INV2-EBLC-RUQ9-DF6Z-H86C");
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new InvoiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->SendInvoice($sendInvoiceRequest);
     } 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->responseEnvelope->ack == "Success") {
         // ID of the created invoice.
         $logger->log("Invoice ID : " . $response->invoiceID);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     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 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 preapproveDetails()
 {
     $logger = new PPLoggingManager('PreapprovalDetails');
     // ##PreapprovaDetailslRequest
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope("en_US");
     // `PreapprovalDetailsRequest` object which takes mandatory params:
     //
     // * `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     // * `Preapproval Key` - A preapproval key that identifies the
     // preapproval for which you want to retrieve details. The preapproval
     // key is returned in the PreapprovalResponse message.
     $preapprovalDetailsRequest = new PreapprovalDetailsRequest($requestEnvelope, "PA-1KM93450LF5424305");
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new AdaptivePaymentsService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->PreapprovalDetails($preapprovalDetailsRequest);
     } catch (Exception $ex) {
         $logger->error("Error Message : " . $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters in
     // response object as shown below
     // ### Success values
     if ($response->responseEnvelope->ack == "Success") {
         // First date for which the preapproval is valid.
         $logger->log("Starting Date : " . $response->startingDate);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     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;
 }
Example #12
0
 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';
$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';
Example #15
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('GetAuthDetails');
$token = $_REQUEST['token'];
$reqType = new GetAuthDetailsRequestType();
$reqType->Token = $token;
$reqType->Version = 92.0;
$req = new GetAuthDetailsReq();
$req->GetAuthDetailsRequest = $reqType;
$logger->error("created GetAuthDetailsRequest Object");
$paypalService = new PayPalAPIInterfaceServiceService();
$getAuthDetailsResponse = $paypalService->GetAuthDetails($req);
//$logger->error("");
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/AdaptivePayments/AdaptivePaymentsService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('GetPaymentOptions');
// create request
$requestEnvelope = new RequestEnvelope("en_US");
$getPaymentOptionsReq = new GetPaymentOptionsRequest($requestEnvelope, $_POST['payKey']);
$logger->log("Created GetPaymentOptionsRequest Object");
$service = new AdaptivePaymentsService();
try {
    $response = $service->GetPaymentOptions($getPaymentOptionsReq);
    $logger->error("Received GetPaymentOptionsResponse:");
    $ack = strtoupper($response->responseEnvelope->ack);
} catch (Exception $ex) {
    throw new Exception('Error occurred in GetPaymentOptions method');
}
if ($ack != "SUCCESS") {
    echo "<b>Error </b>";
    echo "<pre>";
    print_r($response);
    echo "</pre>";
    require_once 'Common/Response.php';
    exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
Example #17
0
 public function refundTheAmt()
 {
     $logger = new PPLoggingManager('Refund');
     // ##RefundRequest
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope("en_US");
     // `RefundRequest` which takes,
     // `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     $refundRequest = new RefundRequest($requestEnvelope);
     // You must specify either,
     //
     // * `Pay Key` - The pay key that identifies the payment for which you
     // want to retrieve details. This is the pay key returned in the
     // PayResponse message.
     // * `Transaction ID` - The PayPal transaction ID associated with the
     // payment. The IPN message associated with the payment contains the
     // transaction ID.
     // `$refundRequest->transactionId`
     // * `Tracking ID` - The tracking ID that was specified for this payment
     // in the PayRequest message.
     // `$refundRequest->trackingId`
     $refundRequest->payKey = "AP-6KL026467X0532357";
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new AdaptivePaymentsService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->Refund($refundRequest);
     } 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->responseEnvelope->ack == "Success") {
         // List of refunds associated with the payment.
         $refundList = $response->refundInfoList->refundInfo;
         // Represents the refund attempt made to a receiver of a
         // PayRequest.
         foreach ($refundList as $refundInfo) {
             // Status of the refund. It is one of the following values:
             //
             // * REFUNDED - Refund successfully completed
             // * REFUNDED_PENDING - Refund awaiting transfer of funds; for
             // example, a refund paid by eCheck.
             // * NOT_PAID - Payment was never made; therefore, it cannot
             // be refunded.
             // * ALREADY_REVERSED_OR_REFUNDED - Request rejected because
             // the refund was already made, or the payment was reversed
             // prior to this request.
             // * NO_API_ACCESS_TO_RECEIVER - Request cannot be completed
             // because you do not have third-party access from the
             // receiver to make the refund.
             // * REFUND_NOT_ALLOWED - Refund is not allowed.
             // * INSUFFICIENT_BALANCE - Request rejected because the
             // receiver from which the refund is to be paid does not
             // have sufficient funds or the funding source cannot be
             // used to make a refund.
             // * AMOUNT_EXCEEDS_REFUNDABLE - Request rejected because you
             // attempted to refund more than the remaining amount of the
             // payment; call the PaymentDetails API operation to
             // determine the amount already refunded.
             // * PREVIOUS_REFUND_PENDING - Request rejected because a
             // refund is currently pending for this part of the payment
             // * NOT_PROCESSED - Request rejected because it cannot be
             // processed at this time
             // * REFUND_ERROR - Request rejected because of an internal
             // error
             // * PREVIOUS_REFUND_ERROR - Request rejected because another
             // part of this refund caused an internal error.
             $logger->log("Refund Status : " . $refundInfo->refundStatus);
         }
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
 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;
 }
Example #19
0
<?php

$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/AdaptivePayments/AdaptivePaymentsService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('GetFundingPlans');
// create request
$getFundingPlansReq = new GetFundingPlansRequest(new RequestEnvelope("en_US"), $_POST['payKey']);
$logger->log("Created GetFundingPlansRequest Object");
$service = new AdaptivePaymentsService();
try {
    $response = $service->GetFundingPlans($getFundingPlansReq);
    $logger->error("Received GetFundingPlansResponse:");
    $ack = strtoupper($response->responseEnvelope->ack);
} catch (Exception $ex) {
    throw new Exception('Error occurred in GetFundingPlans method');
}
if ($ack != "SUCCESS") {
    echo "<b>Error </b>";
    echo "<pre>";
    print_r($response);
    echo "</pre>";
    require_once 'Common/Response.php';
    exit;
}
?>
<!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 Payment - Get Funding Plans</title>
<?php

$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/AdaptivePayments/AdaptivePaymentsService.php';
require_once 'PPLoggingManager.php';
$logger = new PPLoggingManager('GetAvailableShippingAddresses');
// create request
$getAvailableShippingAddressesReq = new GetAvailableShippingAddressesRequest(new RequestEnvelope("en_US"), $_POST['key']);
$logger->log("Created GetAvailableShippingAddressesRequest Object");
$service = new AdaptivePaymentsService();
try {
    $response = $service->GetAvailableShippingAddresses($getAvailableShippingAddressesReq);
    $logger->error("Received GetAvailableShippingAddressesResponse:");
    $ack = strtoupper($response->responseEnvelope->ack);
} catch (Exception $ex) {
    throw new Exception('Error occurred in GetAvailableShippingAddresses method');
}
if ($ack != "SUCCESS") {
    echo "<b>Error </b>";
    echo "<pre>";
    print_r($response);
    echo "</pre>";
    require_once 'Common/Response.php';
    exit;
}
?>
<!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 Payment - Get Available Shipping Addresses</title>
Example #21
0
<?php

$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/AdaptivePayments/AdaptivePaymentsService.php';
require_once 'PPLoggingManager.php';
define("DEFAULT_SELECT", "- Select -");
$logger = new PPLoggingManager('PreApproval');
// create request
$requestEnvelope = new RequestEnvelope("en_US");
$preapprovalRequest = new PreapprovalRequest($requestEnvelope, $_POST['cancelUrl'], $_POST['currencyCode'], $_POST['returnUrl'], $_POST['startingDate']);
// Set optional params
if ($_POST['dateOfMonth'] != null) {
    $preapprovalRequest->dateOfMonth = $_POST['dateOfMonth'];
}
if ($_POST['dayOfWeek'] != null && $_POST['dayOfWeek'] != DEFAULT_SELECT) {
    $preapprovalRequest->dayOfWeek = $_POST['dayOfWeek'];
}
if ($_POST['dateOfMonth'] != null) {
    $preapprovalRequest->dateOfMonth = $_POST['dateOfMonth'];
}
if ($_POST['endingDate'] != null) {
    $preapprovalRequest->endingDate = $_POST['endingDate'];
}
if ($_POST['maxAmountPerPayment'] != null) {
    $preapprovalRequest->maxAmountPerPayment = $_POST['maxAmountPerPayment'];
}
if ($_POST['maxNumberOfPayments'] != null) {
    $preapprovalRequest->maxNumberOfPayments = $_POST['maxNumberOfPayments'];
}
if ($_POST['maxNumberOfPaymentsPerPeriod'] != null) {
 public function doDirectPay()
 {
     $logger = new PPLoggingManager('DoDirectPayment');
     // ## DoDirectPaymentReq
     $doDirectPaymentReq = new DoDirectPaymentReq();
     $doDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();
     // Information about the credit card to be charged.
     $creditCard = new CreditCardDetailsType();
     // Type of credit card. For UK, only Maestro, MasterCard, Discover, and
     // Visa are allowable. For Canada, only MasterCard and Visa are
     // allowable and Interac debit cards are not supported. It is one of the
     // following values:
     //
     // * Visa
     // * MasterCard
     // * Discover
     // * Amex
     // * Solo
     // * Switch
     // * Maestro: See note.
     // `Note:
     // If the credit card type is Maestro, you must set currencyId to GBP.
     // In addition, you must specify either StartMonth and StartYear or
     // IssueNumber.`
     $cardDetails->CreditCardType = "Visa";
     // Credit Card number
     $creditCard->CreditCardNumber = "4770461107194023";
     // ExpiryMonth of credit card
     $creditCard->ExpMonth = "12";
     // Expiry Year of credit card
     $creditCard->ExpYear = "2021";
     //Details about the owner of the credit card.
     $cardOwner = new PayerInfoType();
     // Email address of buyer.
     $cardOwner->Payer = "*****@*****.**";
     $creditCard->CardOwner = $cardOwner;
     $doDirectPaymentRequestDetails->CreditCard = $creditCard;
     // Information about the payment
     $paymentDetails = 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`
     $orderTotal = new BasicAmountType("USD", "4.00");
     $paymentDetails->OrderTotal = $orderTotal;
     //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.
     $paymentDetails->NotifyURL = "http://localhost/ipn";
     $doDirectPaymentRequestDetails->PaymentDetails = $paymentDetails;
     // IP address of the buyer's browser.
     // `Note:
     // PayPal records this IP addresses as a means to detect possible fraud.`
     $doDirectPaymentRequestDetails->IPAddress = "127.0.0.1";
     $doDirectPaymentRequest = new DoDirectPaymentRequestType($doDirectPaymentRequestDetails);
     $doDirectPaymentReq->DoDirectPaymentRequest = $doDirectPaymentRequest;
     // ## 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->DoDirectPayment($doDirectPaymentReq);
     } 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 identifier of the transaction
         $logger->log("Transaction ID :" . $response->TransactionID);
     } else {
         logger . severe("API Error Message : " . $response->Error[0]->LongMessage);
     }
     return $response;
 }
<?php

$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/AdaptivePayments/AdaptivePaymentsService.php';
require_once 'PPLoggingManager.php';
define("DEFAULT_SELECT", "- Select -");
$logger = new PPLoggingManager('SetPaymentOptions');
// create request
$setPaymentOptionsRequest = new SetPaymentOptionsRequest(new RequestEnvelope("en_US"));
// set optional params
if (isset($_POST['receiverEmail'])) {
    $receiver = array();
    for ($i = 0; $i < count($_POST['receiverEmail']); $i++) {
        $receiver[$i] = new Receiver();
        $receiver[$i]->email = $_POST['receiverEmail'][$i];
        $receiver[$i]->amount = $_POST['receiverAmount'][$i];
        $receiver[$i]->primary = $_POST['primaryReceiver'][$i];
        if ($_POST['invoiceId'][$i] != "") {
            $receiver[$i]->invoiceId = $_POST['invoiceId'][$i];
        }
        if ($_POST['paymentType'][$i] != "" && $_POST['paymentType'][$i] != DEFAULT_SELECT) {
            $receiver[$i]->paymentType = $_POST['paymentType'][$i];
        }
        if ($_POST['paymentSubType'][$i] != "") {
            $receiver[$i]->paymentSubType = $_POST['paymentSubType'][$i];
        }
        if ($_POST['phoneCountry'][$i] != "" && $_POST['phoneNumber'][$i]) {
            $receiver[$i]->phone = new PhoneNumberType($_POST['phoneCountry'][$i], $_POST['phoneNumber'][$i]);
            if ($_POST['phoneExtn'][$i] != "") {
                $receiver[$i]->phone->extension = $_POST['phoneExtn'][$i];
 /**
  * @test
  */
 public function testFine()
 {
     $this->object->fine('Test fine Message');
 }
Example #25
0
?>
<html>
<head>
	<title>CancelInvoice Sample API Page</title>
	<link rel="stylesheet" type="text/css" href="sdk.css"/>
	<script type="text/javascript" src="sdk.js"></script>
</head>
<body>
<h2>CancelInvoice API Test Page</h2>
<?php 
//get the current filename
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$currentFile = $parts[count($parts) - 1];
$_SESSION['curFile'] = $currentFile;
$logger = new PPLoggingManager('CancelInvoice');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // create request object
    $requestEnvelope = new RequestEnvelope("en_US");
    $cancelInvoiceRequest = new CancelInvoiceRequest($requestEnvelope);
    $cancelInvoiceRequest->invoiceID = $_POST['invoiceID'];
    $logger->info("created CancelInvoice Object");
    $invoiceService = new InvoiceService();
    // required in third party permissioning
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $invoiceService->setAccessToken($_POST['accessToken']);
        $invoiceService->setTokenSecret($_POST['tokenSecret']);
    }
    $cancelInvoiceResponse = $invoiceService->CancelInvoice($cancelInvoiceRequest, 'jb-us-seller_api1.paypal.com');
    $logger->info("Received CancelInvoiceResponse:");
    var_dump($cancelInvoiceResponse);
 public function createRecurringProfile()
 {
     $logger = new PPLoggingManager('CreateRecurringPaymentProfile');
     // ## CreateRecurringPaymentsProfileReq
     $createRPProfileReq = new CreateRecurringPaymentsProfileReq();
     $createRPProfileRequestType = new CreateRecurringPaymentsProfileRequestType();
     // You can include up to 10 recurring payments profiles per request. The
     // order of the profile details must match the order of the billing
     // agreement details specified in the SetExpressCheckout request which
     // takes mandatory argument:
     //
     // * `billing start date` - The date when billing for this profile begins.
     // `Note:
     // The profile may take up to 24 hours for activation.`
     $RPProfileDetails = new RecurringPaymentsProfileDetailsType("2013-12-31T13:01:19+00:00");
     // Billing amount for each billing cycle during this payment period.
     // This amount does not include shipping and tax amounts.
     // `Note:
     // All amounts in the CreateRecurringPaymentsProfile request must have
     // the same currency.`
     $billingAmount = new BasicAmountType("USD", "3.00");
     // Regular payment period for this schedule which takes mandatory
     // params:
     //
     // * `Billing Period` - Unit for billing during this subscription period. It is one of the
     // following values:
     // * Day
     // * Week
     // * SemiMonth
     // * Month
     // * Year
     // For SemiMonth, billing is done on the 1st and 15th of each month.
     // `Note:
     // The combination of BillingPeriod and BillingFrequency cannot exceed
     // one year.`
     // * `Billing Frequency` - Number of billing periods that make up one billing cycle.
     // The combination of billing frequency and billing period must be less
     // than or equal to one year. For example, if the billing cycle is
     // Month, the maximum value for billing frequency is 12. Similarly, if
     // the billing cycle is Week, the maximum value for billing frequency is
     // 52.
     // `Note:
     // If the billing period is SemiMonth, the billing frequency must be 1.`
     // * `Billing Amount`
     $paymentPeriod = new BillingPeriodDetailsType("Day", "5", $billingAmount);
     // Describes the recurring payments schedule, including the regular
     // payment period, whether there is a trial period, and the number of
     // payments that can fail before a profile is suspended which takes
     // mandatory params:
     //
     // * `Description` - Description of the recurring payment.
     // `Note:
     // You must ensure that this field matches the corresponding billing
     // agreement description included in the SetExpressCheckout request.`
     // * `Payment Period`
     $scheduleDetails = new ScheduleDetailsType("description", $paymentPeriod);
     // `CreateRecurringPaymentsProfileRequestDetailsType` which takes
     // mandatory params:
     //
     // * `Recurring Payments Profile Details`
     // * `Schedule Details`
     $createRecurringPaymentsProfileRequestDetails = new CreateRecurringPaymentsProfileRequestDetailsType($RPProfileDetails, $scheduleDetails);
     // Either EC token or a credit card number is required.If you include
     // both token and credit card number, the token is used and credit card number is
     // ignored
     // In case of setting EC token,
     // `createRecurringPaymentsProfileRequestDetails.setToken("EC-5KH01765D1724703R");`
     // A timestamped token, the value of which was returned in the response
     // to the first call to SetExpressCheckout. Call
     // CreateRecurringPaymentsProfile once for each billing
     // agreement included in SetExpressCheckout request and use the same
     // token for each call. Each CreateRecurringPaymentsProfile request
     // creates a single recurring payments profile.
     // `Note:
     // Tokens expire after approximately 3 hours.`
     // Credit card information for recurring payments using direct payments.
     $creditCard = new CreditCardDetailsType();
     // Type of credit card. For UK, only Maestro, MasterCard, Discover, and
     // Visa are allowable. For Canada, only MasterCard and Visa are
     // allowable and Interac debit cards are not supported. It is one of the
     // following values:
     //
     // * Visa
     // * MasterCard
     // * Discover
     // * Amex
     // * Solo
     // * Switch
     // * Maestro: See note.
     // `Note:
     // If the credit card type is Maestro, you must set currencyId to GBP.
     // In addition, you must specify either StartMonth and StartYear or
     // IssueNumber.`
     $creditCard->CreditCardType = "Visa";
     // Credit Card Number
     $creditCard->CreditCardNumber = "4442662639546634";
     // Credit Card Expiration Month
     $creditCard->ExpMonth = "12";
     // Credit Card Expiration Year
     $creditCard->ExpYear = "2016";
     $createRecurringPaymentsProfileRequestDetails->CreditCard = $creditCard;
     $createRPProfileRequestType->CreateRecurringPaymentsProfileRequestDetails = $createRecurringPaymentsProfileRequestDetails;
     $createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequestType;
     // ## 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->CreateRecurringPaymentsProfile($createRPProfileReq);
     } 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") {
         // A unique identifier for future reference to the details of
         // this recurring payment.
         $logger->log("Profile ID: " . $response->CreateRecurringPaymentsProfileResponseDetails->ProfileID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
 public function createSendInvoice()
 {
     $logger = new PPLoggingManager('CreateAndSendInvoice');
     // ##CreateAndSendInvoiceRequest
     // Use the CreateAndSendInvoiceRequest message to create and send a new
     // invoice. The requester should authenticate the caller and verify that
     // the merchant requesting the invoice has an existing PayPal account in
     // good standing. Once the invoice is created, PayPal sends it to the
     // specified payer, who is notified of the pending invoice.
     // The code for the language in which errors are returned, which must be
     // en_US.
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->ErrorLanguage = "en_US";
     $invoiceItemList = array();
     // InvoiceItemType which takes mandatory params:
     //
     // * `Item Name` - SKU or name of the item.
     // * `Quantity` - Item count.
     // * `Amount` - Price of the item, in the currency specified by the
     // invoice.
     $invoiceItem = new InvoiceItemType("Item", "2", "4.00");
     $invoiceItemList[0] = $invoiceItem;
     // Invoice item.
     $itemList = new InvoiceItemListType($invoiceItemList);
     // InvoiceType which takes mandatory params:
     //
     // * `Merchant Email` - Merchant email address.
     // * `Personal Email` - Payer email address.
     // * `InvoiceItemList` - List of items included in this invoice.
     // * `CurrencyCode` - Currency used for all invoice item amounts and
     // totals.
     // * `PaymentTerms` - Terms by which the invoice payment is due. It is
     // one of the following values:
     // * DueOnReceipt - Payment is due when the payer receives the invoice.
     // * DueOnDateSpecified - Payment is due on the date specified in the
     // invoice.
     // * Net10 - Payment is due 10 days from the invoice date.
     // * Net15 - Payment is due 15 days from the invoice date.
     // * Net30 - Payment is due 30 days from the invoice date.
     // * Net45 - Payment is due 45 days from the invoice date.
     $invoice = new InvoiceType("*****@*****.**", "*****@*****.**", $itemList, "USD", "DueOnReceipt");
     // CreateAndSendInvoiceRequest which takes mandatory params:
     //
     // * `Request Envelope` - Information common to each API operation, such
     // as the language in which an error message is returned.
     // * `Invoice` - Merchant, payer, and invoice information.
     $createAndSendInvoiceRequest = new CreateAndSendInvoiceRequest($requestEnvelope, $invoice);
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new InvoiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->CreateAndSendInvoice($createAndSendInvoiceRequest);
     } 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->responseEnvelope->ack == "Success") {
         // ID of the created invoice.
         $logger->log("Invoice ID : " . $response->invoiceID);
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
Example #28
0
 private function makeAPICall($payRequest)
 {
     $logger = new PPLoggingManager('Pay');
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new AdaptivePaymentsService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->Pay($payRequest);
     } catch (Exception $ex) {
         $logger->error("Error Message : " . $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters in
     // response object as shown below
     // ### Success values
     if ($response->responseEnvelope->ack == "Success") {
         // The pay key, which is a token you use in other Adaptive
         // Payment APIs (such as the Refund Method) to identify this
         // payment. The pay key is valid for 3 hours; the payment must
         // be approved while the pay key is valid.
         $logger->log("Pay Key : " . $response->payKey);
         // Once you get success response, user has to redirect to PayPal
         // for the payment. Construct redirectURL as follows,
         // `redirectURL=https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey="
         // + $response->payKey`
     } else {
         $logger->error("API Error Message : " . $response->error[0]->message);
     }
     return $response;
 }
Example #29
0
$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/Invoice/InvoiceService.php';
require_once 'PPLoggingManager.php';
session_start();
?>
<html>
<head>
	<title>SearchInvoices Sample API Page</title>
	<link rel="stylesheet" type="text/css" href="sdk.css"/>
	<script type="text/javascript" src="sdk.js"></script>
</head>
<body>
<h2>SearchInvoices API Test Page</h2>
<?php 
$logger = new PPLoggingManager('SearchInvoices');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // create request object
    $requestEnvelope = new RequestEnvelope("en_US");
    $merchantEmail = $_POST['merchantEmail'];
    $page = $_POST['pageNumber'];
    $pageSize = $_POST['pageSize'];
    $parameters = new SearchParametersType();
    $parameters->businessName = $_POST['businessName'];
    $parameters->currencyCode = $_POST['currencyCode'];
    $parameters->email = $_POST['email'];
    $parameters->recipientName = $_POST['recipientName'];
    $parameters->invoiceNumber = $_POST['invoiceNumber'];
    foreach ($_POST['status'] as $status) {
        if ($status != '') {
            $parameters->status[] = $status;
Example #30
0
?>
<html>
<head>
	<title>SendInvoice Sample API Page</title>
	<link rel="stylesheet" type="text/css" href="sdk.css"/>
	<script type="text/javascript" src="sdk.js"></script>
</head>
<body>
<h2>SendInvoice API Test Page</h2>
<?php 
//get the current filename
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$currentFile = $parts[count($parts) - 1];
$_SESSION['curFile'] = $currentFile;
$logger = new PPLoggingManager('SendInvoice');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // create request object
    $requestEnvelope = new RequestEnvelope("en_US");
    $sendInvoiceRequest = new SendInvoiceRequest($requestEnvelope, $_POST['invoiceID']);
    $logger->info("created SendInvoice Object");
    $invoiceService = new InvoiceService();
    // required in third party permissioning
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $invoiceService->setAccessToken($_POST['accessToken']);
        $invoiceService->setTokenSecret($_POST['tokenSecret']);
    }
    $sendInvoiceResponse = $invoiceService->SendInvoice($sendInvoiceRequest, 'jb-us-seller_api1.paypal.com');
    $logger->info("Received SendInvoiceResponse:");
    var_dump($sendInvoiceResponse);
} else {