Example #1
0
 /**
  * Executes the Operation
  *
  * Prepares the final message and the calls the Webservice operation. If it is successfull the response is registered
  * and the OperationStatus is set to true, otherwise the Operation status will be set to false and an Exception of the type
  * soapFault will be registered instead.
  *
  * @access public
  */
 public function execute()
 {
     try {
         $this->apiMessage['Version'] = API_VERSION;
         $this->apiMessage['SetExpressCheckoutRequestDetails'] = $this->apiMessage;
         $this->apiMessage = array('SetExpressCheckoutRequest' => $this->apiMessage);
         if (count($this->recurringItems)) {
             $this->apiMessage['SetExpressCheckoutRequest']['SetExpressCheckoutRequestDetails']['BillingAgreementDetails'] = array();
             foreach ($this->recurringItems as $recurringItem) {
                 $this->apiMessage['SetExpressCheckoutRequest']['SetExpressCheckoutRequestDetails']['BillingAgreementDetails'][] = PayPalTypes::BillingAgreementDetailsType($recurringItem);
             }
         }
         $this->apiMessage = array($this->apiMessage);
         parent::registerAPIResponse(PayPalBase::getSoapClient()->__soapCall('SetExpressCheckout', $this->apiMessage, null, PayPalBase::getSoapHeader()));
         PaypalBase::setOperationStatus(true);
     } catch (SoapFault $Exception) {
         parent::registerAPIException($Exception);
         PaypalBase::setOperationStatus(false);
     }
 }
 public function execute()
 {
     $mapping = array(RecurringProductPeriod::TYPE_PERIOD_DAY => 'Day', RecurringProductPeriod::TYPE_PERIOD_WEEK => 'Week', RecurringProductPeriod::TYPE_PERIOD_MONTH => 'Month', RecurringProductPeriod::TYPE_PERIOD_YEAR => 'Year');
     $result = array();
     try {
         foreach ($this->recurringItems as $recurringItem) {
             $quantity = $recurringItem->orderedItem->get()->count->get();
             $RecurringPaymentsProfileDetails = array('BillingStartDate' => PayPalTypes::dateTimeType());
             $periodLength = $recurringItem->periodLength->get();
             $periodType = $recurringItem->periodType->get();
             $rebillCount = $recurringItem->rebillCount->get();
             $setupPrice = $recurringItem->setupPrice->get();
             $periodPrice = $recurringItem->periodPrice->get();
             $ScheduleDetails = array('Description' => PayPalTypes::RecurringItemDescription($recurringItem), 'PaymentPeriod' => array('BillingPeriod' => $mapping[$periodType], 'BillingFrequency' => $periodLength, 'TotalBillingCycles' => $rebillCount, 'Amount' => PayPalTypes::BasicAmountType($periodPrice * $quantity)), 'AutoBillOutstandingAmount' => 'NoAutoBill');
             if ($rebillCount > 0) {
                 $ScheduleDetails['PaymentPeriod']['TotalBillingCycles'] = $rebillCount;
             }
             if ($setupPrice > 0) {
                 $ScheduleDetails['ActivationDetails'] = array('InitialAmount' => PayPalTypes::BasicAmountType($setupPrice * $quantity), 'FailedInitialAmountAction' => 'ContinueOnFailure');
             }
             $this->apiMessage = array('CreateRecurringPaymentsProfileRequest' => array('Version' => API_VERSION, 'CreateRecurringPaymentsProfileRequestDetails' => array('Token' => $this->tokenValue, 'RecurringPaymentsProfileDetails' => $RecurringPaymentsProfileDetails, 'ScheduleDetails' => $ScheduleDetails)));
             $this->apiMessage = array($this->apiMessage);
             $response = PayPalBase::getSoapClient()->__soapCall('CreateRecurringPaymentsProfile', $this->apiMessage, null, PayPalBase::getSoapHeader());
             parent::registerAPIResponse($response);
             PaypalBase::setOperationStatus(true);
             if ($response->Ack == 'Success') {
                 $result[$recurringItem->getID()] = array('Timestamp' => $response->Timestamp, 'Ack' => $response->Ack, 'Version' => $response->Version, 'Build' => $response->Build, 'CreateRecurringPaymentsProfileResponseDetails' => array('ProfileID' => $response->CreateRecurringPaymentsProfileResponseDetails->ProfileID, 'ProfileStatus' => $response->CreateRecurringPaymentsProfileResponseDetails->ProfileStatus));
             }
         }
     } catch (SoapFault $Exception) {
         parent::registerAPIException($Exception);
         PaypalBase::setOperationStatus(false);
         return false;
     }
     return $result;
 }
 protected function processAuth($api, $type)
 {
     $paypal = $this->getHandler($api);
     $address = PayPalTypes::AddressType($this->details->firstName->get() . ' ' . $this->details->lastName->get(), $this->details->address->get(), '', $this->details->city->get(), $this->details->state->get(), $this->details->postalCode->get(), $this->details->country->get(), $this->details->phone->get());
     $personName = PayPalTypes::PersonNameType('', $this->details->firstName->get(), '', $this->details->lastName->get());
     $payerInfo = PayPalTypes::PayerInfoType($this->details->email->get(), $this->details->clientID->get(), 'verified', $personName, $this->details->country->get(), '', $address);
     $paymentDetails = PayPalTypes::PaymentDetailsType($this->details->amount->get(), $this->details->amount->get(), 0, 0, 0, $this->details->description->get(), $this->details->clientID->get(), $this->details->invoiceID->get(), '', '', '', array(), $this->details->currency->get());
     $paypal->setParams($type, $this->data['token'], $this->data['PayerID'], $paymentDetails);
     $paypal->execute($api);
     if ($paypal->success()) {
         $response = $paypal->getAPIResponse();
         if (isset($response->Errors)) {
             $error = isset($response->Errors->LongMessage) ? $response->Errors : ($error = $response->Errors[0]);
             return new TransactionError($error->LongMessage, $response);
         } else {
             $paymentInfo = $response->DoExpressCheckoutPaymentResponseDetails->PaymentInfo;
             $result = new TransactionResult();
             $result->gatewayTransactionID->set($paymentInfo->TransactionID);
             $result->amount->set($paymentInfo->GrossAmount);
             $result->currency->set($response->Currency);
             $result->rawResponse->set($response);
             if ('Sale' == $type) {
                 $result->setTransactionType(TransactionResult::TYPE_SALE);
             } else {
                 $result->setTransactionType(TransactionResult::TYPE_AUTH);
             }
             return $result;
         }
     } else {
         return $paypal->getAPIException();
     }
 }
