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(); } }
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(); } }