public function handle($httpConfig, $request, $options) { $httpConfig->addHeader('X-PAYPAL-REQUEST-DATA-FORMAT', $request->getBindingType()); $httpConfig->addHeader('X-PAYPAL-RESPONSE-DATA-FORMAT', $request->getBindingType()); $httpConfig->addHeader('X-PAYPAL-DEVICE-IPADDRESS', PPUtils::getLocalIPAddress()); $httpConfig->addHeader('X-PAYPAL-REQUEST-SOURCE', PPBaseService::getRequestSource()); if (isset($options['config']['service.SandboxEmailAddress'])) { $httpConfig->addHeader('X-PAYPAL-SANDBOX-EMAIL-ADDRESS', $options['config']['service.SandboxEmailAddress']); } }
public function handle($httpConfig, $request, $options) { $httpConfig->addHeader('X-PAYPAL-REQUEST-DATA-FORMAT', $request->getBindingType()); $httpConfig->addHeader('X-PAYPAL-RESPONSE-DATA-FORMAT', $request->getBindingType()); $httpConfig->addHeader('X-PAYPAL-DEVICE-IPADDRESS', PPUtils::getLocalIPAddress()); $httpConfig->addHeader('X-PAYPAL-REQUEST-SOURCE', $this->getRequestSource()); if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) { $httpConfig->addHeader("User-Agent", PPUserAgent::getValue($this->sdkName, $this->sdkVersion)); } if (isset($options['config']['service.SandboxEmailAddress'])) { $httpConfig->addHeader('X-PAYPAL-SANDBOX-EMAIL-ADDRESS', $options['config']['service.SandboxEmailAddress']); } }
/** * @test */ public function deserializeAndSerialize() { $nvpString = "list2(0).field1=somevalue1&list2(0).field2=somevalue2&list2(1).field1=another+value1&list2(1).field2=anothervalue2&list3(0).attrib1=somevalue1&list3(0).attrib2=somevalue2&list3(0)=value+field&list3(1).attrib1=another+value1&list3(2)=anothervalue2"; $newC = new SimpleContainerTestClass(); $newC->init(PPUtils::nvpToMap($nvpString)); //TODO: Mock nvpToMap $this->assertEquals($nvpString, $newC->toNVPString()); }
/** * Service Call: ExternalRememberMeOptOut * @param ExternalRememberMeOptOutReq $externalRememberMeOptOutReq * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return PayPalAPI\ExternalRememberMeOptOutResponseType * @throws APIException */ public function ExternalRememberMeOptOut($externalRememberMeOptOutReq, $apiCredential = NULL) { $apiContext = new PPApiContext($this->config); $handlers = array(new PPMerchantServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $this->setStandardParams($externalRememberMeOptOutReq->ExternalRememberMeOptOutRequest); $ret = new ExternalRememberMeOptOutResponseType(); $resp = $this->call('PayPalAPIAA', 'ExternalRememberMeOptOut', $externalRememberMeOptOutReq, $apiContext, $handlers); $ret->init(PPUtils::xmlToArray($resp)); return $ret; }
/** * Service Call: DeleteInvoice * @param DeleteInvoiceRequest $deleteInvoiceRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return Types\PT\DeleteInvoiceResponse * @throws APIException */ public function DeleteInvoice($deleteInvoiceRequest, $apiCredential = NULL) { $ret = new DeleteInvoiceResponse(); $apiContext = new PPApiContext($this->config); $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $resp = $this->call('Invoice', 'DeleteInvoice', $deleteInvoiceRequest, $apiContext, $handlers); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * Service Call: GetAdvancedPersonalData * @param GetAdvancedPersonalDataRequest $getAdvancedPersonalDataRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return Types\Perm\GetAdvancedPersonalDataResponse * @throws APIException */ public function GetAdvancedPersonalData($getAdvancedPersonalDataRequest, $apiCredential = NULL) { $ret = new GetAdvancedPersonalDataResponse(); $resp = $this->call('Permissions', 'GetAdvancedPersonalData', $getAdvancedPersonalDataRequest, $apiCredential); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * @test */ public function testGetAttributeType() { $this->assertEquals(true, PPUtils::isAttributeProperty('MockReflectionTestType', 'currencyID')); $this->assertEquals(false, PPUtils::isAttributeProperty('MockReflectionTestType', 'value')); $this->assertEquals(false, PPUtils::isAttributeProperty('MockReflectionTestType', 'noAnnotations')); }
/** * @param string $property * @param array $element */ private function fillRelation($property, array $element) { if (!class_exists($type = PPUtils::propertyType($this, $property))) { trigger_error("Class {$type} not found.", E_USER_NOTICE); return; // just ignore } if (isset($element['num'])) { // array of objects $this->{$property}[$element['num']] = $item = new $type(); $item->init($element['children'], false); } else { $this->{$property} = new $type(); $this->{$property}->init($element["children"], false); } }
/** * Service Call: GetPrePaymentDisclosure * @param GetPrePaymentDisclosureRequest $getPrePaymentDisclosureRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return Types\AP\GetPrePaymentDisclosureResponse * @throws APIException */ public function GetPrePaymentDisclosure($getPrePaymentDisclosureRequest, $apiCredential = NULL) { $ret = new GetPrePaymentDisclosureResponse(); $apiContext = new PPApiContext($this->config); $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $resp = $this->call('AdaptivePayments', 'GetPrePaymentDisclosure', $getPrePaymentDisclosureRequest, $apiContext, $handlers); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * @test */ public function testSoapFaults() { $xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body> <soapenv:Fault xmlns:axis2ns237961="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>axis2ns237961:Server</faultcode><faultstring>Authentication failed. API credentials are incorrect.</faultstring><detail><ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"><responseEnvelope><timestamp>2013-09-03T04:36:14.931-07:00</timestamp><ack>Failure</ack><correlationId>ebeb480862a99</correlationId><build>6941298</build></responseEnvelope><error><errorId>520003</errorId><domain>PLATFORM</domain><subdomain>Application</subdomain><severity>Error</severity><category>Application</category><message>Authentication failed. API credentials are incorrect.</message></error></ns3:FaultMessage></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>'; $map = PPUtils::xmlToArray($xml); $o = new FaultMessage(); $o->init($map, false); $this->assertEquals("Failure", $o->responseEnvelope->ack); $this->assertEquals("Application", $o->error[0]->category); }
/** * Service Call: UpdateAuthorization * @param UpdateAuthorizationReq $updateAuthorizationReq * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return PayPalAPI\UpdateAuthorizationResponseType * @throws APIException */ public function UpdateAuthorization($updateAuthorizationReq, $apiCredential = NULL) { $this->setStandardParams($updateAuthorizationReq->UpdateAuthorizationRequest); $ret = new UpdateAuthorizationResponseType(); $apiContext = new PPApiContext($this->config); $handlers = array(new PPMerchantServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $resp = $this->call('PayPalAPIAA', 'UpdateAuthorization', $updateAuthorizationReq, $apiContext, $handlers); $ret->init(PPUtils::xmlToArray($resp)); return $ret; }
/** * Service Call: GetAdvancedPersonalData * @param GetAdvancedPersonalDataRequest $getAdvancedPersonalDataRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return Types\Perm\GetAdvancedPersonalDataResponse * @throws APIException */ public function GetAdvancedPersonalData($getAdvancedPersonalDataRequest, $apiCredential = NULL) { $apiContext = new PPApiContext($this->config); $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $ret = new GetAdvancedPersonalDataResponse(); $resp = $this->call('Permissions', 'GetAdvancedPersonalData', $getAdvancedPersonalDataRequest, $apiContext, $handlers); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }
/** * Service Call: ExternalRememberMeOptOut * @param ExternalRememberMeOptOutReq $externalRememberMeOptOutReq * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return PayPalAPI\ExternalRememberMeOptOutResponseType * @throws APIException */ public function ExternalRememberMeOptOut($externalRememberMeOptOutReq, $apiCredential = NULL) { $this->setStandardParams($externalRememberMeOptOutReq->ExternalRememberMeOptOutRequest); $ret = new ExternalRememberMeOptOutResponseType(); $resp = $this->call('PayPalAPIAA', 'ExternalRememberMeOptOut', $externalRememberMeOptOutReq, $apiCredential); $ret->init(PPUtils::xmlToArray($resp)); return $ret; }
/** * @test */ public function testGetLocalIPAddress() { $ip = $this->object->getLocalIPAddress(); //$this->assertEquals('127.0.0.1',$ip); }
/** * @param array $map * @param string $prefix */ public function init(array $map = array(), $prefix = '') { if (empty($map)) { return; } $map = PPUtils::lowerKeys($map); foreach (get_object_vars($this) as $property => $defaultValue) { if (array_key_exists($propKey = strtolower($prefix . $property), $map) && $this->isBuiltInType($type = PPUtils::propertyType($this, $property))) { $type = PPUtils::propertyType($this, $property); $this->{$property} = urldecode($map[$propKey]); continue; // string } elseif (!($filtered = PPUtils::filterKeyPrefix($map, $propKey))) { continue; // NULL } if (!class_exists($type = PPUtils::propertyType($this, $property)) && !$this->isBuiltInType($type)) { trigger_error("Class {$type} not found.", E_USER_NOTICE); continue; // just ignore } if (is_array($defaultValue) || PPUtils::isPropertyArray($this, $property)) { // array of objects if ($this->isBuiltInType($type)) { // Array of simple types foreach ($filtered as $key => $value) { $this->{$property}[trim($key, "()")] = urldecode($value); } } else { // Array of complex objects $delim = '.'; for ($i = 0; $itemValues = PPUtils::filterKeyPrefix($filtered, "({$i})"); $i++) { $this->{$property}[$i] = $item = new $type(); $item->init(PPUtils::filterKeyPrefix($itemValues, ".")); if (array_key_exists("", $itemValues)) { $item->value = urldecode($itemValues[""]); } } // Handle cases where we have a list of objects // with just the value present and all attributes values are null foreach ($filtered as $key => $value) { $idx = trim($key, "()"); if (is_numeric($idx) && (is_null($this->{$property}) || !array_key_exists($idx, $this->{$property}))) { $this->{$property}[$idx] = new $type(); $this->{$property}[$idx]->value = urldecode($value); } } } } else { // one object $this->{$property} = new $type(); $this->{$property}->init(PPUtils::filterKeyPrefix($filtered, '.')); // unprefix if (array_key_exists("", $filtered)) { $this->{$property}->value = urldecode($filtered[""]); } } } }
/** * Service Call: CheckComplianceStatus * @param CheckComplianceStatusRequest $checkComplianceStatusRequest * @param mixed $apiCredential - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object * created dynamically * @return Types\AA\CheckComplianceStatusResponse * @throws APIException */ public function CheckComplianceStatus($checkComplianceStatusRequest, $apiCredential = NULL) { $ret = new CheckComplianceStatusResponse(); $apiContext = new PPApiContext($this->config); $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION)); $resp = $this->call('AdaptiveAccounts', 'CheckComplianceStatus', $checkComplianceStatusRequest, $apiContext, $handlers); $ret->init(PPUtils::nvpToMap($resp)); return $ret; }