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 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; }
} if ($_POST['paymentDateStart'] != '' || $_POST['paymentDateEnd'] != '') { $dateRange = new DateRangeType(); $dateRange->startDate = $_POST['paymentDateStart']; $dateRange->endDate = $_POST['paymentDateEnd']; $parameters->paymentDate = $dateRange; } if ($_POST['creationDateStart'] != '' || $_POST['creationDateEnd'] != '') { $dateRange = new DateRangeType(); $dateRange->startDate = $_POST['creationDateStart']; $dateRange->endDate = $_POST['creationDateEnd']; $parameters->creationDate = $dateRange; } $searchInvoicesRequest = new SearchInvoicesRequest($requestEnvelope, $merchantEmail, $parameters, $page, $pageSize); $logger->info("created GsearchInvoices Object"); $invoiceService = new InvoiceService(); // required in third party permissioning if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $invoiceService->setAccessToken($_POST['accessToken']); $invoiceService->setTokenSecret($_POST['tokenSecret']); } $searchInvoicesResponse = $invoiceService->SearchInvoices($searchInvoicesRequest); $logger->info("Received searchInvoices Response"); var_dump($searchInvoicesResponse); } else { ?> <form method="POST"> <div id="apidetails">The SearchInvoice API operation is used to search for invoices that match input criteria.</div> <div class="params"> <div class="param_name">Merchant Email</div>
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; }
<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); } else { ?> <form method="POST"> <div id="apidetails">The CancelInvoice API operation is used to cancel an invoice.</div> <div class="params"> <div class="param_name">Invoice ID</div> <div class="param_value"><input type="text" name="invoiceID" value=""
// create request object /* * (Required) RFC 3066 language in which error messages are returned; by default it is en_US, which is the only language currently supported. */ $requestEnvelope = new RequestEnvelope("en_US"); $cancelInvoiceRequest = new CancelInvoiceRequest($requestEnvelope); /* * (Optional) ID of the invoice. */ $cancelInvoiceRequest->invoiceID = $_POST['invoiceID']; /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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 { /* wrap API method calls on the service object with a try catch */ if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $cancelInvoiceResponse = $invoiceService->CancelInvoice($cancelInvoiceRequest, $cred); } else { $cancelInvoiceResponse = $invoiceService->CancelInvoice($cancelInvoiceRequest); } } catch (Exception $ex) { require_once 'error.php'; exit;
if ($_POST['note'] != "") { $payment->note = $_POST['note']; } /* * (Required) Date when the invoice was paid. */ if ($_POST['paymentDate'] != "") { $payment->date = $_POST['paymentDate']; } $markInvoiceAsPaidRequest = new MarkInvoiceAsPaidRequest($requestEnvelope, $_POST['invoiceID'], $payment); /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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 { if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $markInvoiceAsPaidResponse = $invoiceService->MarkInvoiceAsPaid($markInvoiceAsPaidRequest, $cred); } else { $markInvoiceAsPaidResponse = $invoiceService->MarkInvoiceAsPaid($markInvoiceAsPaidRequest); } } catch (Exception $ex) { require_once 'error.php'; exit; }
/* * (Required) Information common to each API operation, such as the language in which an error message is returned. */ $requestEnvelope = new RequestEnvelope("en_US"); $refundDetails = new OtherPaymentRefundDetailsType(); if ($_POST['note'] != "") { $refundDetails->note = $_POST['note']; } if ($_POST['refundDate'] != "") { $refundDetails->date = $_POST['refundDate']; } $markInvoiceAsRefundedRequest = new MarkInvoiceAsRefundedRequest($requestEnvelope, $_POST['invoiceID'], $refundDetails); /* 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 { if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $markInvoiceAsRefundedResponse = $invoiceService->MarkInvoiceAsRefunded($markInvoiceAsRefundedRequest, $cred); } else { $markInvoiceAsRefundedResponse = $invoiceService->MarkInvoiceAsRefunded($markInvoiceAsRefundedRequest); } } catch (Exception $ex) { require_once 'error.php'; exit; }
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // create request object $requestEnvelope = new RequestEnvelope("en_US"); $payment = new OtherPaymentDetailsType(); if ($_POST['paymentMethod'] != "") { $payment->method = $_POST['paymentMethod']; } if ($_POST['note'] != "") { $payment->note = $_POST['note']; } if ($_POST['paymentDate'] != "") { $payment->date = $_POST['paymentDate']; } $markInvoiceAsPaidRequest = new MarkInvoiceAsPaidRequest($requestEnvelope, $_POST['invoiceID'], $payment); $logger->info("created MarkInvoiceAsPaid Object"); $invoiceService = new InvoiceService(); // required in third party permissioning if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $invoiceService->setAccessToken($_POST['accessToken']); $invoiceService->setTokenSecret($_POST['tokenSecret']); } $markInvoiceAsPaidResponse = $invoiceService->MarkInvoiceAsPaid($markInvoiceAsPaidRequest, 'jb-us-seller_api1.paypal.com'); $logger->info("Received MarkInvoiceAsPaidResponse:"); var_dump($markInvoiceAsPaidResponse); } else { ?> <form method="POST"> <div id="apidetails">The MarkInvoiceAsPaid API operation is used to mark an invoice as paid.</div> <div class="params"> <div class="param_name">Invoice ID *</div>
/** * @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)); }
*/ $requestEnvelope = new RequestEnvelope("en_US"); /* * 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 */ $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);
<html> <head> <title>GetInvoiceDetails Sample API Page</title> <link rel="stylesheet" type="text/css" href="sdk.css"/> <script type="text/javascript" src="sdk.js"></script> </head> <body> <h2>GetInvoiceDetails API Test Page</h2> <?php $logger = new PPLoggingManager('GetInvoiceDetails'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // create request object $requestEnvelope = new RequestEnvelope("en_US"); $getInvoiceDetailsRequest = new GetInvoiceDetailsRequest($requestEnvelope, $_POST['invoiceID']); $logger->info("created GetInvoiceDetails Object"); $invoiceService = new InvoiceService(); // required in third party permissioning if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $invoiceService->setAccessToken($_POST['accessToken']); $invoiceService->setTokenSecret($_POST['tokenSecret']); } $getInvoiceDetailsResponse = $invoiceService->GetInvoiceDetails($getInvoiceDetailsRequest, 'jb-us-seller_api1.paypal.com'); $logger->info("Received getInvoiceDetailsResponse"); var_dump($getInvoiceDetailsResponse); } else { ?> <form method="POST"> <div id="apidetails">The GetInvoiceDetails API operation is used to get detailed information about an invoice.</div> <div class="params"> <div class="param_name">Invoice ID *</div> <div class="param_value"><input type="text" name="invoiceID" value=""
$requestEnvelope = new RequestEnvelope("en_US"); /* * UpdateInvoiceRequest 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 update. * `Invoice` - Merchant, payer, and invoice information. */ $updateInvoiceRequest = new UpdateInvoiceRequest($requestEnvelope, $_POST['invoiceId'], $invoice); /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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 { if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) { $updateInvoiceResponse = $invoiceService->UpdateInvoice($updateInvoiceRequest, $cred); } else { $updateInvoiceResponse = $invoiceService->UpdateInvoice($updateInvoiceRequest); } } catch (Exception $ex) { require_once 'error.php'; exit; }
* 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, $merchantEmail, $parameters, $page, $pageSize); /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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("jb-us-seller_api1.paypal.com", "WX4WTU3S8MY44S7F", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy"); $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) { $searchInvoicesResponse = $invoiceService->SearchInvoices($searchInvoicesRequest, $cred); } else { $searchInvoicesResponse = $invoiceService->SearchInvoices($searchInvoicesRequest);
$requestEnvelope = new RequestEnvelope("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, $_POST['invoiceID']); /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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);
*/ $requestEnvelope = new RequestEnvelope("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, $_POST['invoiceID']); /* * ## Creating service wrapper object Creating service wrapper object to make API call and loading 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) { $getInvoiceDetailsResponse = $invoiceService->GetInvoiceDetails($getInvoiceDetailsRequest, $cred); } else { $getInvoiceDetailsResponse = $invoiceService->GetInvoiceDetails($getInvoiceDetailsRequest);