2 namespace PayPal\Handler;
3 use PayPal\Exception\PPConfigurationException;
4 use PayPal\Auth\PPSignatureCredential;
5 use PayPal\Auth\PPCertificateCredential;
6 use PayPal\Core\PPConstants;
7 class PPMerchantServiceHandler extends PPGenericServiceHandler {
10 public function handle($httpConfig, $request, $options) {
11 parent::handle($httpConfig, $request, $options);
12 $this->config = $options['config'];
13 $credential = $request->getCredential();
14 if($options['port'] != null && isset($this->config['service.EndPoint.'.$options['port']]))
16 $this->endpoint = $this->config['service.EndPoint.'.$options['port']];
18 // for backward compatibilty (for those who are using old config files with 'service.EndPoint')
19 else if (isset($this->config['service.EndPoint']))
21 $this->endpoint = $this->config['service.EndPoint'];
23 else if (isset($this->config['mode']))
25 if(strtoupper($this->config['mode']) == 'SANDBOX')
27 if($credential instanceof PPSignatureCredential)
29 $this->endpoint = PPConstants::MERCHANT_SANDBOX_SIGNATURE_ENDPOINT;
31 else if($credential instanceof PPCertificateCredential)
33 $this->endpoint = PPConstants::MERCHANT_SANDBOX_CERT_ENDPOINT;
36 else if(strtoupper($this->config['mode']) == 'LIVE')
38 if($credential instanceof PPSignatureCredential)
40 $this->endpoint = PPConstants::MERCHANT_LIVE_SIGNATURE_ENDPOINT;
42 else if($credential instanceof PPCertificateCredential)
44 $this->endpoint = PPConstants::MERCHANT_LIVE_CERT_ENDPOINT;
50 throw new PPConfigurationException('endpoint Not Set');
53 if($options['serviceBinding'] == 'SOAP' )
55 $httpConfig->setUrl($this->endpoint);
59 throw new PPConfigurationException('expecting service binding to be SOAP');
62 $request->addBindingInfo("namespace", "xmlns:ns=\"urn:ebay:api:PayPalAPI\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\"");