public function toXMLString()
 {
     $str = '';
     if ($this->ReferenceID != null) {
         $str .= '<ebl:ReferenceID>' . PPUtils::escapeInvalidXmlCharsRegex($this->ReferenceID) . '</ebl:ReferenceID>';
     }
     if ($this->PaymentAction != null) {
         $str .= '<ebl:PaymentAction>' . PPUtils::escapeInvalidXmlCharsRegex($this->PaymentAction) . '</ebl:PaymentAction>';
     }
     if ($this->PaymentType != null) {
         $str .= '<ebl:PaymentType>' . PPUtils::escapeInvalidXmlCharsRegex($this->PaymentType) . '</ebl:PaymentType>';
     }
     if ($this->PaymentDetails != null) {
         $str .= '<ebl:PaymentDetails>';
         $str .= $this->PaymentDetails->toXMLString();
         $str .= '</ebl:PaymentDetails>';
     }
     if ($this->CreditCard != null) {
         $str .= '<ebl:CreditCard>';
         $str .= $this->CreditCard->toXMLString();
         $str .= '</ebl:CreditCard>';
     }
     if ($this->IPAddress != null) {
         $str .= '<ebl:IPAddress>' . PPUtils::escapeInvalidXmlCharsRegex($this->IPAddress) . '</ebl:IPAddress>';
     }
     if ($this->MerchantSessionId != null) {
         $str .= '<ebl:MerchantSessionId>' . PPUtils::escapeInvalidXmlCharsRegex($this->MerchantSessionId) . '</ebl:MerchantSessionId>';
     }
     if ($this->ReqConfirmShipping != null) {
         $str .= '<ebl:ReqConfirmShipping>' . PPUtils::escapeInvalidXmlCharsRegex($this->ReqConfirmShipping) . '</ebl:ReqConfirmShipping>';
     }
     if ($this->SoftDescriptor != null) {
         $str .= '<ebl:SoftDescriptor>' . PPUtils::escapeInvalidXmlCharsRegex($this->SoftDescriptor) . '</ebl:SoftDescriptor>';
     }
     if ($this->SenderDetails != null) {
         $str .= '<ebl:SenderDetails>';
         $str .= $this->SenderDetails->toXMLString();
         $str .= '</ebl:SenderDetails>';
     }
     if ($this->MsgSubID != null) {
         $str .= '<ebl:MsgSubID>' . PPUtils::escapeInvalidXmlCharsRegex($this->MsgSubID) . '</ebl:MsgSubID>';
     }
     return $str;
 }
 public function toXMLString()
 {
     $str = '';
     if ($this->ReferenceID != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:ReferenceID>' . $this->ReferenceID . '</ebl:ReferenceID>';
     }
     if ($this->PaymentAction != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:PaymentAction>' . $this->PaymentAction . '</ebl:PaymentAction>';
     }
     if ($this->PaymentType != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:PaymentType>' . $this->PaymentType . '</ebl:PaymentType>';
     }
     if ($this->PaymentDetails != null) {
         //prop is not a collection
         //prop is complex
         //prop is not enum
         //does not contain attribute or is attribute
         $str .= '<ebl:PaymentDetails>';
         $str .= $this->PaymentDetails->toXMLString();
         $str .= '</ebl:PaymentDetails>';
     }
     if ($this->CreditCard != null) {
         //prop is not a collection
         //prop is complex
         //prop is not enum
         //does not contain attribute or is attribute
         $str .= '<ebl:CreditCard>';
         $str .= $this->CreditCard->toXMLString();
         $str .= '</ebl:CreditCard>';
     }
     if ($this->IPAddress != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:IPAddress>' . $this->IPAddress . '</ebl:IPAddress>';
     }
     if ($this->MerchantSessionId != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:MerchantSessionId>' . $this->MerchantSessionId . '</ebl:MerchantSessionId>';
     }
     if ($this->ReqConfirmShipping != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:ReqConfirmShipping>' . $this->ReqConfirmShipping . '</ebl:ReqConfirmShipping>';
     }
     if ($this->SoftDescriptor != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:SoftDescriptor>' . $this->SoftDescriptor . '</ebl:SoftDescriptor>';
     }
     if ($this->SenderDetails != null) {
         //prop is not a collection
         //prop is complex
         //prop is not enum
         //does not contain attribute or is attribute
         $str .= '<ebl:SenderDetails>';
         $str .= $this->SenderDetails->toXMLString();
         $str .= '</ebl:SenderDetails>';
     }
     if ($this->MsgSubID != null) {
         //prop is not a collection
         //prop not complex
         //prop is not value
         $str .= '<ebl:MsgSubID>' . $this->MsgSubID . '</ebl:MsgSubID>';
     }
     return $str;
 }
