PayPal\Service\PayPalAPIInterfaceServiceService::GetRecurringPaymentsProfileDetails PHP Method

GetRecurringPaymentsProfileDetails() public method

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

Usage Example

Example #1
0
 /**
  * Clear a payment profile
  *
  * @param array $subscription         
  * @param array $paymentProfile         
  * @throws Exception
  */
 public function cancelPaymentProfile(array $subscription, array $paymentProfile)
 {
     $subService = SubscriptionsService::instance();
     $orderService = OrdersService::instance();
     // PPService
     $paypalService = new PayPalAPIInterfaceServiceService();
     $getRPPDetailsReqest = new GetRecurringPaymentsProfileDetailsRequestType();
     $getRPPDetailsReqest->ProfileID = $paymentProfile['paymentProfileId'];
     $getRPPDetailsReq = new GetRecurringPaymentsProfileDetailsReq();
     $getRPPDetailsReq->GetRecurringPaymentsProfileDetailsRequest = $getRPPDetailsReqest;
     $getRPPDetailsResponse = $paypalService->GetRecurringPaymentsProfileDetails($getRPPDetailsReq);
     if (empty($getRPPDetailsResponse) || $getRPPDetailsResponse->Ack != 'Success') {
         throw new Exception('Error retrieving payment profile status');
     }
     $profileStatus = $getRPPDetailsResponse->GetRecurringPaymentsProfileDetailsResponseDetails->ProfileStatus;
     // Active profile, send off the cancel
     if (strcasecmp($profileStatus, PaymentProfileStatus::ACTIVEPROFILE) === 0 || strcasecmp($profileStatus, PaymentProfileStatus::CANCELLEDPROFILE) === 0) {
         if (strcasecmp($profileStatus, PaymentProfileStatus::ACTIVEPROFILE) === 0) {
             // Do we have a payment profile, we need to cancel it with paypal
             $manageRPPStatusReqestDetails = new ManageRecurringPaymentsProfileStatusRequestDetailsType();
             $manageRPPStatusReqestDetails->Action = 'Cancel';
             $manageRPPStatusReqestDetails->ProfileID = $paymentProfile['paymentProfileId'];
             $manageRPPStatusReqest = new ManageRecurringPaymentsProfileStatusRequestType();
             $manageRPPStatusReqest->ManageRecurringPaymentsProfileStatusRequestDetails = $manageRPPStatusReqestDetails;
             $manageRPPStatusReq = new ManageRecurringPaymentsProfileStatusReq();
             $manageRPPStatusReq->ManageRecurringPaymentsProfileStatusRequest = $manageRPPStatusReqest;
             $manageRPPStatusResponse = $paypalService->ManageRecurringPaymentsProfileStatus($manageRPPStatusReq);
             if (!isset($manageRPPStatusResponse) || $manageRPPStatusResponse->Ack != 'Success') {
                 throw new Exception($manageRPPStatusResponse->Errors[0]->LongMessage);
             }
         }
         $orderService->updatePaymentProfileState($paymentProfile['profileId'], PaymentProfileStatus::CANCELLEDPROFILE);
     }
 }
All Usage Examples Of PayPal\Service\PayPalAPIInterfaceServiceService::GetRecurringPaymentsProfileDetails