$CARequest->preferredLanguageCode = "en_US"; $rEnvelope = new RequestEnvelope(); $rEnvelope->errorLanguage = "en_US"; $CARequest->requestEnvelope = $rEnvelope; $CARequest->createAccountWebOptions = new CreateAccountWebOptionsType(); $serverName = $_SERVER['SERVER_NAME']; $serverPort = $_SERVER['SERVER_PORT']; $url = dirname('http://' . $serverName . ':' . $serverPort . $_SERVER['REQUEST_URI']); $returnURL = $url . "/CreateAccountDetails.php"; $CARequest->createAccountWebOptions->returnUrl = $returnURL; $CARequest->registrationType = "WEB"; //$CARequest->sandboxEmailAddress = $sandboxEmail; $CARequest->emailAddress = $email; $aa = new AdaptiveAccounts(); $aa->sandBoxEmailAddress = $sandboxEmail; $response = $aa->CreateAccount($CARequest); if (strtoupper($aa->isSuccess) == 'FAILURE') { $_SESSION['FAULTMSG'] = $aa->getLastError(); $location = "APIError.php"; header("Location: {$location}"); } else { $location = $response->redirectURL; if (!empty($location)) { $_SESSION['createdAccount'] = $response; header("Location: {$location}"); } } } catch (Exception $ex) { $fault = new FaultMessage(); $errorData = new ErrorData(); $errorData->errorId = $ex->getFile();
function CreateAccountBusiness() { $bizName = 'Bonzop'; $bizAddressline1 = '1968 Ape Way'; $bizAddressline2 = 'Apt 123'; $bizcity = 'Austin'; $bizZIP = '78750'; $bizCountryCode = 'US'; $biz_address_state = 'TX'; $bizWorkPhone = '512-691-4160'; $bizCategoryCode = '1001'; $bizSubCategory = '2002'; $bizCustomerServicePhone = '512-691-4160'; $datetime = gettimeofday(); $bizCustomerServiceEmail = 'testaccount1' . $datetime['usec'] . '@paypal.com'; $bizWebSite = 'https://www.x.com'; $bizDateOfEstablishment = '1968-01-01'; $businessType = 'INDIVIDUAL'; $averagePrice = '100'; $averageMonthlyVolume = '100'; $percentageRevenueFromOnline = '100'; $salesVenue = 'WEB'; /* Make the call to PayPal to create Account on behalf of the caller If an error occured, show the resulting errors */ $CARequest = new CreateAccountRequest(); $CARequest->accountType = 'BUSINESS'; $address = new AddressType(); $address->city = 'Austin'; $address->countryCode = 'US'; $address->line1 = '1968 Ape Way'; $address->line2 = 'Apt 123'; $address->postalCode = '78750'; $address->state = 'TX'; $CARequest->address = $address; $CARequest->citizenshipCountryCode = 'US'; $CARequest->clientDetails = new ClientDetailsType(); $CARequest->clientDetails->applicationId = "APP-80W284485P519543T"; $CARequest->clientDetails->ipAddress = "127.0.0.1"; $CARequest->contactPhoneNumber = '512-691-4160'; $CARequest->currencyCode = 'USD'; $CARequest->dateOfBirth = '1968-01-01'; $name = new NameType(); $name->firstName = 'Bonzop'; $name->middleName = 'Simore'; $name->lastName = 'Zaius'; $name->salutation = 'Dr.'; $CARequest->name = $name; $CARequest->notificationURL = 'http://stranger.paypal.com/cgi-bin/ipntest.cgi'; $CARequest->partnerField1 = 'p1'; $CARequest->partnerField2 = 'p2'; $CARequest->partnerField3 = 'p3'; $CARequest->partnerField4 = 'p4'; $CARequest->partnerField5 = 'p5'; $CARequest->preferredLanguageCode = "en_US"; //only required for business account $bizInfo = new BusinessInfoType(); $bizInfo->businessName = $bizName; $bizAddress = new AddressType(); $bizAddress->city = $bizcity; $bizAddress->countryCode = $bizCountryCode; $bizAddress->line1 = $bizAddressline1; $bizAddress->line2 = $bizAddressline2; $bizAddress->postalCode = $bizZIP; $bizAddress->state = $biz_address_state; $bizInfo->businessAddress = $bizAddress; $bizInfo->workPhone = $bizWorkPhone; $bizInfo->category = $bizCategoryCode; $bizInfo->subCategory = $bizSubCategory; $bizInfo->customerServicePhone = $bizCustomerServicePhone; $bizInfo->customerServiceEmail = $bizCustomerServiceEmail; $bizInfo->webSite = $bizWebSite; $bizInfo->dateOfEstablishment = $bizDateOfEstablishment; $bizInfo->businessType = $businessType; $bizInfo->averagePrice = $averagePrice; $bizInfo->averageMonthlyVolume = $averageMonthlyVolume; $bizInfo->percentageRevenueFromOnline = $percentageRevenueFromOnline; $bizInfo->salesVenue = $salesVenue; $CARequest->businessInfo = $bizInfo; $rEnvelope = new RequestEnvelope(); $rEnvelope->errorLanguage = "en_US"; $CARequest->requestEnvelope = $rEnvelope; $CARequest->createAccountWebOptions = new CreateAccountWebOptionsType(); $CARequest->registrationType = "WEB"; $CARequest->sandboxEmailAddress = '*****@*****.**'; $datetime = gettimeofday(); $CARequest->emailAddress = 'testaccount' . $datetime['usec'] . '@paypal.com'; $aa = new AdaptiveAccounts(); $aa->sandBoxEmailAddress = '*****@*****.**'; $response = $aa->CreateAccount($CARequest); if (strtoupper($aa->isSuccess) == 'FAILURE') { $FaultMsg = $aa->getLastError(); echo "Transaction CreateAccount Business Failed: error Id: "; if (is_array($FaultMsg->error)) { echo $FaultMsg->error[0]->errorId . ", error message: " . $FaultMsg->error[0]->message; } else { echo $FaultMsg->error->errorId . ", error message: " . $FaultMsg->error->message; } } else { echo "CreateAccount Business API call Successful! \n"; $tempReturn2['createAccountKey'] = $response->createAccountKey; $tempReturn2['emailAddress'] = $CARequest->emailAddress; return $tempReturn2; } }