Beispiel #3
0
 public function init($map = null, $prefix = '')
 {
     if ($map != null) {
         if (PPUtils::array_match_key($map, $prefix . "responseEnvelope.")) {
             $newPrefix = $prefix . "responseEnvelope.";
             $this->responseEnvelope = new ResponseEnvelope();
             $this->responseEnvelope->init($map, $newPrefix);
         }
         if (PPUtils::array_match_key($map, $prefix . "invoice.")) {
             $newPrefix = $prefix . "invoice.";
             $this->invoice = new InvoiceType();
             $this->invoice->init($map, $newPrefix);
         }
         if (PPUtils::array_match_key($map, $prefix . "invoiceDetails.")) {
             $newPrefix = $prefix . "invoiceDetails.";
             $this->invoiceDetails = new InvoiceDetailsType();
             $this->invoiceDetails->init($map, $newPrefix);
         }
         if (PPUtils::array_match_key($map, $prefix . "paymentDetails.")) {
             $newPrefix = $prefix . "paymentDetails.";
             $this->paymentDetails = new PaymentDetailsType();
             $this->paymentDetails->init($map, $newPrefix);
         }
         if (PPUtils::array_match_key($map, $prefix . "refundDetails.")) {
             $newPrefix = $prefix . "refundDetails.";
             $this->refundDetails = new PaymentRefundDetailsType();
             $this->refundDetails->init($map, $newPrefix);
         }
         $mapKeyName = $prefix . 'invoiceURL';
         if ($map != null && array_key_exists($mapKeyName, $map)) {
             $this->invoiceURL = $map[$mapKeyName];
         }
         $i = 0;
         while (true) {
             if (PPUtils::array_match_key($map, $prefix . "error({$i})")) {
                 $newPrefix = $prefix . "error({$i}).";
                 $this->error[$i] = new ErrorData();
                 $this->error[$i]->init($map, $newPrefix);
             } else {
                 break;
             }
             $i++;
         }
     }
 }
Beispiel #4
0
 public function purchase()
 {
     // Note, we used to add extensions/ to include_path here, that should either
     // be standardized in Loader or we need to load more files here to make
     // up for whatever the PayPal code would otherwise try to load
     require_once 'extensions/PayPal.php';
     require_once 'extensions/PayPal/Profile/Handler/Array.php';
     require_once 'extensions/PayPal/Profile/API.php';
     require_once 'extensions/PayPal/Type/DoDirectPaymentRequestType.php';
     require_once 'extensions/PayPal/Type/DoDirectPaymentRequestDetailsType.php';
     require_once 'extensions/PayPal/Type/DoDirectPaymentResponseType.php';
     //  Add all of the types
     require_once 'extensions/PayPal/Type/BasicAmountType.php';
     require_once 'extensions/PayPal/Type/PaymentDetailsType.php';
     require_once 'extensions/PayPal/Type/AddressType.php';
     require_once 'extensions/PayPal/Type/CreditCardDetailsType.php';
     require_once 'extensions/PayPal/Type/PayerInfoType.php';
     require_once 'extensions/PayPal/Type/PersonNameType.php';
     require_once 'extensions/PayPal/CallerServices.php';
     $environment = $this->live ? 'live' : 'sandbox';
     $dp_request = new DoDirectPaymentRequestType();
     $OrderTotal = new BasicAmountType();
     $OrderTotal->setattr('currencyID', 'USD');
     $OrderTotal->setval($this->amount, 'iso-8859-1');
     $PaymentDetails = new PaymentDetailsType();
     $PaymentDetails->setOrderTotal($OrderTotal);
     $shipTo = new AddressType();
     $shipTo->setName($this->firstName . ' ' . $this->lastName);
     $shipTo->setStreet1($this->address1);
     $shipTo->setStreet2($this->address2);
     $shipTo->setCityName($this->city);
     $shipTo->setStateOrProvince($this->state);
     $shipTo->setCountry('US');
     $shipTo->setPostalCode($this->zip);
     $PaymentDetails->setShipToAddress($shipTo);
     $dp_details = new DoDirectPaymentRequestDetailsType();
     $dp_details->setPaymentDetails($PaymentDetails);
     // Credit Card info
     $card_details = new CreditCardDetailsType();
     $card_details->setCreditCardType($this->creditCardType);
     $card_details->setCreditCardNumber($this->creditCardNumber);
     $card_details->setExpMonth($this->expirationMonth);
     $card_details->setExpYear($this->expirationYear);
     $card_details->setCVV2($this->cvv2Number);
     $payer = new PayerInfoType();
     $person_name = new PersonNameType();
     $person_name->setFirstName($this->firstName);
     $person_name->setLastName($this->lastName);
     $payer->setPayerName($person_name);
     $payer->setPayerCountry('US');
     $payer->setAddress($shipTo);
     $card_details->setCardOwner($payer);
     $dp_details->setCreditCard($card_details);
     $dp_details->setIPAddress($_SERVER['SERVER_ADDR']);
     $dp_details->setPaymentAction('Sale');
     $dp_request->setDoDirectPaymentRequestDetails($dp_details);
     $handler = ProfileHandler_Array::getInstance(array('username' => $this->apiUsername, 'certificateFile' => null, 'subject' => null, 'environment' => $environment));
     $pid = ProfileHandler::generateID();
     $profile = new APIProfile($pid, $handler);
     $profile->setAPIUsername($this->apiUsername);
     $profile->setAPIPassword($this->apiPassword);
     $profile->setSignature($this->apiSignature);
     $profile->setEnvironment($environment);
     $caller = new CallerServices($profile);
     $response = $caller->DoDirectPayment($dp_request);
     if (PayPal::isError($response)) {
         Site::getPage()->addWarning($response->message);
         return false;
     }
     if ($response->Ack == 'Success') {
         return true;
     }
     if (is_array($response->Errors)) {
         foreach ($response->Errors as $error) {
             Site::getPage()->addWarning($error->LongMessage);
         }
     } else {
         Site::getPage()->addWarning($response->Errors->LongMessage);
     }
     return false;
 }