Example #4
0
 /**
  * Adds Item to the Payment Details
  *
  * @param string $Name
  * @param float $Number
  * @param integer $Quantity
  * @param float $Tax
  * @param float $Amount
  * @param string $currencyID
  */
 public function addPaymentItem($Name = '', $Number = '', $Quantity = 1, $Tax = '', $Amount = '', $currencyID = 'USD')
 {
     $this->apiMessage['PaymentDetails']['PaymentDetailsItem'][] = PayPalTypes::PaymentDetailsItemType($Name, $Number, $Quantity, $Tax, $Amount, $currencyID);
 }
Example #5
0
 public static function BillingAgreementDetailsType(RecurringItem $recurringItem, $BillingType = 'RecurringPayments', $PaymentType = 'Any', $BillingAgreementCustom = '')
 {
     return array('BillingAgreementDescription' => PayPalTypes::RecurringItemDescription($recurringItem), 'BillingType' => $BillingType, 'PaymentType' => $PaymentType, 'BillingAgreementCustom' => $BillingAgreementCustom);
 }
Example #6
0
 /**
  * Generates the TransactionSearchRequestType
  * 
  * Prepares a multi-dimensional array for the message to be used in the search.
  *
  * @param integer $StartDate UNIXTIMESTAMP
  * @param intefer $EndDate UNIXTIMESTAMP
  * @param string $PayerEmail
  * @param string $ReceiverEmail
  * @param string $ReceiptID
  * @param string $TransactionID
  * @param string $PayerName
  * @param string $AuctionItemNumber
  * @param string $InvoiceID
  * @param string $CardNumber
  * @param string $TransactionClass
  * @param float $Amount
  * @param string $CurrencyCode
  * @param string $Status
  * @param string $currencyID
  */
 public function setParams($StartDate, $EndDate = 0, $PayerEmail = '', $ReceiverEmail = '', $ReceiptID = '', $TransactionID = '', $PayerName = '', $AuctionItemNumber = '', $InvoiceID = '', $CardNumber = '', $TransactionClass = '', $Amount = '', $CurrencyCode = '', $Status = '', $currencyID = 'USD')
 {
     $this->apiMessage = PayPalTypes::TransactionSearchRequestType($StartDate, $EndDate, $PayerEmail, $ReceiverEmail, $ReceiptID, $TransactionID, $PayerName, $AuctionItemNumber, $InvoiceID, $CardNumber, $TransactionClass, $Amount, $CurrencyCode, $Status, $currencyID);
 }
 protected function processAuth($api, $type)
 {
     $paypal = $this->getHandler($api);
     $address = PayPalTypes::AddressType($this->details->firstName->get() . ' ' . $this->details->lastName->get(), $this->details->address->get(), '', $this->details->city->get(), $this->details->state->get(), $this->details->postalCode->get(), $this->details->country->get(), $this->details->phone->get());
     $personName = PayPalTypes::PersonNameType('', $this->details->firstName->get(), '', $this->details->lastName->get());
     $payerInfo = PayPalTypes::PayerInfoType($this->details->email->get(), $this->details->clientID->get(), 'verified', $personName, $this->details->country->get(), '', $address);
     $cardType = $this->getCardType();
     if ('American Express' == $cardType) {
         $cardType = 'Amex';
     }
     $creditCardDetails = PayPalTypes::CreditCardDetailsType($cardType, $this->getCardNumber(), $this->getExpirationMonth(), $this->getExpirationYear(), $payerInfo, $this->getCardCode());
     $paymentDetails = PayPalTypes::PaymentDetailsType($this->details->amount->get(), $this->details->amount->get(), 0, 0, 0, $this->details->description->get(), $this->details->clientID->get(), $this->details->invoiceID->get(), '', 'ipn_notify.php', $address, array(), $this->details->currency->get());
     $paypal->setParams($type, $paymentDetails, $creditCardDetails, $this->details->ipAddress->get(), session_id());
     $paypal->execute($api);
     if ($paypal->success()) {
         $response = $paypal->getAPIResponse();
         if (isset($response->Errors)) {
             $error = isset($response->Errors->LongMessage) ? $response->Errors : ($error = $response->Errors[0]);
             return new TransactionError($error->LongMessage, $response);
         } else {
             $result = new TransactionResult();
             $result->gatewayTransactionID->set($response->TransactionID);
             $result->amount->set($response->Amount);
             $result->currency->set($response->Currency);
             $avs = PaypalCommon::getAVSbyCode($response->AVSCode);
             $result->AVSaddr->set($avs[0]);
             $result->AVSzip->set($avs[1]);
             $result->CVVmatch->set(PaypalCommon::getCVVByCode($response->CVV2Code));
             $result->rawResponse->set($response);
             if ('Sale' == $type) {
                 $result->setTransactionType(TransactionResult::TYPE_SALE);
             } else {
                 $result->setTransactionType(TransactionResult::TYPE_AUTH);
             }
             return $result;
         }
     } else {
         return $paypal->getAPIException();
     }
 }
Example #8
0
 /**
  * Creates the static SoapHeader
  *
  * This is the Custom Security Header passed to paypal.
  *
  * The username here is not the same as you account username and so is the password.
  * The subject is the payment on whose behalf you have been authorized to make the operation call.
  *
  * @param string $Username
  * @param string $Password
  * @param string $Signature
  * @param string $Subject
  */
 public static function registerSoapHeader($Username, $Password, $Signature, $Subject = '')
 {
     $Credentials = new SoapVar(PayPalTypes::UserIdPasswordType($Username, $Password, $Signature, $Subject), SOAP_ENC_OBJECT);
     $headerNameSpace = 'urn:ebay:api:PayPalAPI';
     $headerName = 'RequesterCredentials';
     $headerData = array("Credentials" => $Credentials);
     $mustUnderstand = true;
     PayPalBase::setSoapHeader(new SoapHeader($headerNameSpace, $headerName, $headerData, $mustUnderstand));
 }