public function toXMLString() { $str = ''; $str .= parent::toXMLString(); if ($this->StartDate != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:StartDate>' . $this->StartDate . '</urn:StartDate>'; } if ($this->EndDate != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:EndDate>' . $this->EndDate . '</urn:EndDate>'; } if ($this->Payer != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:Payer>' . $this->Payer . '</urn:Payer>'; } if ($this->Receiver != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:Receiver>' . $this->Receiver . '</urn:Receiver>'; } if ($this->ReceiptID != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:ReceiptID>' . $this->ReceiptID . '</urn:ReceiptID>'; } if ($this->TransactionID != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:TransactionID>' . $this->TransactionID . '</urn:TransactionID>'; } if ($this->ProfileID != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:ProfileID>' . $this->ProfileID . '</urn:ProfileID>'; } if ($this->PayerName != null) { //prop is not a collection //prop is complex //prop is not enum //does not contain attribute or is attribute $str .= '<urn:PayerName>'; $str .= $this->PayerName->toXMLString(); $str .= '</urn:PayerName>'; } if ($this->AuctionItemNumber != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:AuctionItemNumber>' . $this->AuctionItemNumber . '</urn:AuctionItemNumber>'; } if ($this->InvoiceID != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:InvoiceID>' . $this->InvoiceID . '</urn:InvoiceID>'; } if ($this->CardNumber != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:CardNumber>' . $this->CardNumber . '</urn:CardNumber>'; } if ($this->TransactionClass != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:TransactionClass>' . $this->TransactionClass . '</urn:TransactionClass>'; } if ($this->Amount != null) { //prop is not a collection //prop is complex //prop is not enum //prop containsattribute $str .= '<urn:Amount'; $str .= $this->Amount->toXMLString(); $str .= '</urn:Amount>'; } if ($this->CurrencyCode != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:CurrencyCode>' . $this->CurrencyCode . '</urn:CurrencyCode>'; } if ($this->Status != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<urn:Status>' . $this->Status . '</urn:Status>'; } return $str; }
public function toXMLString() { $str = ''; $str .= parent::toXMLString(); if ($this->StartDate != null) { $str .= '<urn:StartDate>' . PPUtils::escapeInvalidXmlCharsRegex($this->StartDate) . '</urn:StartDate>'; } if ($this->EndDate != null) { $str .= '<urn:EndDate>' . PPUtils::escapeInvalidXmlCharsRegex($this->EndDate) . '</urn:EndDate>'; } if ($this->Payer != null) { $str .= '<urn:Payer>' . PPUtils::escapeInvalidXmlCharsRegex($this->Payer) . '</urn:Payer>'; } if ($this->Receiver != null) { $str .= '<urn:Receiver>' . PPUtils::escapeInvalidXmlCharsRegex($this->Receiver) . '</urn:Receiver>'; } if ($this->ReceiptID != null) { $str .= '<urn:ReceiptID>' . PPUtils::escapeInvalidXmlCharsRegex($this->ReceiptID) . '</urn:ReceiptID>'; } if ($this->TransactionID != null) { $str .= '<urn:TransactionID>' . PPUtils::escapeInvalidXmlCharsRegex($this->TransactionID) . '</urn:TransactionID>'; } if ($this->ProfileID != null) { $str .= '<urn:ProfileID>' . PPUtils::escapeInvalidXmlCharsRegex($this->ProfileID) . '</urn:ProfileID>'; } if ($this->PayerName != null) { $str .= '<urn:PayerName>'; $str .= $this->PayerName->toXMLString(); $str .= '</urn:PayerName>'; } if ($this->AuctionItemNumber != null) { $str .= '<urn:AuctionItemNumber>' . PPUtils::escapeInvalidXmlCharsRegex($this->AuctionItemNumber) . '</urn:AuctionItemNumber>'; } if ($this->InvoiceID != null) { $str .= '<urn:InvoiceID>' . PPUtils::escapeInvalidXmlCharsRegex($this->InvoiceID) . '</urn:InvoiceID>'; } if ($this->CardNumber != null) { $str .= '<urn:CardNumber>' . PPUtils::escapeInvalidXmlCharsRegex($this->CardNumber) . '</urn:CardNumber>'; } if ($this->TransactionClass != null) { $str .= '<urn:TransactionClass>' . PPUtils::escapeInvalidXmlCharsRegex($this->TransactionClass) . '</urn:TransactionClass>'; } if ($this->Amount != null) { $str .= '<urn:Amount'; $str .= $this->Amount->toXMLString(); $str .= '</urn:Amount>'; } if ($this->CurrencyCode != null) { $str .= '<urn:CurrencyCode>' . PPUtils::escapeInvalidXmlCharsRegex($this->CurrencyCode) . '</urn:CurrencyCode>'; } if ($this->Status != null) { $str .= '<urn:Status>' . PPUtils::escapeInvalidXmlCharsRegex($this->Status) . '</urn:Status>'; } return $str; }
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; }