if ($_REQUEST['accountType'] == "Business") { $createAccountRequest->businessInfo = $businessInfo; } /* * ## Creating service wrapper object Creating service wrapper object to make API call Configuration::getAcctAndConfig() returns array that contains credential and config parameters */ $service = new AdaptiveAccountsService(Configuration::getAcctAndConfig()); try { /* * ## Making API call invoke the appropriate method corresponding to API in service wrapper object */ $response = $service->CreateAccount($createAccountRequest); } catch (Exception $ex) { require_once 'Common/Error.php'; exit; } $ack = strtoupper($response->responseEnvelope->ack); if ($ack != "SUCCESS") { echo "<b>Error </b>"; echo "<pre>"; print_r($response); echo "</pre>"; } else { echo "<pre>"; print_r($response); echo "</pre>"; $createAccountKey = strtoupper($response->createAccountKey);
private function makeAPICall($createAccountRequest) { $logger = new PPLoggingManager('CreateAccount'); // ## Creating service wrapper object // Creating service wrapper object to make API call and loading // configuration file for your credentials and endpoint $service = new AdaptiveAccountsService(); try { // ## Making API call // invoke the appropriate method corresponding to API in service // wrapper object $response = $service->CreateAccount($createAccountRequest); } catch (Exception $ex) { $logger->error("Error Message : " . $ex->getMessage()); } // ## Accessing response parameters // You can access the response parameters using getter methods in // response object as shown below // ### Success values if ($response->responseEnvelope->ack == "Success") { $logger->log("Create account Key : " . $response->createAccountKey); // ### Redirection to PayPal // Once you get the success response, user needs to redirect to // PayPal to enter password for the created account. For that, // you have to use the redirect URL from the response, like // createAccountResponse.getRedirectURL(); // Using this url, // redirects the user to PayPal. } else { $logger->error("API Error Message : " . $response->error[0]->message); } return $response; }