コード例 #1
0
 /**
  * @test
  * Test case for permissions service integration
  */
 public function testCreateInvoiceForThirdParty()
 {
     $item1 = new InvoiceItemType('item_name1', '1', '1');
     $item2 = new InvoiceItemType('item_name2', '2', '2');
     $items = array($item1, $item2);
     $itemList = new InvoiceItemListType();
     $itemList->item = $items;
     $invoice = new InvoiceType('*****@*****.**', '*****@*****.**', $itemList, 'USD', 'DueOnReceipt');
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->errorLanguage = "en_US";
     $createInvoiceRequest = new CreateInvoiceRequest($requestEnvelope, $invoice);
     $invoice_service = new InvoiceService();
     $invoice_service->setAccessToken("iHJRdaLaHlROHt6OxkH29I53ZvCHdgEhBdMWxu4OyoB9AaKkS5YlWw");
     $invoice_service->setTokenSecret("3M5zkwsU-F0OKhvsuSJmITYJueg");
     $ret = $invoice_service->CreateInvoice($createInvoiceRequest, 'jb-us-seller_api1.paypal.com');
     $this->assertNotNull($ret);
 }
コード例 #2
0
 public function invoice()
 {
     $logger = new PPLoggingManager('CreateInvoice');
     // ##CreateInvoiceRequest
     // Use the CreateInvoiceRequest message to create a new invoice. The
     // merchant issuing the invoice, and the partner, if any, making the
     // call, must have a PayPal account in good standing.
     // 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");
     // CreateInvoiceRequest 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.
     $createInvoiceRequest = new CreateInvoiceRequest($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->CreateInvoice($createInvoiceRequest);
     } 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;
 }
コード例 #3
0
ファイル: InvoiceServiceTest.php プロジェクト: kashyapkk/SDKs
 /**
  * @test
  */
 public function testCreateAndSendInvoice()
 {
     $item1 = new InvoiceItemType('item_name1', '1', '1');
     $item2 = new InvoiceItemType('item_name2', '2', '2');
     $items = array($item1, $item2);
     $itemList = new InvoiceItemListType();
     $itemList->item = $items;
     $invoice = new InvoiceType('*****@*****.**', '*****@*****.**', $itemList, 'USD', 'DueOnReceipt');
     $requestEnvelope = new RequestEnvelope();
     $requestEnvelope->errorLanguage = "en_US";
     $createInvoiceRequest = new CreateInvoiceRequest($requestEnvelope, $invoice);
     $invoice_service = new InvoiceService();
     $ret = $invoice_service->CreateInvoice($createInvoiceRequest, 'jb-us-seller_api1.paypal.com');
     $this->assertNotNull($ret);
     $this->assertNotNull($ret->invoiceID);
     $this->assertEquals(0, count($ret->error));
 }
コード例 #4
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) {
         $createInvoiceResponse = $invoiceService->CreateInvoice($createInvoiceRequest, $cred);
     } else {
         $createInvoiceResponse = $invoiceService->CreateInvoice($createInvoiceRequest);
     }
 } catch (Exception $ex) {
     require_once 'error.php';
     exit;
 }
 echo "<table>";
 echo "<tr><td>Ack :</td><td><div id='Ack'>" . $createInvoiceResponse->responseEnvelope->ack . "</div> </td></tr>";
 echo "<tr><td>InvoiceID :</td><td><div id='InvoiceID'>" . $createInvoiceResponse->invoiceID . "</div> </td></tr>";
 echo "</table>";
 require 'ShowAllResponse.php';
 echo "<pre>";
 var_dump($createInvoiceResponse);
 echo "</pre>";
コード例 #5
0
ファイル: createInvoice.php プロジェクト: kashyapkk/SDKs
    // send request
    $item1 = new InvoiceItemType($_POST['item_name1'], $_POST['item_quantity1'], $_POST['item_unitPrice1']);
    $item2 = new InvoiceItemType($_POST['item_name2'], $_POST['item_quantity2'], $_POST['item_unitPrice2']);
    $itemList = new InvoiceItemListType();
    $itemList->item = array($item1, $item2);
    $invoice = new InvoiceType($_POST['merchantEmail'], $_POST['payerEmail'], $itemList, $_POST['currencyCode'], $_POST['paymentTerms']);
    $requestEnvelope = new RequestEnvelope("en_US");
    $createInvoiceRequest = new CreateInvoiceRequest($requestEnvelope, $invoice);
    $logger->info("created CreateInvoiceRequest Object");
    $invoiceService = new InvoiceService();
    // required in third party permissioning
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $invoiceService->setAccessToken($_POST['accessToken']);
        $invoiceService->setTokenSecret($_POST['tokenSecret']);
    }
    $createInvoiceResponse = $invoiceService->CreateInvoice($createInvoiceRequest, 'jb-us-seller_api1.paypal.com');
    $logger->info("Received CreateInvoiceResponse:");
    var_dump($createInvoiceResponse);
} else {
    ?>
<form method="POST">
<div id="apidetails">The CreateInvoice API operation is used to create a new "Draft" invoice. The call includes merchant and payer information in addition to invoice detail. The response to the call contains a invoice ID and a URL where the invoice can be viewed on a browser.</div>
<div class="params">
<div class="param_name">Merchant Email</div>
<div class="param_value"><input type="text" name="merchantEmail"
	value="*****@*****.**" size="50" maxlength="260" /></div>
<div class="param_name">Payer Email</div>
<div class="param_value"><input type="text" name="payerEmail"
	value="*****@*****.**" size="50" maxlength="260" /></div>
<div class="param_name">Item1 Name</div>
<div class="param_value"><input type="text" name="item_name1"