if (isset($_POST['receiveremail'][$i]) && $_POST['receiveremail'][$i] != '') {
        $massPayItems[$j] =& PayPal::getType('MassPayRequestItemType');
        $massPayItems[$j]->setReceiverEmail($_POST["receiveremail"][$i]);
        $massPayItems[$j]->setNote($_POST["note"][$i]);
        $massPayItems[$j]->setUniqueId($_POST["uniqueID"][$i]);
        $amtType =& PayPal::getType('BasicAmountType');
        $amtType->setattr('currencyID', 'USD');
        $amtType->setval($_POST["amount"][$i], 'iso-8859-1');
        $massPayItems[$j]->setAmount($amtType);
        $j++;
    }
}
$masspay_request->setEmailSubject($emailSubject);
$masspay_request->setReceiverType($receiverType);
//creating multiple occurences of MassPayRequestItem
$multiItems = new MultiOccurs($masspay_request, 'MassPayRequestItem');
$multiItems->setChildren($massPayItems);
$masspay_request->setMassPayItem($multiItems);
$logger->_log('Initial request: ' . print_r($masspay_request, true));
$caller =& PayPal::getCallerServices($profile);
$response = $caller->MassPay($masspay_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;
        $logger->_log('Domasspay failed: ' . print_r($response, true));
Exemple #2
0
 private function buildDirectPaymentRequest($authorization = true)
 {
     $dp_request =& PayPal::getType('DoDirectPaymentRequestType');
     $dp_request->setVersion('51.0', $this->charset);
     $paymentType = $authorization ? 'Authorization' : 'Sale';
     $OrderTotal =& PayPal::getType('BasicAmountType');
     $OrderTotal->setattr('currencyID', $this->currencyID);
     $OrderTotal->setval($this->amount, $this->charset);
     $ShippingTotal =& PayPal::getType('BasicAmountType');
     $ShippingTotal->setattr('currencyID', $this->currencyID);
     $ShippingTotal->setval($this->shippingTotal, $this->charset);
     $shipTo =& PayPal::getType('AddressType');
     $shipTo->setName($this->Firstname + ' ' + $this->Lastname);
     $shipTo->setName($this->Firstname + ' ' + $this->Lastname);
     $shipTo->setStreet1($this->ShippingAddress['Street1']);
     $shipTo->setStreet2($this->ShippingAddress['Street2']);
     $shipTo->setCityName($this->ShippingAddress['CityName']);
     $shipTo->setStateOrProvince($this->ShippingAddress['StateOrProvince']);
     $shipTo->setCountry($this->ShippingAddress['Country']);
     $shipTo->setPostalCode($this->ShippingAddress['PostalCode']);
     $payerAddress =& PayPal::getType('AddressType');
     $payerAddress->setName($this->Firstname + ' ' + $this->Lastname);
     $payerAddress->setStreet1($this->PayerAddress['Street1']);
     $payerAddress->setStreet2($this->PayerAddress['Street2']);
     $payerAddress->setCityName($this->PayerAddress['CityName']);
     $payerAddress->setStateOrProvince($this->PayerAddress['StateOrProvince']);
     $payerAddress->setCountry($this->PayerAddress['Country']);
     $payerAddress->setPostalCode($this->PayerAddress['PostalCode']);
     $PaymentDetails =& PayPal::getType('PaymentDetailsType');
     $PaymentDetails->setOrderTotal($OrderTotal);
     $PaymentDetails->setShippingTotal($ShippingTotal);
     $PaymentDetails->setShipToAddress($shipTo);
     if (count($this->items) > 0) {
         $m = new MultiOccurs($PaymentDetails, 'PaymentDetailsItem');
         $m->setChildren($this->items);
         $PaymentDetails->setPaymentDetailsItem($m);
         $ItemTotal =& PayPal::getType('BasicAmountType');
         $ItemTotal->setattr('currencyID', $this->currencyID);
         $ItemTotal->setval($this->formatAmount($this->itemTotal), $this->charset);
         $PaymentDetails->setItemTotal($ItemTotal, $this->charset);
     }
     $PaymentDetails->setOrderDescription($this->description, $this->charset);
     $person_name =& PayPal::getType('PersonNameType');
     $person_name->setFirstName($this->ShippingAddress['Firstname']);
     $person_name->setLastName($this->ShippingAddress['Lastname']);
     $payer =& PayPal::getType('PayerInfoType');
     $payer->setPayerName($person_name);
     $payer->setPayerCountry($this->PayerAddress['Country']);
     $payer->setAddress($payerAddress);
     $card_details =& PayPal::getType('CreditCardDetailsType');
     $card_details->setCardOwner($payer);
     $card_details->setCreditCardType($this->CreditCardType);
     $card_details->setCreditCardNumber($this->CreditCardNumber);
     $card_details->setExpMonth($this->ExpMonth);
     $card_details->setExpYear($this->ExpYear);
     $card_details->setCVV2($this->CVV2);
     $dp_details =& PayPal::getType('DoDirectPaymentRequestDetailsType');
     $dp_details->setPaymentDetails($PaymentDetails);
     $dp_details->setCreditCard($card_details);
     $dp_details->setIPAddress(Network::visitorIpAddress());
     $dp_details->setPaymentAction($paymentType);
     $dp_request->setDoDirectPaymentRequestDetails($dp_details);
     $this->request = $dp_request;
 }