Ejemplo n.º 1
0
 /**
  * @test
  */
 public function checkSendInvoice()
 {
     $env = new RequestEnvelope();
     $env->errorLanguage = "en_US";
     $env->detailLevel = "ReturnAll";
     $req = new SendInvoiceRequest();
     $req->invoiceID = self::$invoicID;
     $req->requestEnvelope = $env;
     $invc = new InvoiceService();
     $ret = $invc->SendInvoice($req);
     $this->assertNotNull($ret);
     $this->assertNotNull($ret->invoiceID);
     $this->assertEquals(0, count($ret->error));
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
      configuration file for your credentials and endpoint
 */
 $invoiceService = new InvoiceService(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 {
     /*
     *  ## Making API call
     			 Invoke the appropriate method corresponding to API in service
     			 wrapper object
     */
     if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
         $sendInvoiceResponse = $invoiceService->SendInvoice($sendInvoiceRequest, $cred);
     } else {
         $sendInvoiceResponse = $invoiceService->SendInvoice($sendInvoiceRequest);
     }
 } catch (Exception $ex) {
     require_once 'error.php';
     exit;
 }
 echo "<table>";
 echo "<tr><td>Ack :</td><td><div id='Ack'>" . $sendInvoiceResponse->responseEnvelope->ack . "</div> </td></tr>";
 echo "<tr><td>InvoiceID :</td><td><div id='InvoiceID'>" . $sendInvoiceResponse->invoiceID . "</div> </td></tr>";
 echo "</table>";
 require 'ShowAllResponse.php';
 echo "<pre>";
 var_dump($sendInvoiceResponse);
 echo "</pre>";
Ejemplo n.º 4
0
$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 {
    ?>

<form method="POST">
<div id="apidetails">SendInvoice API operation is used to send an invoice to a payer and notify the payer of the pending invoice.</div>
<div class="params">
<div class="param_name">Invoice ID</div>
<div class="param_value"><input type="text" name="invoiceID" value=""
	size="50" maxlength="260" /></div>
</div>
<?php 
    include 'permissions.php';
    ?>