Inheritance: extends IPPCredential
 /**
  * @test
  */
 public function testHeadersAddedForSOAP()
 {
     $options = array('config' => array('mode' => 'sandbox'), 'serviceName' => 'AdaptivePayments', 'apiMethod' => 'ConvertCurrency');
     $req = new PPRequest(new StdClass(), 'SOAP');
     $handler = new PPSignatureAuthHandler();
     // Test that no headers are added if no credential is passed
     $httpConfig = new PPHttpConfig();
     $handler->handle($httpConfig, $req, $options);
     $this->assertEquals('', $req->getBindingInfo('securityHeader'));
     // Test that the 3 token SOAP headers are added for first party API calls
     $req = new PPRequest(new StdClass(), 'SOAP');
     $req->setCredential(new PPSignatureCredential('user', 'pass', 'sign'));
     $handler->handle($httpConfig, $req, $options);
     $this->assertContains('<ebl:Username>', $req->getBindingInfo('securityHeader'));
     $this->assertContains('<ebl:Password>', $req->getBindingInfo('securityHeader'));
     $this->assertContains('<ebl:Signature>', $req->getBindingInfo('securityHeader'));
     // Test addition of 'subject' SOAP header for subject based third party auth
     $req = new PPRequest(new StdClass(), 'SOAP');
     $cred = new PPSignatureCredential('user', 'pass', 'sign');
     $cred->setThirdPartyAuthorization(new PPSubjectAuthorization('*****@*****.**'));
     $req->setCredential($cred);
     $handler->handle($httpConfig, $req, $options);
     $this->assertContains('<ebl:Username>', $req->getBindingInfo('securityHeader'));
     $this->assertContains('<ebl:Password>', $req->getBindingInfo('securityHeader'));
     $this->assertContains('<ebl:Signature>', $req->getBindingInfo('securityHeader'));
     $this->assertContains('<ebl:Subject>', $req->getBindingInfo('securityHeader'));
     // Test that no auth related HTTP headers (username, password, sign?) are
     // added for token based third party auth
     $req->getCredential()->setThirdPartyAuthorization(new PPTokenAuthorization('token', 'tokenSecret'));
     $handler->handle($httpConfig, $req, $options);
     $this->assertContains('<ns:RequesterCredentials/>', $req->getBindingInfo('securityHeader'));
     $this->assertEquals(0, count($httpConfig->getHeaders()));
 }
 /**
  * @test
  */
 public function testDefaultAPIAccount()
 {
     $req = new PPRequest(new StdClass(), 'NV');
     $httpConfig = new PPHttpConfig();
     $handler = new PPPlatformServiceHandler(null, 'sdkname', 'sdkversion');
     $handler->handle($httpConfig, $req, $this->options);
     $this->assertEquals($this->options['config']['acct1.Signature'], $req->getCredential()->getSignature());
     $cred = new PPSignatureCredential('user', 'pass', 'sig');
     $cred->setApplicationId('appId');
     $httpConfig = new PPHttpConfig();
     $handler = new PPPlatformServiceHandler($cred, 'sdkname', 'sdkversion');
     $handler->handle($httpConfig, $req, $this->options);
     $this->assertEquals($cred, $req->getCredential());
 }
 public function testThirdPartyAuthorization()
 {
     $authorizerEmail = "*****@*****.**";
     $thirdPartyAuth = new PPSubjectAuthorization($authorizerEmail);
     $cred = new PPSignatureCredential("username", "pwd", "signature");
     $cred->setThirdPartyAuthorization($thirdPartyAuth);
     $this->assertEquals($cred->getThirdPartyAuthorization()->getSubject(), $authorizerEmail);
     $accessToken = "atoken";
     $tokenSecret = "asecret";
     $thirdPartyAuth = new PPTokenAuthorization($accessToken, $tokenSecret);
     $cred->setThirdPartyAuthorization($thirdPartyAuth);
     $this->assertEquals($cred->getThirdPartyAuthorization()->getAccessToken(), $accessToken);
     $this->assertEquals($cred->getThirdPartyAuthorization()->getTokenSecret(), $tokenSecret);
 }
 /**
  * @test
  */
 public function testValidConfiguration()
 {
     $credential = new PPSignatureCredential('user', 'pass', 'sign');
     $credential->setThirdPartyAuthorization(new PPTokenAuthorization('accessToken', 'tokenSecret'));
     $options = array('config' => array('mode' => 'sandbox'), 'serviceName' => 'DoExpressCheckout', 'port' => 'PayPalAPI');
     $req = new PPRequest(new StdClass(), 'SOAP');
     $req->setCredential($credential);
     $httpConfig = new PPHttpConfig('http://api.paypal.com');
     $handler = new PPAuthenticationHandler();
     $handler->handle($httpConfig, $req, $options);
     $this->assertArrayHasKey('X-PP-AUTHORIZATION', $httpConfig->getHeaders());
     $options['port'] = 'abc';
     $handler->handle($httpConfig, $req, $options);
     $this->assertArrayHasKey('X-PAYPAL-AUTHORIZATION', $httpConfig->getHeaders());
     unset($options['port']);
     $handler->handle($httpConfig, $req, $options);
     $this->assertArrayHasKey('X-PAYPAL-AUTHORIZATION', $httpConfig->getHeaders());
 }
