setEmail() public méthode

Email address representing the payer. 127 characters max.
public setEmail ( string $email )
$email string
 public static function createPayerInfo()
 {
     $payerInfo = new PayerInfo();
     $payerInfo->setEmail(self::$email);
     $payerInfo->setFirstName(self::$firstName);
     $payerInfo->setLastName(self::$lastName);
     $payerInfo->setPhone(self::$phone);
     $payerInfo->setPayerId(self::$payerId);
     $payerInfo->setShippingAddress(AddressTest::createAddress());
     return $payerInfo;
 }
 /**
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     $this->_autoload();
     $order = $this->_getOrder($data['order_number']);
     //initialise application
     $app = JFactory::getApplication();
     //get card input
     $data['cardtype'] = $app->input->getString("cardtype");
     $data['cardnum'] = $app->input->getString("cardnum");
     $month = $app->input->getString("month");
     $year = $app->input->getString("year");
     $card_exp = $month . '' . $year;
     $data['cardexp'] = $card_exp;
     $data['cardcvv'] = $app->input->getString("cardcvv");
     $data['cardnum_last4'] = substr($app->input->getString("cardnum"), -4);
     //initialise payment
     $apiContext = new ApiContext(new OAuthTokenCredential($this->api_clientId, $this->api_clientSecret));
     $apiContext->setConfig(array('mode' => $this->api_mode));
     //		echo'<pre>';print_r($apiContext);die;
     $card = new CreditCard();
     $card->setType($data['cardtype']);
     $card->setNumber($data['cardnum']);
     $card->setExpireMonth($month);
     $card->setExpireYear($year);
     $card->setFirstName($data['firstname']);
     $card->setLastName($data['lastname']);
     $card->setCvv2($data['cardcvv']);
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
     if (!empty($data['email'])) {
         $payerInfo = new PayerInfo();
         $payerInfo->setFirstName($data['firstname']);
         $payerInfo->setLastName($data['lastname']);
         $payerInfo->setEmail($data['email']);
         $payer->setPayerInfo($payerInfo);
     }
     $amount = new Amount();
     $amount->setCurrency($this->currency);
     $amount->setTotal($data['total']);
     $item1 = new Item();
     $item1->setName($data['order_number'])->setDescription($data['order_number'])->setCurrency($this->currency)->setQuantity(1)->setTax(0)->setPrice($data['total']);
     $itemList = new ItemList();
     $itemList->setItems(array($item1));
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setItemList($itemList);
     $transaction->setDescription($data['order_number']);
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $request = clone $payment;
     try {
         $payment->create($apiContext);
     } catch (PayPal\Exception\PayPalConnectionException $ex) {
         $error = json_decode($ex->getData());
         $error_html = '<h2>' . $error->name . '</h2><br>';
         foreach ($error->details as $r) {
             $error_html .= '- ' . $r->field . ' - ' . $r->issue . '<br>';
         }
         $app->enqueueMessage($error_html, 'error');
         $app->redirect('index.php?option=com_bookpro&view=formpayment&order_id=' . $order->id . '&' . JSession::getFormToken() . '=1');
         return;
     } catch (Exception $ex) {
         die($ex);
     }
     $ack = $payment->getState();
     if ($ack == 'approved' || $ack == 'completed') {
         $order->pay_status = "SUCCESS";
         $order->order_status = "CONFIRMED";
         $order->tx_id = $payment->getId();
         $order->store();
     } else {
         JLog::addLogger(array('text_file' => 'paypal.txt', 'text_file_path' => 'logs', 'text_file_no_php' => 1, 'text_entry_format' => '{DATE} {TIME} {MESSAGE}'), JLog::ALERT);
         JLog::add('Transaction: ' . json_encode($payment) . '\\nOrder: ' . $order->order_number . ' Status: ' . $ack, JLog::ALERT, 'com_bookpro');
         $order->pay_status = "PENDING";
         $order->tx_id = $transaction_id;
         $order->store();
     }
     $app = JFactory::getApplication();
     $app->redirect('index.php?option=com_bookpro&controller=payment&task=postpayment&method=' . $this->_element . '&order_number=' . $order->order_number);
     return;
 }
Exemple #3
0
 public function createBillingAgreement($planId, $shippingAddress, $billingAddress, $productName, $cartSummary, $cardDetails, $apiContext)
 {
     $billingPlanDefaultValues = $this->getBillingPlanDefaultValues();
     $billingAgreement = new Agreement();
     $billingAgreement->setName('Billing Agreement For ' . $productName);
     $billingAgreement->setDescription($cartSummary->paymentPlanTitle);
     $startDate = new Zend_Date();
     $startDate->addDay($billingPlanDefaultValues->startDateInterval);
     $billingAgreement->setStartDate($startDate->get(Zend_Date::ISO_8601));
     $payerInfo = new PayerInfo();
     $payerInfo->setFirstName($billingAddress->firstname);
     $payerInfo->setLastName($billingAddress->lastname);
     $payerInfo->setEmail($billingAddress->emailAddress);
     /* Fields not supported yet */
     //$payerInfo->setEmail($cart->address->billing['billing_email']);
     //$payerInfo->setPhone($cart->address->billing['billing_contactNo']);
     /* Get a MALFORMED_REQUEST error when using this field */
     //$payerInfo->setCountryCode($cart->address->billing['billing_countryCode']);
     $cardName = $cardDetails->cardName;
     $cardNumber = $cardDetails->cardNumber;
     $cardType = strtolower($cardDetails->cardType);
     $cardExpiryMonth = $cardDetails->cardExpiryMonth;
     $cardExpiryYear = $cardDetails->cardExpiryYear;
     $cardSecurityCode = $cardDetails->cardSecurityCode;
     $nameParser = new Om_Model_Name();
     $name = $nameParser->parse_name($cardName);
     $card = new CreditCard();
     $card->setType($cardType);
     $card->setNumber($cardNumber);
     $card->setExpireMonth($cardExpiryMonth);
     $card->setExpireYear($cardExpiryYear);
     $card->setCvv2($cardSecurityCode);
     $card->setFirstName($name['fname']);
     $card->setLastName($name['lname']);
     $fundingInstrument = new FundingInstrument();
     $fundingInstrument->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array($fundingInstrument));
     $payer->setPayerInfo($payerInfo);
     $billingAgreement->setPayer($payer);
     $shippingAddressPayPal = new Address();
     $shippingAddressPayPal->setLine1($shippingAddress->addressLine1);
     $shippingAddressPayPal->setLine2($shippingAddress->addressLine2 . ' ' . $shippingAddress->addressLine3);
     $shippingAddressPayPal->setCity($shippingAddress->city);
     $shippingAddressPayPal->setCountryCode($shippingAddress->getCountry()->code);
     $shippingAddressPayPal->setPostalCode($shippingAddress->postcode);
     $shippingAddressPayPal->setState($shippingAddress->county);
     $shippingAddressPayPal->setPhone($shippingAddress->contactNumber);
     $billingAgreement->setShippingAddress($shippingAddressPayPal);
     $plan = new Plan();
     $plan->setId($planId);
     $billingAgreement->setPlan($plan);
     return $billingAgreement->create($apiContext);
 }