PayPal\Service\PayPalAPIInterfaceServiceService::GetExpressCheckoutDetails PHP Method

GetExpressCheckoutDetails() public method

Service Call: GetExpressCheckoutDetails
public GetExpressCheckoutDetails ( GetExpressCheckoutDetailsReq $getExpressCheckoutDetailsReq, mixed $apiCredential = null ) : GetExpressCheckoutDetailsResponseType
$getExpressCheckoutDetailsReq PayPal\PayPalAPI\GetExpressCheckoutDetailsReq
$apiCredential mixed - Optional API credential - can either be a username configured in sdk_config.ini or a ICredential object created dynamically
return PayPal\PayPalAPI\GetExpressCheckoutDetailsResponseType
    public function GetExpressCheckoutDetails($getExpressCheckoutDetailsReq, $apiCredential = null)
    {
        $apiContext = new PPApiContext($this->config);
        $handlers = array(new PPMerchantServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION));
        $this->setStandardParams($getExpressCheckoutDetailsReq->GetExpressCheckoutDetailsRequest);
        $ret = new GetExpressCheckoutDetailsResponseType();
        $resp = $this->call('PayPalAPIAA', 'GetExpressCheckoutDetails', $getExpressCheckoutDetailsReq, $apiContext, $handlers);
        $ret->init(PPUtils::xmlToArray($resp));
        return $ret;
    }

Usage Example

Beispiel #1
0
 public function getExpressCheckoutDetails($token)
 {
     $paypalTransaction = PaypalTransactionQuery::create()->findOneByToken($token);
     if (!$paypalTransaction) {
         \App::abort('Fatal Error');
     }
     $payment = $paypalTransaction->getPayment();
     $getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
     $getExpressCheckoutRequest = new GetExpressCheckoutDetailsReq();
     $getExpressCheckoutRequest->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     try {
         $getExpressCheckoutResponse = $this->payPalApi->GetExpressCheckoutDetails($getExpressCheckoutRequest);
     } catch (PPConnectionException $e) {
         $paymentError = new PaymentError('Error Connecting to PayPal.', $e);
         return $this->paymentBus->getFailedHandler($payment, $paymentError)->redirect();
     }
     if ($getExpressCheckoutResponse->Ack != 'Success') {
         $paymentError = new PaymentError('Error Connecting to PayPal.');
         return $this->paymentBus->getFailedHandler($payment, $paymentError)->redirect();
     }
     try {
         $payPalFinalResponse = $this->doExpressCheckout($getExpressCheckoutResponse->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID, $getExpressCheckoutResponse->GetExpressCheckoutDetailsResponseDetails->Token, $getExpressCheckoutResponse->GetExpressCheckoutDetailsResponseDetails->PaymentDetails[0]->OrderTotal);
     } catch (PPConnectionException $e) {
         $paymentError = new PaymentError('Error Connecting to PayPal.', $e);
         return $this->paymentBus->getFailedHandler($payment, $paymentError)->redirect();
     }
     if ($payPalFinalResponse->Ack != "Success") {
         $this->logPayPalErrors($payment, $payPalFinalResponse);
         $paymentError = new PaymentError('PayPal transaction failed.');
         return $this->paymentBus->getFailedHandler($payment, $paymentError)->redirect();
     }
     $paymentStatus = $payPalFinalResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo[0]->PaymentStatus;
     if ($paymentStatus != "Completed") {
         $paymentError = new PaymentError('PayPal transaction pending');
         return $this->paymentBus->getPendingHandler($payment, $paymentError)->redirect();
     }
     $paypalTransaction->setStatus($paymentStatus);
     $paypalTransaction->save();
     return $this->paymentBus->getCompletedHandler($payment)->redirect();
 }
All Usage Examples Of PayPal\Service\PayPalAPIInterfaceServiceService::GetExpressCheckoutDetails