Ejemplo n.º 5
0
 *  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::getAcctAndConfig() returns array that contains credential and config parameters
 */
 $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) {
         $createInvoiceResponse = $invoiceService->CreateInvoice($createInvoiceRequest, $cred);
     } else {
         $createInvoiceResponse = $invoiceService->CreateInvoice($createInvoiceRequest);
     }
 } catch (Exception $ex) {
     require_once 'error.php';
Ejemplo n.º 6
0
 *  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::getAcctAndConfig() returns array that contains credential and config parameters
 */
 $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) {
         $getInvoiceDetailsResponse = $invoiceService->GetInvoiceDetails($getInvoiceDetailsRequest, $cred);
     } else {
         $getInvoiceDetailsResponse = $invoiceService->GetInvoiceDetails($getInvoiceDetailsRequest);
     }
 } catch (Exception $ex) {
     require_once 'error.php';
Ejemplo n.º 7
0
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // create request object
    $requestEnvelope = new RequestEnvelope("en_US");
    /*
     * (Required) ID of the invoice to mark as unpaid. 
     */
    $markInvoiceAsUnpaidRequest = new MarkInvoiceAsUnpaidRequest($requestEnvelope, $_POST['invoiceID']);
    /*
    	 * 	 ## Creating service wrapper object
    	Creating service wrapper object to make API call and loading
    	Configuration::getAcctAndConfig() returns array that contains credential and config parameters
    */
    $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 {
        if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
            $markInvoiceAsUnpaidResponse = $invoiceService->MarkInvoiceAsUnpaid($markInvoiceAsUnpaidRequest, $cred);
        } else {
            $markInvoiceAsUnpaidResponse = $invoiceService->MarkInvoiceAsUnpaid($markInvoiceAsUnpaidRequest);
        }
    } catch (Exception $ex) {
        require_once 'error.php';
        exit;
    }
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>" . $markInvoiceAsUnpaidResponse->responseEnvelope->ack . "</div> </td></tr>";
    echo "<tr><td>InvoiceID :</td><td><div id='InvoiceID'>" . $markInvoiceAsUnpaidResponse->invoiceID . "</div> </td></tr>";
Ejemplo n.º 8
0
 		 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::getAcctAndConfig() returns array that contains credential and config parameters
 */
 $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);
     }
 } catch (Exception $ex) {
     require_once 'error.php';
Ejemplo n.º 9
0
 *  ## MassPayReq
Details of each payment.
`Note:
A single MassPayRequest can include up to 250 MassPayItems.`
*/
$massPayReq = new MassPayReq();
$massPayReq->MassPayRequest = $massPayRequest;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
// required in third party permissioning
if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
    $cred = new PPSignatureCredential("jb-us-seller_api1.paypal.com", "WX4WTU3S8MY44S7F", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
    $cred->setThirdPartyAuthorization(new PPTokenAuthorization($_POST['accessToken'], $_POST['tokenSecret']));
}
try {
    /* wrap API method calls on the service object with a try catch */
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $massPayResponse = $paypalService->MassPay($massPayReq, $cred);
    } else {
        $massPayResponse = $paypalService->MassPay($massPayReq);
    }
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($massPayResponse)) {
    echo "<table>";