session_start();
$was_submitted = false;
$logger = new SampleLogger('VoidReceipt.php', PEAR_LOG_DEBUG);
$logger->_log('POST variables: ' . print_r($_POST, true));
$profile = $_SESSION['APIProfile'];
// Verify that user is logged in
if (!isset($profile)) {
    // Not logged in -- Back to the login page
    $logger->_log('You are not logged in;  return to index.php');
    $location = 'index.php';
    header("Location: {$location}");
} else {
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
$void_request =& PayPal::getType('DoVoidRequestType');
if (PayPal::isError($void_request)) {
    $logger->_log('Error in request: ' . print_r($void_request, true));
} else {
    $logger->_log('Create request: ' . print_r($void_request, true));
}
// Set request fields
$authorization_id = $_POST['authorization_id'];
if (isset($authorization_id)) {
    $void_request->setAuthorizationID($authorization_id, 'iso-8859-1');
}
$note = $_POST['note'];
if (isset($note)) {
    $void_request->setNote($note);
}
$logger->_log('Initial request: ' . print_r($void_request, true));
 function ipn(&$BL)
 {
     if ($_POST['pp'] == "paypalwpp") {
         $this->item_number = $_POST['item_number'];
         $this->transaction_id = 0;
         $this->payment_status = '';
         $pp_vals = $BL->pp_vals->getByKey("paypalwpp");
         $temp = $BL->orphan_orders->hasAnyOne(array("WHERE `item_number`=" . intval($this->item_number)));
         $O_order = array();
         foreach ($BL->orphan_order_datas->find(array("WHERE `orphan_order_id`=" . intval($temp['orphanorder_id']))) as $data) {
             $O_order[$data['orphan_order_field']] = $data['orphan_order_value'];
         }
         if (count($O_order)) {
             $amount = number_format($O_order['gross_amount'], 2);
         } else {
             $invoice = $BL->invoices->get("WHERE `invoice_no`=" . intval($this->item_number));
             $amount = number_format($invoice[0]['gross_amount'], 2);
         }
         require_once 'PayPal.php';
         require_once 'PayPal/Profile/API.php';
         require_once 'PayPal/Profile/Handler.php';
         require_once 'PayPal/Profile/Handler/Array.php';
         require_once 'PayPal/Type/DoDirectPaymentRequestType.php';
         require_once 'PayPal/Type/DoDirectPaymentRequestDetailsType.php';
         require_once 'PayPal/Type/DoDirectPaymentResponseType.php';
         // Add all of the types
         require_once 'PayPal/Type/BasicAmountType.php';
         require_once 'PayPal/Type/PaymentDetailsType.php';
         require_once 'PayPal/Type/AddressType.php';
         require_once 'PayPal/Type/CreditCardDetailsType.php';
         require_once 'PayPal/Type/PayerInfoType.php';
         require_once 'PayPal/Type/PersonNameType.php';
         // Ack related constants
         define('ACK_SUCCESS', 'Success');
         define('ACK_SUCCESS_WITH_WARNING', 'SuccessWithWarning');
         // Refund related constants
         define('REFUND_PARTIAL', 'Partial');
         define('REFUND_FULL', 'Full');
         // Profile
         if ($this->demo_mode) {
             define('ENVIRONMENT', 'sandbox');
         } else {
             define('ENVIRONMENT', 'live');
         }
         define('UNITED_STATES', 'US');
         $dummy = @new APIProfile();
         $environments = $dummy->getValidEnvironments();
         $handler =& ProfileHandler_Array::getInstance(array('username' => $pp_vals['paypalwpp_apiUsername'], 'certificateFile' => null, 'subject' => null, 'environment' => ENVIRONMENT));
         $pid = ProfileHandler::generateID();
         $profile = new APIProfile($pid, $handler);
         $profile->setAPIUsername($pp_vals['paypalwpp_apiUsername']);
         $profile->setAPIPassword($pp_vals['paypalwpp_apiPassword']);
         if (is_file($pp_vals['paypalwpp_certFile'])) {
             $profile->setCertificateFile($pp_vals['paypalwpp_certFile']);
         }
         $profile->setSignature($pp_vals['paypalwpp_signature']);
         $profile->setEnvironment(ENVIRONMENT);
         $caller =& PayPal::getCallerServices($profile);
         $_SESSION['APIProfile'] = $profile;
         $_SESSION['caller'] = $caller;
         $dp_request =& PayPal::getType('DoDirectPaymentRequestType');
         /**
          * Get posted request values
          */
         $paymentType = 'Sale';
         $firstName = $_POST['paypalwpp_firstName'];
         $lastName = $_POST['paypalwpp_lastName'];
         $creditCardType = $_POST['paypalwpp_creditCardType'];
         $creditCardNumber = $_POST['paypalwpp_creditCardNumber'];
         $expDateMonth = $_POST['paypalwpp_expDateMonth'];
         $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
         $expDateYear = $_POST['paypalwpp_expDateYear'];
         $cvv2Number = $_POST['paypalwpp_cvv2Number'];
         $address1 = $_POST['paypalwpp_address1'];
         $address2 = $_POST['paypalwpp_address2'];
         $city = $_POST['paypalwpp_city'];
         $state = $_POST['paypalwpp_state'];
         $zip = $_POST['paypalwpp_zip'];
         $amount = $amount;
         // Populate SOAP request information
         // Payment details
         $OrderTotal =& PayPal::getType('BasicAmountType');
         $OrderTotal->setattr('currencyID', 'USD');
         $OrderTotal->setval($amount, 'iso-8859-1');
         $PaymentDetails =& PayPal::getType('PaymentDetailsType');
         $PaymentDetails->setOrderTotal($OrderTotal);
         $shipTo =& PayPal::getType('AddressType');
         $shipTo->setName($firstName . ' ' . $lastName);
         $shipTo->setStreet1($address1);
         $shipTo->setStreet2($address2);
         $shipTo->setCityName($city);
         $shipTo->setStateOrProvince($state);
         $shipTo->setCountry(UNITED_STATES);
         $shipTo->setPostalCode($zip);
         $PaymentDetails->setShipToAddress($shipTo);
         $dp_details =& PayPal::getType('DoDirectPaymentRequestDetailsType');
         $dp_details->setPaymentDetails($PaymentDetails);
         // Credit Card info
         $card_details =& PayPal::getType('CreditCardDetailsType');
         $card_details->setCreditCardType($creditCardType);
         $card_details->setCreditCardNumber($creditCardNumber);
         $card_details->setExpMonth($padDateMonth);
         $card_details->setExpYear($expDateYear);
         $card_details->setCVV2($cvv2Number);
         $payer =& PayPal::getType('PayerInfoType');
         $person_name =& PayPal::getType('PersonNameType');
         $person_name->setFirstName($firstName);
         $person_name->setLastName($lastName);
         $payer->setPayerName($person_name);
         $payer->setPayerCountry(UNITED_STATES);
         $payer->setAddress($shipTo);
         $card_details->setCardOwner($payer);
         $dp_details->setCreditCard($card_details);
         $dp_details->setIPAddress($_SERVER['SERVER_ADDR']);
         $dp_details->setPaymentAction($paymentType);
         $dp_request->setDoDirectPaymentRequestDetails($dp_details);
         $caller =& PayPal::getCallerServices($profile);
         $response = $caller->DoDirectPayment($dp_request);
         $ack = $response->getAck();
         $this->payment_status = $ack;
         $this->transaction_id = $response->TransactionID;
         if (!empty($this->item_number) && !empty($this->transaction_id) && ($this->payment_status == ACK_SUCCESS || $this->payment_status == ACK_SUCCESS_WITH_WARNING)) {
             $BL->invoices->processTransaction($this->item_number, $this->transaction_id);
             return true;
         }
     }
     return false;
 }
session_start();
$was_submitted = false;
$logger = new SampleLogger('GetBalanceRecipt.php', PEAR_LOG_DEBUG);
$logger->_log('POST variables: ' . print_r($_POST, true));
$profile = $_SESSION['APIProfile'];
// Verify that user is logged in
if (!isset($profile)) {
    // Not logged in -- Back to the login page
    $logger->_log('You are not logged in;  return to index.php');
    $location = 'index.php';
    header("Location: {$location}");
} else {
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
$getbalance_request =& PayPal::getType('GetBalanceRequestType');
if (PayPal::isError($getbalance_request)) {
    $logger->_log('Error in request: ' . print_r($getbalance_request, true));
} else {
    $logger->_log('Create request: ' . print_r($getbalance_request, true));
}
$logger->_log('Initial request: ' . print_r($getbalance_request, true));
$caller =& PayPal::getCallerServices($profile);
$response = $caller->GetBalance($getbalance_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
        // Good to break out;
        break;
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
$boa_request =& PayPal::getType('BillOutstandingAmountRequestType');
if (PayPal::isError($crpp_request)) {
    $logger->_log('Error in request: ' . print_r($boa_request, true));
} else {
    $logger->_log('Create request: ' . print_r($boa_request, true));
}
$logger->_log('Initial request: ' . print_r($boa_request, true));
/**
 * Get posted request values
 */
$profileID = $_POST['profileID'];
$amount = $_POST['amount'];
$boa_details =& PayPal::getType('BillOutstandingAmountRequestDetailsType');
$boa_details->setProfileID($profileID);
$boa_details->setAmount($amount);
$boa_request->setBillOutstandingAmountRequestDetails($boa_details);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->BillOutstandingAmount($boa_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
        // Good to break out;
        break;
    default:
        $_SESSION['response'] =& $response;
Exemple #5
0
 function refundPayment($transaction_id, $type = 'Full', $amount = '', $note = '')
 {
     if (!$this->setEnvironment()) {
         return false;
     }
     if (!$transaction_id) {
         return false;
     }
     if (!$note) {
         $note = sprintf('Refund %s', $transaction_id);
     }
     $pid = ProfileHandler::generateID();
     $handler =& ProfileHandler_Array::getInstance(array('username' => $this->pp_username, 'certificateFile' => null, 'subject' => null, 'environment' => $this->environment));
     $profile = new APIProfile($pid, $handler);
     $profile->setAPIUsername($this->pp_username);
     $profile->setAPIPassword($this->pricepp_pass);
     $profile->setSignature($this->pp_signature);
     $profile->setCertificateFile(null);
     $profile->setEnvironment($this->environment);
     $ref_details =& PayPal::getType('RefundTransactionRequestType');
     $ref_details->setVersion("51.0");
     $transactionID = filter_var($transaction_id, FILTER_SANITIZE_STRING);
     $refundType = filter_var($type, FILTER_SANITIZE_STRING);
     $refundAmount = filter_var($amount, FILTER_SANITIZE_STRING);
     $refundNote = filter_var($note, FILTER_SANITIZE_STRING);
     $ref_details->setTransactionID($transactionID, 'iso-8859-1');
     $ref_details->setRefundType($refundType, 'iso-8859-1');
     $ref_details->setAmount($refundAmount, 'iso-8859-1');
     $ref_details->setMemo($refundNote, 'iso-8859-1');
     $caller =& PayPal::getCallerServices($profile);
     $this->logger->_log("Refund Profile: " . print_r($profile, true) . "");
     $this->logger->_log("Refund Request Details: " . print_r($ref_details, true) . "");
     $response = $caller->RefundTransaction($ref_details);
     $this->logger->_log("Refund Response Details: " . print_r($response, true) . "");
     $ack = $response->getAck();
     $ref_return = array();
     if ($ack == 'Success') {
         $ref_return = array('success' => array('field' => 'Refund Processing', 'desc' => $response));
     } else {
         $ref_return = array('error' => array('field' => 'Refund Processing', 'desc' => $response->Errors->LongMessage, 'short_message' => $response->Errors->ShortMessage, 'error_code' => $response->Errors->ErrorCode, 'correlation_id' => $response->CorrelationID));
     }
     return $ref_return;
 }
Exemple #6
0
 function save($data)
 {
     $data = $this->udm->getData();
     foreach ($data as $key => $value) {
         if ($field = $this->checkPrefix($key)) {
             $plugin[$field] = $value;
         }
     }
     $options = $this->getOptions();
     require_once 'PayPal.php';
     require_once 'PayPal/Profile/API.php';
     require_once 'PayPal/Profile/Handler.php';
     require_once 'PayPal/Profile/Handler/Array.php';
     require_once 'PayPal/Type/DoDirectPaymentRequestType.php';
     require_once 'PayPal/Type/DoDirectPaymentRequestDetailsType.php';
     require_once 'PayPal/Type/DoDirectPaymentResponseType.php';
     require_once 'PayPal/Type/BasicAmountType.php';
     require_once 'PayPal/Type/PaymentDetailsType.php';
     require_once 'PayPal/Type/AddressType.php';
     require_once 'PayPal/Type/CreditCardDetailsType.php';
     require_once 'PayPal/Type/PayerInfoType.php';
     require_once 'PayPal/Type/PersonNameType.php';
     $pid =& ProfileHandler::generateID();
     $handler =& ProfileHandler_Array::getInstance(array('username' => $options['api_username'], 'password' => $options['api_password'], 'certificateFile' => $options['cert_file'], 'subject' => null, 'environment' => $options['environment']));
     $profile =& APIProfile::getInstance($pid, $handler);
     $dp_request =& PayPal::getType('DoDirectPaymentRequestType');
     $firstName = $data['First_Name'];
     $lastName = $data['Last_Name'];
     $creditCardType = $plugin['cc_type'];
     $creditCardNumber = $plugin['cc_number'];
     $expDateMonth = $plugin['cc_expiration']['m'];
     // Month must be padded with leading zero
     $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
     $expDateYear = $plugin['cc_expiration']['Y'];
     $cvv2Number = $plugin['cc_cvv2'];
     $address1 = $data['Street'];
     $address2 = isset($data['Street_1']) ? $data['Street_1'] : null;
     $city = $data['City'];
     $state = $data['State'];
     $zip = $data['Zip'];
     $amount = $plugin['amount'];
     $OrderTotal =& PayPal::getType('BasicAmountType');
     $OrderTotal->setattr('currencyID', 'USD');
     $OrderTotal->setval($amount, 'iso-8859-1');
     $PaymentDetails =& PayPal::getType('PaymentDetailsType');
     $PaymentDetails->setOrderTotal($OrderTotal);
     $shipTo =& PayPal::getType('AddressType');
     $shipTo->setName($firstName . ' ' . $lastName);
     $shipTo->setStreet1($address1);
     $shipTo->setStreet2($address2);
     $shipTo->setCityName($city);
     $shipTo->setStateOrProvince($state);
     $shipTo->setCountry('US');
     $shipTo->setPostalCode($zip);
     $PaymentDetails->setShipToAddress($shipTo);
     $dp_details =& PayPal::getType('DoDirectPaymentRequestDetailsType');
     $dp_details->setPaymentDetails($PaymentDetails);
     // Credit Card info
     $card_details =& PayPal::getType('CreditCardDetailsType');
     $card_details->setCreditCardType($creditCardType);
     $card_details->setCreditCardNumber($creditCardNumber);
     $card_details->setExpMonth($padDateMonth);
     $card_details->setExpYear($expDateYear);
     $card_details->setCVV2($cvv2Number);
     $payer =& PayPal::getType('PayerInfoType');
     $person_name =& PayPal::getType('PersonNameType');
     $person_name->setFirstName($firstName);
     $person_name->setLastName($lastName);
     $payer->setPayerName($person_name);
     $payer->setPayerCountry('US');
     $payer->setAddress($shipTo);
     if (isset($data['Email'])) {
         $payer->setPayer($data['Email']);
     }
     $card_details->setCardOwner($payer);
     $dp_details->setCreditCard($card_details);
     $dp_details->setIPAddress($_SERVER['SERVER_ADDR']);
     $dp_details->setPaymentAction('Sale');
     $dp_request->setDoDirectPaymentRequestDetails($dp_details);
     $caller =& PayPal::getCallerServices($profile);
     if (PEAR::isError($caller)) {
         trigger_error($caller->getMessage());
         return false;
     }
     $response = $caller->DoDirectPayment($dp_request);
     $ack = $response->getAck();
     define('ACK_SUCCESS', 'Success');
     define('ACK_SUCCESS_WITH_WARNING', 'SuccessWithWarning');
     switch ($ack) {
         case ACK_SUCCESS:
         case ACK_SUCCESS_WITH_WARNING:
             if (isset($options['response']) && $options['response']) {
                 $response_code = 'Transaction ID: ' . $response->getTransactionID() . "\n" . 'Completed AVS Code: ' . $response->getAVSCode() . "\n" . 'CVV2 Code: ' . $response->getCVV2Code();
                 require_once 'AMP/System/User/Profile/Profile.php';
                 $profile =& new AMP_System_User_Profile($this->dbcon, $this->udm->uid);
                 if ($profile->hasData()) {
                     $update = array($options['response'] => $response_code);
                     $profile->mergeData($update);
                     $profile->save();
                 } else {
                     trigger_error('cannot update profile with paypal response: ' . $response_code);
                 }
             }
             return true;
         default:
             require_once 'PayPal/Type/AbstractResponseType.php';
             require_once 'PayPal/Type/ErrorType.php';
             require_once 'PayPal/Type/DoDirectPaymentResponseType.php';
             $errors =& $response->getErrors();
             if (!is_array($errors)) {
                 $errors = array($errors);
             }
             foreach ($errors as $error) {
                 trigger_error($error->getShortMessage() . ' : ' . $error->getLongMessage());
                 $flash =& AMP_System_Flash::instance();
                 $flash->add_error($error->getLongMessage());
             }
     }
     return false;
 }
$card_details->setExpMonth($padDateMonth);
$card_details->setExpYear($expDateYear);
$card_details->setCVV2($cvv2Number);
$logger->_log('card_details: ' . print_r($card_details, true));
$payer =& PayPal::getType('PayerInfoType');
$person_name =& PayPal::getType('PersonNameType');
$person_name->setFirstName($firstName);
$person_name->setLastName($lastName);
$payer->setPayerName($person_name);
$payer->setPayerCountry(UNITED_STATES);
$payer->setAddress($shipTo);
$card_details->setCardOwner($payer);
$crpp_details->setCreditCard($card_details);
$scheduleDetails =& PayPal::getType('ScheduleDetailsType');
$scheduleDetails->setDescription($profileDesc);
$billingPeriodDetails =& PayPal::getType('BillingPeriodDetailsType');
$billingPeriodDetails->setBillingPeriod($billingPeriod);
$billingPeriodDetails->setBillingFrequency($billingFrequency);
$billingPeriodDetails->setTotalBillingCycles($totalBillingCycles);
$billingPeriodDetails->setAmount($amount);
$scheduleDetails->setPaymentPeriod($billingPeriodDetails);
$crpp_details->setScheduleDetails($scheduleDetails);
$crpp_request->setCreateRecurringPaymentsProfileRequestDetails($crpp_details);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->CreateRecurringPaymentsProfile($crpp_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
<?php

include 'ppsdk_include_path.inc';
require_once 'PayPal.php';
require_once 'PayPal/Profile/API.php';
require_once 'PayPal/Profile/Handler.php';
require_once 'PayPal/Profile/Handler/Array.php';
require_once 'request_base.php';
$trans_search =& PayPal::getType('TransactionSearchRequestType');
$trans_search->setStartDate(date('Y-m-d') . 'T00:00:00-0700');
$response = $caller->TransactionSearch($trans_search);
$ack = $response->getAck();
echo "RESULT: {$ack}\n";
var_dump($response);
?>

 /**
  * Charges funds from Paypal from the given token
  *
  * @param string $token - Token given by Paypal on a GET request on the return URL
  * @return bool
  */
 public function chargeExpressCheckout($token)
 {
     if (!$this->getCaller()) {
         return false;
     }
     $ExpressCheckoutDetailsRequestType =& PayPal::getType('GetExpressCheckoutDetailsRequestType');
     $ExpressCheckoutDetailsRequestType->setToken($token);
     // Execute the call
     $r = $this->api_caller->GetExpressCheckoutDetails($ExpressCheckoutDetailsRequestType);
     if ($r->Ack == 'Success') {
         $details = $r->getGetExpressCheckoutDetailsResponseDetails();
         $buyer_info = $details->getPayerInfo();
         $buyer_name = $buyer_info->getPayerName();
         $buyer_address = $buyer_info->getAddress();
         $this->setBillingFirstName($buyer_name->FirstName);
         $this->setBillingLastName($buyer_name->LastName);
         $this->setBillingStreet1($buyer_address->Street1);
         $this->setBillingStreet2($buyer_address->Street2);
         $this->setBillingCity($buyer_address->CityName);
         $this->setBillingState($buyer_address->StateOrProvince);
         $this->setBillingZip($buyer_address->PostalCode);
         $this->setBillingCountry($buyer_address->Country);
         $this->setBillingEmail($buyer_info->Payer);
         $BasicAmountType =& PayPal::getType('BasicAmountType');
         $BasicAmountType->setattr('currencyID', $this->currency_id);
         $BasicAmountType->setval($this->getData('total'));
         $AddressType =& PayPal::getType('AddressType');
         $AddressType->setStreet1($this->getBillingStreet1());
         $AddressType->setStreet2($this->getBillingStreet2());
         $AddressType->setCityName($this->getBillingCity());
         $AddressType->setStateOrProvince($this->getBillingState());
         $AddressType->setPostalCode($this->getBillingZip());
         $AddressType->setCountry($this->getBillingCountry());
         $PaymentDetailsType =& PayPal::getType('PaymentDetailsType');
         $PaymentDetailsType->setOrderTotal($BasicAmountType);
         $PaymentDetailsType->setOrderDescription($this->getData('description'));
         $PaymentDetailsType->setCustom($this->getData('custom'));
         $PaymentDetailsType->setShipToAddress($AddressType);
         $request =& PayPal::getType('DoExpressCheckoutPaymentRequestDetailsType');
         $request->setToken($token);
         $request->setPayerID($buyer_info->PayerID);
         $request->setPaymentAction($this->api_action);
         $request->setPaymentDetails($PaymentDetailsType);
         return $this->execute($request, 'ExpressCheckoutPayment', 'Do');
     } else {
         $this->api_error_string = $request->getMessage();
         return false;
     }
 }
$shipTo->setPostalCode($zip);
$PaymentDetails->setShipToAddress($shipTo);
$dp_details =& PayPal::getType('DoDirectPaymentRequestDetailsType');
$dp_details->setPaymentDetails($PaymentDetails);
// Credit Card info
$card_details =& PayPal::getType('CreditCardDetailsType');
$card_details->setCreditCardType($creditCardType);
$card_details->setCreditCardNumber($creditCardNumber);
$card_details->setExpMonth($padDateMonth);
// $card_details->setExpMonth('01');
$card_details->setExpYear($expDateYear);
// $card_details->setExpYear('2010');
$card_details->setCVV2($cvv2Number);
$logger->_log('card_details: ' . print_r($card_details, true));
$payer =& PayPal::getType('PayerInfoType');
$person_name =& PayPal::getType('PersonNameType');
$person_name->setFirstName($firstName);
$person_name->setLastName($lastName);
$payer->setPayerName($person_name);
$payer->setPayerCountry(UNITED_STATES);
$payer->setAddress($shipTo);
$card_details->setCardOwner($payer);
$dp_details->setCreditCard($card_details);
$dp_details->setIPAddress($_SERVER['SERVER_ADDR']);
$dp_details->setPaymentAction($paymentType);
$dp_request->setDoDirectPaymentRequestDetails($dp_details);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->DoDirectPayment($dp_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
            header("Location: " . $payPalURL);
            exit;
        default:
            $_SESSION['response'] =& $response;
            $logger->_log('SetExpressCheckout failed: ' . print_r($response, true));
            $location = "ApiError.php";
            header("Location: {$location}");
    }
} else {
    // We have a TOKEN from paypal
    // GetExpressCheckoutDetails handling here
    $paymentType = $_REQUEST['paymentType'];
    $token = $_REQUEST['token'];
    $paymentAmount = $_REQUEST['paymentAmount'];
    $currencyCodeType = $_REQUEST['currencyCodeType'];
    $ec_request =& PayPal::getType('GetExpressCheckoutDetailsRequestType');
    $ec_request->setToken($token);
    $caller =& PayPal::getCallerServices($profile);
    // Execute SOAP request
    $response = $caller->GetExpressCheckoutDetails($ec_request);
    // $display = print_r($response, true);
    $logger->_log('GetExpressCheckoutDetails response: ' . print_r($response, true));
    $ack = $response->getAck();
    $logger->_log('Ack=' . $ack);
    switch ($ack) {
        case ACK_SUCCESS:
        case ACK_SUCCESS_WITH_WARNING:
            // Continue on based on the require below...
            break;
        default:
            $_SESSION['response'] =& $response;
 /**
  * Deposits a transaction
  * @throws jmsPaymentApprovalExpiredException
  * @throws jmsPaymentCommunicationException
  * @see plugins/jmsPaymentPlugin/lib/method/jmsPaymentMethod#deposit($data, $retry)
  */
 public function deposit(jmsPaymentMethodData $data, $retry = false)
 {
     $amount = PayPal::getType('BasicAmountType');
     $amount->setattr('currencyID', $data->getCurrency());
     $amount->setval(number_format($data->getAmount(), 2));
     $captureRequest = Paypal::getType('DoCaptureRequestType');
     $captureRequest->setAmount($amount);
     $captureRequest->setAuthorizationId($data->getValue('external_reference_number'));
     $captureRequest->setCompleteType('Complete');
     if ($data->hasValue('note')) {
         $captureRequest->setNote($data->getValue('note'));
     }
     $result = $this->getCallerServices()->DoCapture($captureRequest);
     if (Pear::isError($result)) {
         throw new jmsPaymentCommunicationException('Error while capturing payment: ' . $result->getMessage());
     }
     if ($result->Ack !== 'Success') {
         throw new jmsPaymentCommunicationException('Error ' . $result->Ack . ' while capturing.');
     }
     $response = $result->getDoCaptureResponseDetails();
     $paymentInfo = $response->getPaymentInfo();
     $data->setResponseCode($paymentInfo->PaymentStatus);
     $data->setProcessedAmount($data->getAmount());
     // process the payment status
     switch ($paymentInfo->PaymentStatus) {
         case 'Expired':
             $e = new jmsPaymentApprovalExpiredException();
             $e->setPaymentMethodData($data);
             throw $e;
         case 'Completed':
             return $data;
         case 'Pending':
             $e = new jmsPaymentException('Payment is still pending; reason: ' . $paymentInfo->PendingReason);
             $data->setReasonCode($paymentInfo->PendingReason);
             $e->setPaymentMethodData($data);
             throw $e;
         default:
             // TODO: Some more processing as to what went wrong exactly
             $e = new jmsPaymentException('Payment could not be completed. Status: ' . $paymentInfo->PaymentStatus);
             $e->setPaymentMethodData($data);
             throw $e;
     }
 }
$token = $_REQUEST['token'];
$paymentAmount = $_REQUEST['paymentAmount'];
$paymentType = $_REQUEST['paymentType'];
$currencyCodeType = $_REQUEST['currencyCodeType'];
$payerID = $_REQUEST['payerID'];
$ec_details =& PayPal::getType('DoExpressCheckoutPaymentRequestDetailsType');
$ec_details->setToken($token);
$ec_details->setPayerID($payerID);
$ec_details->setPaymentAction($paymentType);
$amt_type =& PayPal::getType('BasicAmountType');
$amt_type->setattr('currencyID', $currencyCodeType);
$amt_type->setval($paymentAmount, 'iso-8859-1');
$payment_details =& PayPal::getType('PaymentDetailsType');
$payment_details->setOrderTotal($amt_type);
$ec_details->setPaymentDetails($payment_details);
$ec_request =& PayPal::getType('DoExpressCheckoutPaymentRequestType');
$ec_request->setDoExpressCheckoutPaymentRequestDetails($ec_details);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->DoExpressCheckoutPayment($ec_request);
// $display = print_r($response, true);
$logger->_log('DoExpressCheckoutPayment response: ' . print_r($response, true));
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
        // Show HTML below
        break;
    default:
        $_SESSION['response'] =& $response;
$authorization_id = $_POST['authorization_id'];
if (isset($authorization_id)) {
    $capture_request->setAuthorizationID($authorization_id, 'iso-8859-1');
}
$complete_code_type = $_POST['CompleteCodeType'];
$capture_request->setCompleteType($complete_code_type);
$invoice_id = $_POST['invoice_id'];
if (isset($invoice_id)) {
    $capture_request->setInvoiceID($invoice_id);
}
$note = $_POST['note'];
if (isset($note)) {
    $capture_request->setNote($note);
}
$amount = $_POST['amount'];
$amtType =& PayPal::getType('BasicAmountType');
$amtType->setattr('currencyID', 'USD');
$amtType->setval($amount, 'iso-8859-1');
$capture_request->setAmount($amtType);
$logger->_log('Initial request: ' . print_r($capture_request, true));
$caller =& PayPal::getCallerServices($profile);
$response = $caller->DoCapture($capture_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
        // Good to break out;
        break;
    default:
        $_SESSION['response'] = $response;
$was_submitted = false;
$logger = new SampleLogger('TransactionDetails.php', PEAR_LOG_DEBUG);
$logger->_log('POST variables: ' . print_r($_POST, true));
$profile = $_SESSION['APIProfile'];
// Verify that user is logged in
if (!isset($profile)) {
    // Not logged in -- Back to the login page
    $logger->_log('You are not logged in;  return to index.php');
    header("Location: index.php");
    exit;
} else {
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
// $trans_details = new TransactionSearchRequestType();
$trans_details =& PayPal::getType('GetTransactionDetailsRequestType');
if (PayPal::isError($trans_details)) {
    $logger->_log('Error in request: ' . print_r($trans_details, true));
} else {
    $logger->_log('Create request: ' . print_r($trans_details, true));
}
// Set request fields
$tran_id = $_GET['transactionID'];
if (isset($tran_id)) {
    $trans_details->setTransactionId($tran_id, 'iso-8859-1');
} else {
    // Error: transaction ID was not set
    $location = 'GetTransactionDetails.php';
    header("Location: {$location}");
    exit;
}
Exemple #16
0
 /**
  * Override some of the default SOAP:: package _decode behavior to
  * handle simpleTypes and complexTypes with simpleContent.
  */
 function &_decode(&$soapval)
 {
     if (count($soapval->attributes)) {
         $attributes = $soapval->attributes;
     }
     $object =& PayPal::getType($soapval->type);
     if (PayPal::isError($object)) {
         return parent::_decode($soapval);
     }
     $this->_type_translation[$soapval->type] = $soapval->type;
     $result =& parent::_decode($soapval);
     if (!is_a($result, 'XSDType') && is_a($object, 'XSDSimpleType')) {
         $object->setval($result);
         if (isset($attributes)) {
             foreach ($attributes as $aname => $attribute) {
                 $object->setattr($aname, $attribute);
             }
         }
         $result =& $object;
     }
     return $result;
 }
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
$mrpps_request =& PayPal::getType('ManageRecurringPaymentsProfileStatusRequestType');
if (PayPal::isError($crpp_request)) {
    $logger->_log('Error in request: ' . print_r($mrpps_request, true));
} else {
    $logger->_log('Create request: ' . print_r($mrpps_request, true));
}
$logger->_log('Initial request: ' . print_r($mrpps_request, true));
/**
 * Get posted request values
 */
$profileID = $_POST['profileID'];
$action = $_POST['action'];
$mrpps_details =& PayPal::getType('ManageRecurringPaymentsProfileStatusRequestDetailsType');
$mrpps_details->setProfileID($profileID);
$mrpps_details->setAction($action);
$mrpps_request->setManageRecurringPaymentsProfileStatusRequestDetails($mrpps_details);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->ManageRecurringPaymentsProfileStatus($mrpps_request);
$ack = $response->getAck();
$logger->_log('Ack=' . $ack);
switch ($ack) {
    case ACK_SUCCESS:
    case ACK_SUCCESS_WITH_WARNING:
        // Good to break out;
        break;
    default:
        $_SESSION['response'] =& $response;
$was_submitted = false;
$logger = new SampleLogger('GetRPProfileDetails.php', PEAR_LOG_DEBUG);
$logger->_log('POST variables: ' . print_r($_POST, true));
$profile = $_SESSION['APIProfile'];
// $caller = $_SESSION['caller'];
// Verify that user is logged in
if (!isset($profile)) {
    // Not logged in -- Back to the login page
    $logger->_log('You are not logged in;  return to index.php');
    $location = '../index.php';
    header("Location: {$location}");
} else {
    $logger->_log('Profile from session: ' . print_r($profile, true));
}
// Build our request from $_POST
$grppd_request =& PayPal::getType('GetRecurringPaymentsProfileDetailsRequestType');
if (PayPal::isError($crpp_request)) {
    $logger->_log('Error in request: ' . print_r($grppd_request, true));
} else {
    $logger->_log('Create request: ' . print_r($grppd_request, true));
}
$logger->_log('Initial request: ' . print_r($grppd_request, true));
/**
 * Get posted request values
 */
$profileID = $_POST['profileID'];
$grppd_request->setProfileID($profileID);
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->GetRecurringPaymentsProfileDetails($grppd_request);
$ack = $response->getAck();
Exemple #19
0
 public function addItem($name, $amount, $quantity = 1, $description = '', $number = '', $tax = 0.0)
 {
     @($itemAmount =& PayPal::getType('BasicAmountType'));
     $itemAmount->setattr('currencyID', $this->currencyID);
     $itemAmount->setval($this->formatAmount($amount), $this->charset);
     @($itemTax =& PayPal::getType('BasicAmountType'));
     $itemTax->setattr('currencyID', $this->currencyID);
     $itemTax->setval($this->formatAmount($tax), $this->charset);
     @($item =& PayPal::getType('PaymentDetailsItemType'));
     $item->setName($name, $this->charset);
     $item->setQuantity($quantity, $this->charset);
     $item->setDescription($description, $this->charset);
     $item->setNumber($number, $this->charset);
     $item->setTax($itemTax, $this->charset);
     $item->setAmount($itemAmount, $this->charset);
     $this->items[] = $item;
     $this->itemTotal += $amount * $quantity + $tax;
 }