public function toXMLString() { $str = ''; if ($this->ProfileID != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:ProfileID>' . $this->ProfileID . '</ebl:ProfileID>'; } if ($this->Note != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:Note>' . $this->Note . '</ebl:Note>'; } if ($this->Description != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:Description>' . $this->Description . '</ebl:Description>'; } if ($this->SubscriberName != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:SubscriberName>' . $this->SubscriberName . '</ebl:SubscriberName>'; } if ($this->SubscriberShippingAddress != null) { //prop is not a collection //prop is complex //prop is not enum //does not contain attribute or is attribute $str .= '<ebl:SubscriberShippingAddress>'; $str .= $this->SubscriberShippingAddress->toXMLString(); $str .= '</ebl:SubscriberShippingAddress>'; } if ($this->ProfileReference != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:ProfileReference>' . $this->ProfileReference . '</ebl:ProfileReference>'; } if ($this->AdditionalBillingCycles != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:AdditionalBillingCycles>' . $this->AdditionalBillingCycles . '</ebl:AdditionalBillingCycles>'; } if ($this->Amount != null) { //prop is not a collection //prop is complex //prop is not enum //prop containsattribute $str .= '<ebl:Amount'; $str .= $this->Amount->toXMLString(); $str .= '</ebl:Amount>'; } if ($this->ShippingAmount != null) { //prop is not a collection //prop is complex //prop is not enum //prop containsattribute $str .= '<ebl:ShippingAmount'; $str .= $this->ShippingAmount->toXMLString(); $str .= '</ebl:ShippingAmount>'; } if ($this->TaxAmount != null) { //prop is not a collection //prop is complex //prop is not enum //prop containsattribute $str .= '<ebl:TaxAmount'; $str .= $this->TaxAmount->toXMLString(); $str .= '</ebl:TaxAmount>'; } if ($this->OutstandingBalance != null) { //prop is not a collection //prop is complex //prop is not enum //prop containsattribute $str .= '<ebl:OutstandingBalance'; $str .= $this->OutstandingBalance->toXMLString(); $str .= '</ebl:OutstandingBalance>'; } if ($this->AutoBillOutstandingAmount != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:AutoBillOutstandingAmount>' . $this->AutoBillOutstandingAmount . '</ebl:AutoBillOutstandingAmount>'; } if ($this->MaxFailedPayments != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:MaxFailedPayments>' . $this->MaxFailedPayments . '</ebl:MaxFailedPayments>'; } 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->BillingStartDate != null) { //prop is not a collection //prop not complex //prop is not value $str .= '<ebl:BillingStartDate>' . $this->BillingStartDate . '</ebl:BillingStartDate>'; } if ($this->TrialPeriod != null) { //prop is not a collection //prop is complex //prop is not enum //does not contain attribute or is attribute $str .= '<ebl:TrialPeriod>'; $str .= $this->TrialPeriod->toXMLString(); $str .= '</ebl:TrialPeriod>'; } if ($this->PaymentPeriod != null) { //prop is not a collection //prop is complex //prop is not enum //does not contain attribute or is attribute $str .= '<ebl:PaymentPeriod>'; $str .= $this->PaymentPeriod->toXMLString(); $str .= '</ebl:PaymentPeriod>'; } return $str; }
public function toXMLString() { $str = ''; if ($this->ProfileID != null) { $str .= '<ebl:ProfileID>' . PPUtils::escapeInvalidXmlCharsRegex($this->ProfileID) . '</ebl:ProfileID>'; } if ($this->Note != null) { $str .= '<ebl:Note>' . PPUtils::escapeInvalidXmlCharsRegex($this->Note) . '</ebl:Note>'; } if ($this->Description != null) { $str .= '<ebl:Description>' . PPUtils::escapeInvalidXmlCharsRegex($this->Description) . '</ebl:Description>'; } if ($this->SubscriberName != null) { $str .= '<ebl:SubscriberName>' . PPUtils::escapeInvalidXmlCharsRegex($this->SubscriberName) . '</ebl:SubscriberName>'; } if ($this->SubscriberShippingAddress != null) { $str .= '<ebl:SubscriberShippingAddress>'; $str .= $this->SubscriberShippingAddress->toXMLString(); $str .= '</ebl:SubscriberShippingAddress>'; } if ($this->ProfileReference != null) { $str .= '<ebl:ProfileReference>' . PPUtils::escapeInvalidXmlCharsRegex($this->ProfileReference) . '</ebl:ProfileReference>'; } if ($this->AdditionalBillingCycles != null) { $str .= '<ebl:AdditionalBillingCycles>' . PPUtils::escapeInvalidXmlCharsRegex($this->AdditionalBillingCycles) . '</ebl:AdditionalBillingCycles>'; } if ($this->Amount != null) { $str .= '<ebl:Amount'; $str .= $this->Amount->toXMLString(); $str .= '</ebl:Amount>'; } if ($this->ShippingAmount != null) { $str .= '<ebl:ShippingAmount'; $str .= $this->ShippingAmount->toXMLString(); $str .= '</ebl:ShippingAmount>'; } if ($this->TaxAmount != null) { $str .= '<ebl:TaxAmount'; $str .= $this->TaxAmount->toXMLString(); $str .= '</ebl:TaxAmount>'; } if ($this->OutstandingBalance != null) { $str .= '<ebl:OutstandingBalance'; $str .= $this->OutstandingBalance->toXMLString(); $str .= '</ebl:OutstandingBalance>'; } if ($this->AutoBillOutstandingAmount != null) { $str .= '<ebl:AutoBillOutstandingAmount>' . PPUtils::escapeInvalidXmlCharsRegex($this->AutoBillOutstandingAmount) . '</ebl:AutoBillOutstandingAmount>'; } if ($this->MaxFailedPayments != null) { $str .= '<ebl:MaxFailedPayments>' . PPUtils::escapeInvalidXmlCharsRegex($this->MaxFailedPayments) . '</ebl:MaxFailedPayments>'; } if ($this->CreditCard != null) { $str .= '<ebl:CreditCard>'; $str .= $this->CreditCard->toXMLString(); $str .= '</ebl:CreditCard>'; } if ($this->BillingStartDate != null) { $str .= '<ebl:BillingStartDate>' . PPUtils::escapeInvalidXmlCharsRegex($this->BillingStartDate) . '</ebl:BillingStartDate>'; } if ($this->TrialPeriod != null) { $str .= '<ebl:TrialPeriod>'; $str .= $this->TrialPeriod->toXMLString(); $str .= '</ebl:TrialPeriod>'; } if ($this->PaymentPeriod != null) { $str .= '<ebl:PaymentPeriod>'; $str .= $this->PaymentPeriod->toXMLString(); $str .= '</ebl:PaymentPeriod>'; } 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; }