/** * * Coutries Supported: * AU - Australia * CA - Canada * CY - Cyprus * CZ - Czech Republic * DK - Denmark * EE - Estonia * FI - Finland * FR - France * DE - Germany * GR - Greece * HU - Hungary * IT - Italy * LV - Latvia * LT - Lithuania * LU - Luxembourg * MT - Malta * NL - Netherlands * PL - Poland * PT - Portugal * SK - Slovak Republic * SI - Slovenia * ES - Spain * SE - Sweden * UK - United Kingdom * US - United States */ public CreateAccountResponse CreateAccount(CreateAccountRequest CreateAccountRequest, string apiUsername) { string resp = call("CreateAccount", CreateAccountRequest.toNVPString(""), apiUsername); NVPUtil util = new NVPUtil(); return new CreateAccountResponse(util.parseNVPString(resp), ""); }
public CreateAccountResponse CreateAccount(CreateAccountRequest CreateAccountRequest) { return CreateAccount(CreateAccountRequest, null); }
// # CreateAccount API operations // The CreateAccount API operations enable you to create a PayPal account on behalf of a third party and download the SDK [here](https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index) public CreateAccountResponse CreateAccountAPIOperations(CreateAccountRequest createAccountRequest) { // Create the CreateAccountResponse object CreateAccountResponse responseCreateAccount = new CreateAccountResponse(); try { // Create the AdaptiveAccounts service object to make the API call AdaptiveAccountsService service = new AdaptiveAccountsService(); // # API call // Invoke the CreateAccount method in service wrapper object responseCreateAccount = service.CreateAccount(createAccountRequest); if (responseCreateAccount != null) { // Response envelope acknowledgement string acknowledgement = "CreateAccount API operation - " + createAccountRequest.accountType; acknowledgement += " - " + responseCreateAccount.responseEnvelope.ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseCreateAccount.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { logger.Info("Create Account Key : " + responseCreateAccount.createAccountKey + "\n"); Console.WriteLine("Create Account Key : " + responseCreateAccount.createAccountKey + "\n"); // Redirection to PayPal // The user is redirected to PayPal to enter password for the created account // Set the redirection URL in responseCreateAccount.redirectURL // Using this URL the user is redirected to PayPal } // # Error Values else { List<ErrorData> errorMessages = responseCreateAccount.error; foreach (ErrorData error in errorMessages) { logger.Debug("API Error Message : " + error.message); Console.WriteLine("API Error Message : " + error.message + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return responseCreateAccount; }
// # Create Account public CreateAccountRequest CreateAccount() { // Request envelope object RequestEnvelope envelopeRequest = new RequestEnvelope(); // The name of the person for whom the PayPal account is created: // // * FirstName // * LastName NameType name = new NameType("John", "David"); // The address to be associated with the PayPal account: // // * Street1 // * countrycode // * city // * state // * postalcode AddressType address = new AddressType("Ape Way", "US"); address.city = "Austin"; address.state = "TX"; address.postalCode ="78750"; // The CreateAccountRequest contains the information required // to create a PayPal account for a business customer // Instantiating createAccountRequest with mandatory arguments: // // * requesteEvelope // * name // * address // * preferredlanguagecode CreateAccountRequest createAccountRequest = new CreateAccountRequest(envelopeRequest, name, address, "en_US"); // The type of account to be created // Allowable values: // // * Personal // * Premier // * Business createAccountRequest.accountType = "Personal"; // The code of the country to be associated with the account createAccountRequest.citizenshipCountryCode = "US"; // Phone Number to be associated with the account createAccountRequest.contactPhoneNumber ="5126914160"; // The three letter code for the currency to be associated with the account createAccountRequest.currencyCode ="USD"; // Email address of person for whom the PayPal account is created createAccountRequest.emailAddress = "*****@*****.**"; // This attribute determines whether a key or a URL is returned for the redirect URL createAccountRequest.registrationType = "Web"; // IPN URL // // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed // * The transaction related IPN variables will be received on the call back URL specified in the request // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID" // * PayPal would continuously resend IPN if a wrong IPN is sent createAccountRequest.notificationURL = "http://IPNhost"; return createAccountRequest; }
private void CreateAccount(HttpContext context) { // #CreateAccount API // The CreateAccount API operation enables you to create a PayPal account on behalf of a third party. NameValueCollection parameters = context.Request.Params; // The name of the person for whom the PayPal account is // created, which // contains // // * `FirstName` - First name of the account or payment card // holder. // * `LastName` - Last name of the account or payment card // holder. NameType name = new NameType(parameters["firstName"], parameters["lastName"]); //(Optional) A salutation for the account or payment card holder. if (parameters["salutation"] != string.Empty) name.salutation = parameters["salutation"]; //Optional) Middle name of the account or payment card holder. if (parameters["middleName"] != string.Empty) name.middleName = parameters["middleName"]; //(Optional) A suffix for the account or payment card holder. if (parameters["suffix"] != string.Empty) name.suffix = parameters["suffix"]; // Address of the person for whom the PayPal account is created AddressType address = new AddressType(parameters["line1"], parameters["countryCode"]); //(Optional) Second line of the address. // Note: This field is required for Brazilian addresses. if (parameters["line2"] != string.Empty) address.line2 = parameters["line2"]; //(Required) City name if (parameters["city"] != string.Empty) address.city = parameters["city"]; //(Optional) State code. if (parameters["state"] != string.Empty) address.state = parameters["state"]; //(Optional) Zip or postal code. if (parameters["postalCode"] != string.Empty) address.postalCode = parameters["postalCode"]; // Instantiating createAccountRequest with mandatory arguments: // // * `requestenvelope` - Information common to each API // operation, such // as the language in which an error message is returned. // * `name` - The name of the person for whom the PayPal account // is // created. // * `address` - The address to be associated with the PayPal // account. // * `preferredlanguagecode`- The code indicating the language // to be // associated with the account. // What value is allowed depends on the country code passed in // the // countryCode parameter for the address. // For Example: United States (US) - en_US CreateAccountRequest req = new CreateAccountRequest(new RequestEnvelope(), name, address, parameters["preferredLanguageCode"]); // The type of account to create. Allowed values: // // *Personal – Personal account // *Premier – Premier account // *Business – Business account if (parameters["accountType"] != string.Empty) req.accountType = parameters["accountType"]; // Phone Number to be associated with the account. if(parameters["contactPhoneNumber"] != string.Empty) req.contactPhoneNumber = parameters["contactPhoneNumber"]; if (parameters["homePhoneNumber"] != string.Empty) req.homePhoneNumber = parameters["homePhoneNumber"]; if (parameters["mobilePhoneNumber"] != string.Empty) req.mobilePhoneNumber = parameters["mobilePhoneNumber"]; // Email address of person for whom the PayPal account is // created. if (parameters["emailAddress"] != string.Empty) req.emailAddress = parameters["emailAddress"]; // The three letter code for the currency to be associated with // the account if (parameters["currencyCode"] != string.Empty) req.currencyCode = parameters["currencyCode"]; // The code of the country to be associated with the account. req.citizenshipCountryCode = parameters["citizenshipCountryCode"]; // This attribute determines whether a key or a URL is returned // for the redirect URL. Allowable value(s) currently // supported:`Web` - Returns a URL req.registrationType = parameters["registrationType"]; // The URL to post instant payment notification (IPN) messages // to // regarding account creation. This URL supersedes the IPN // notification // URL set in the merchant profile. if (parameters["notificationUrl"] != string.Empty) { req.notificationURL = parameters["notificationUrl"]; } if (parameters["returnUrl"] != string.Empty || parameters["returnUrlDescription"] != string.Empty || parameters["showAddCreditCard"] != string.Empty || parameters["showMobileConfirm"] != string.Empty || parameters["useMiniBrowser"] != string.Empty) { // Used for configuration settings for the web flow CreateAccountWebOptionsType webOptions = new CreateAccountWebOptionsType(); req.createAccountWebOptions = webOptions; // (Required) The URL to which you want the account holder to return when he or she finishes account registration. // This URL appears as a link on the final page of the PayPal account registration flow. // The text of this link is the text passed in the returnUrlDescription request parameter (below). if (parameters["returnUrl"] != string.Empty) webOptions.returnUrl = parameters["returnUrl"]; //(Optional) A description of the return URL. if (parameters["returnUrlDescription"] != string.Empty) webOptions.returnUrlDescription = parameters["returnUrlDescription"]; // (Optional) Defines whether the "add credit card" option is included in the PayPal account registration flow. // true - Show the option (default) // false - Do not show the option if (parameters["showAddCreditCard"] != string.Empty) webOptions.showAddCreditCard = Convert.ToBoolean( parameters["showAddCreditCard"]); // (Optional) Defines whether the "mobile confirmation" option is included in the PayPal account registration flow. // true - Show the option // false - Do not show the option (default) if (parameters["showMobileConfirm"] != string.Empty) webOptions.showMobileConfirm = Convert.ToBoolean(parameters["showMobileConfirm"]); // (Optional) Defines whether to use the minibrowser account registration flow or the traditional account registration flow. // true - Use the minibrowser flow // false - Use the traditional flow (default) if (parameters["useMiniBrowser"] != string.Empty) webOptions.useMiniBrowser = Convert.ToBoolean(parameters["useMiniBrowser"]); } // Create the AdaptiveAccounts service object to make the API call AdaptiveAccountsService service = null; CreateAccountResponse resp = null; try { // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Creating service wrapper object to make an API call and loading // configuration map for your credentials and endpoint service = new AdaptiveAccountsService(configurationMap); // # API call // Invoke the CreateAccount method in service wrapper object resp = service.CreateAccount(req); } catch (System.Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { redirectUrl = resp.redirectURL; keyResponseParams.Add("Account Id", resp.accountId); keyResponseParams.Add("Create account key", resp.createAccountKey); keyResponseParams.Add("Execution status", resp.execStatus.ToString()); //Selenium Test Case keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString()); keyResponseParams.Add("Redirect To PayPal", resp.redirectURL); } displayResponse(context, "CreateAccount", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
private void CreateAccount(HttpContext context) { NameValueCollection parameters = context.Request.Params; NameType nameOnCard = new NameType(parameters["firstName"], parameters["lastName"]); if (parameters["salutation"] != "") nameOnCard.salutation = parameters["salutation"]; if (parameters["middleName"] != "") nameOnCard.middleName = parameters["middleName"]; if (parameters["suffix"] != "") nameOnCard.suffix = parameters["suffix"]; AddressType address = new AddressType(parameters["line1"], parameters["countryCode"]); if (parameters["line2"] != "") address.line2 = parameters["line2"]; if (parameters["city"] != "") address.city = parameters["city"]; if (parameters["state"] != "") address.state = parameters["state"]; if (parameters["postalCode"] != "") address.postalCode = parameters["postalCode"]; CreateAccountRequest req = new CreateAccountRequest(new RequestEnvelope(), nameOnCard, address, parameters["preferredLanguageCode"]); // set optional parameters if(parameters["contactPhoneNumber"] != "") req.contactPhoneNumber = parameters["contactPhoneNumber"]; if (parameters["homePhoneNumber"] != "") req.homePhoneNumber = parameters["homePhoneNumber"]; if (parameters["mobilePhoneNumber"] != "") req.mobilePhoneNumber = parameters["mobilePhoneNumber"]; if (parameters["emailAddress"] != "") req.emailAddress = parameters["emailAddress"]; if (parameters["currencyCode"] != "") req.currencyCode = parameters["currencyCode"]; req.citizenshipCountryCode = parameters["citizenshipCountryCode"]; req.registrationType = parameters["registrationType"]; if (parameters["returnUrl"] != "" || parameters["returnUrlDescription"] != "" || parameters["showAddCreditCard"] != "" || parameters["showMobileConfirm"] != "" || parameters["useMiniBrowser"] != "") { CreateAccountWebOptionsType webOptions = new CreateAccountWebOptionsType(); req.createAccountWebOptions = webOptions; if (parameters["returnUrl"] != "") webOptions.returnUrl = parameters["returnUrl"]; if (parameters["returnUrlDescription"] != "") webOptions.returnUrlDescription = parameters["returnUrlDescription"]; if (parameters["showAddCreditCard"] != "") webOptions.showAddCreditCard = Boolean.Parse(parameters["showAddCreditCard"]); if (parameters["showMobileConfirm"] != "") webOptions.showMobileConfirm = Boolean.Parse(parameters["showMobileConfirm"]); if (parameters["useMiniBrowser"] != "") webOptions.useMiniBrowser = Boolean.Parse(parameters["useMiniBrowser"]); } // All set. Fire the request AdaptiveAccountsService service = new AdaptiveAccountsService(); CreateAccountResponse resp = null; try { resp = service.CreateAccount(req); } catch (System.Exception e) { context.Response.Write(e.Message); } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + resp.redirectURL; keyResponseParams.Add("Account Id", resp.accountId); keyResponseParams.Add("Create account key", resp.createAccountKey); keyResponseParams.Add("Execution status", resp.execStatus.ToString()); } displayResponse(context, "CreateAccount", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
/// <summary> /// Coutries Supported: /// AU - Australia /// CA - Canada /// CY - /// Cyprus /// CZ - Czech Republic /// DK - Denmark /// EE - Estonia /// FI - Finland /// FR - /// France /// DE - Germany /// GR - Greece /// HU - Hungary /// IT - Italy /// LV - Latvia /// LT - /// Lithuania /// LU - Luxembourg /// MT - Malta /// NL - Netherlands /// PL - Poland /// PT - /// Portugal /// SK - Slovak Republic /// SI - Slovenia /// ES - Spain /// SE - Sweden /// UK - /// United Kingdom /// US - United States /// /// /// /// /// /// </summary> ///<param name="createAccountRequest"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest, ICredential credential) { IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, createAccountRequest.ToNVPString(string.Empty), ServiceName, "CreateAccount", credential); ((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName; ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion; ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "AdaptiveAccounts"; NVPUtil util = new NVPUtil(); return CreateAccountResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1); }
/// <summary> /// Coutries Supported: /// AU - Australia /// CA - Canada /// CY - /// Cyprus /// CZ - Czech Republic /// DK - Denmark /// EE - Estonia /// FI - Finland /// FR - /// France /// DE - Germany /// GR - Greece /// HU - Hungary /// IT - Italy /// LV - Latvia /// LT - /// Lithuania /// LU - Luxembourg /// MT - Malta /// NL - Netherlands /// PL - Poland /// PT - /// Portugal /// SK - Slovak Republic /// SI - Slovenia /// ES - Spain /// SE - Sweden /// UK - /// United Kingdom /// US - United States /// /// /// /// /// /// </summary> ///<param name="createAccountRequest"></param> public CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest) { return CreateAccount(createAccountRequest,(string) null); }
/** * Coutries Supported: * AU - Australia * CA - Canada * CY - Cyprus * CZ - Czech Republic * DK - Denmark * EE - Estonia * FI - Finland * FR - France * DE - Germany * GR - Greece * HU - Hungary * IT - Italy * LV - Latvia * LT - Lithuania * LU - Luxembourg * MT - Malta * NL - Netherlands * PL - Poland * PT - Portugal * SK - Slovak Republic * SI - Slovenia * ES - Spain * SE - Sweden * UK - United Kingdom * US - United States * * * * * */ public CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest, string apiUserName) { string response = Call("CreateAccount", createAccountRequest.ToNVPString(""), apiUserName); NVPUtil util = new NVPUtil(); return CreateAccountResponse.CreateInstance(util.ParseNVPString(response), "", -1); }