public static async Task <string> CreateProfile() { SandboxEnvironment environment = new SandboxEnvironment( "AcsZudPzaw7QNmu68Q15SdtKMCM0HJMKO-q-Lp1IXgLwqe-Dt9CWOYqsBtZ_QiS2hVVL0o50BK8xW0Dk", "EJo0Vn_JKFf5qq4pN6zOKm50fmYN4dI8ZTeB5j2vl5YtWRnKeAPOvXK2WZ4faxGA8QaUM1KhVj-kF8kr"); _client = new PayPalHttpClient(environment); WebProfileCreateRequest request = new WebProfileCreateRequest(); WebProfile profile = new WebProfile { Name = "WebProfil", Presentation = new Presentation { BrandName = "eTeatar", LocaleCode = "US", LogoImage = "https://www.paypal.com/" }, InputFields = new InputFields { AddressOverride = 0, AllowNote = false, NoShipping = 1 }, FlowConfig = new FlowConfig { BankTxnPendingUrl = "https://www.paypal.com/", LandingPageType = "billing", UserAction = "commit", ReturnUriHttpMethod = "POST" }, Temporary = true }; request.RequestBody(profile); HttpResponse response = await _client.Execute(request); WebProfile result = response.Result <WebProfile>(); return(result.Id); }
public static string FetchWebProfile(PaypalWithRedirectSettings paypalSettings) { if (!paypalSettings.CheckoutProfileId.IsNullEmptyOrWhiteSpace()) { return(paypalSettings.CheckoutProfileId); } var webProfileRequest = new WebProfileCreateRequest(); webProfileRequest.RequestBody(new WebProfile() { Temporary = false, InputFields = new InputFields() { NoShipping = 1, AddressOverride = 1 }, Name = Guid.NewGuid().ToString() }); var environment = GetEnvironment(paypalSettings); var client = new PayPalHttpClient(environment); try { var response = client.Execute(webProfileRequest).Result; var result = response.Result <WebProfile>(); var id = result.Id; paypalSettings.CheckoutProfileId = id; var settingService = DependencyResolver.Resolve <ISettingService>(); settingService.Save(paypalSettings, ApplicationEngine.CurrentStore.Id); return(id); } catch (BraintreeHttp.HttpException ex) { return(null); } }