private static CreatePayoutRequest buildRequestBody() { var request = new CreatePayoutRequest() { SenderBatchHeader = new SenderBatchHeader() { EmailMessage = "Congrats on recieving 1$", EmailSubject = "You recieved a payout!!" }, Items = new List <PayoutItem>() { new PayoutItem() { RecipientType = "EMAIL", Amount = new Currency() { CurrencyCode = "USD", Value = "1", }, Receiver = "*****@*****.**", } } }; return(request); }
public static CreatePayoutRequest buildRequestBody() { var request = new CreatePayoutRequest() { SenderBatchHeader = new SenderBatchHeader() { EmailMessage = "Congrats on recieving 1$", EmailSubject = "You recieved a payout!!" }, Items = new List <PayoutItem>() { new PayoutItem() { RecipientType = "EMAIL", Amount = new Currency() { CurrencyCode = "USD", Value = "1", }, Receiver = "*****@*****.**", RecipientWallet = "VENMO", Note = "This is a test note", VenmoContext = new VenmoContext() { LogoURL = "https://i.imgur.com/eOYIYgM.png", HollerURL = "https://cdn.emogi.com/holler", SocialFeedPrivacy = "friends_only" } } } }; return(request); }
/// <summary> /// Resource /{merchantId}/payouts /// <a href="https://developer.globalcollect.com/documentation/api/server/#__merchantId__payouts_post">Create payout</a> /// </summary> /// <param name="body">CreatePayoutRequest</param> /// <param name="context">CallContext</param> /// <returns>PayoutResponse</returns> /// <exception cref="DeclinedPayoutException">if the GlobalCollect platform declined / rejected the payout. The payout result will be available from the exception.</exception> /// <exception cref="ValidationException">if the request was not correct and couldn't be processed (HTTP status code BadRequest)</exception> /// <exception cref="AuthorizationException">if the request was not allowed (HTTP status code Forbidden)</exception> /// <exception cref="IdempotenceException">if an idempotent request caused a conflict (HTTP status code Conflict)</exception> /// <exception cref="ReferenceException">if an object was attempted to be referenced that doesn't exist or has been removed, /// or there was a conflict (HTTP status code NotFound, Conflict or Gone)</exception> /// <exception cref="GlobalCollectException">if something went wrong at the GlobalCollect platform, /// the GlobalCollect platform was unable to process a message from a downstream partner/acquirer, /// or the service that you're trying to reach is temporary unavailable (HTTP status code InternalServerError, BadGateway or ServiceUnavailable)</exception> /// <exception cref="ApiException">if the GlobalCollect platform returned any other error</exception> public async Task <PayoutResponse> Create(CreatePayoutRequest body, CallContext context = null) { string uri = InstantiateUri("/{apiVersion}/{merchantId}/payouts", null); try { return(await _communicator.Post <PayoutResponse>( uri, ClientHeaders, null, body, context)); } catch (ResponseException e) { object errorObject; switch (e.StatusCode) { case HttpStatusCode.BadRequest: errorObject = _communicator.Marshaller.Unmarshal <PayoutErrorResponse>(e.Body); break; default: errorObject = _communicator.Marshaller.Unmarshal <ErrorResponse>(e.Body); break; } throw CreateException(e.StatusCode, e.Body, errorObject, context); } }
/// <inheritdoc/> public async Task <PayoutResponse> CreatePayout(CreatePayoutRequest body, CallContext context = null) { string uri = InstantiateUri("/v2/{merchantId}/payouts", null); try { return(await _communicator.Post <PayoutResponse>( uri, ClientHeaders, null, body, context) .ConfigureAwait(false)); } catch (ResponseException e) { object errorObject = _communicator.Unmarshal <PayoutErrorResponse>(e.Body); throw CreateException(e.StatusCode, e.Body, errorObject, context); } }
public async Task <IActionResult> CreatePayout(string pullPaymentId, CreatePayoutRequest request) { if (request is null) { return(NotFound()); } if (!PaymentMethodId.TryParse(request?.PaymentMethod, out var paymentMethodId)) { ModelState.AddModelError(nameof(request.PaymentMethod), "Invalid payment method"); return(this.CreateValidationError(ModelState)); } var payoutHandler = _payoutHandlers.FirstOrDefault(handler => handler.CanHandle(paymentMethodId)); if (payoutHandler is null) { ModelState.AddModelError(nameof(request.PaymentMethod), "Invalid payment method"); return(this.CreateValidationError(ModelState)); } await using var ctx = _dbContextFactory.CreateContext(); var pp = await ctx.PullPayments.FindAsync(pullPaymentId); if (pp is null) { return(PullPaymentNotFound()); } var ppBlob = pp.GetBlob(); IClaimDestination destination = await payoutHandler.ParseClaimDestination(paymentMethodId, request.Destination); if (destination is null) { ModelState.AddModelError(nameof(request.Destination), "The destination must be an address or a BIP21 URI"); return(this.CreateValidationError(ModelState)); } if (request.Amount is decimal v && (v < ppBlob.MinimumClaim || v == 0.0m)) { ModelState.AddModelError(nameof(request.Amount), $"Amount too small (should be at least {ppBlob.MinimumClaim})"); return(this.CreateValidationError(ModelState)); } var cd = _currencyNameTable.GetCurrencyData(pp.GetBlob().Currency, false); var result = await _pullPaymentService.Claim(new ClaimRequest() { Destination = destination, PullPaymentId = pullPaymentId, Value = request.Amount, PaymentMethodId = paymentMethodId }); switch (result.Result) { case ClaimRequest.ClaimResult.Ok: break; case ClaimRequest.ClaimResult.Duplicate: return(this.CreateAPIError("duplicate-destination", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.Expired: return(this.CreateAPIError("expired", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.NotStarted: return(this.CreateAPIError("not-started", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.Archived: return(this.CreateAPIError("archived", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.Overdraft: return(this.CreateAPIError("overdraft", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.AmountTooLow: return(this.CreateAPIError("amount-too-low", ClaimRequest.GetErrorMessage(result.Result))); case ClaimRequest.ClaimResult.PaymentMethodNotSupported: return(this.CreateAPIError("payment-method-not-supported", ClaimRequest.GetErrorMessage(result.Result))); default: throw new NotSupportedException("Unsupported ClaimResult"); } return(Ok(ToModel(result.PayoutData, cd))); }
public async void Example() { #pragma warning disable 0168 using (Client client = GetClient()) { AmountOfMoney amountOfMoney = new AmountOfMoney(); amountOfMoney.Amount = 2345L; amountOfMoney.CurrencyCode = "EUR"; BankAccountIban bankAccountIban = new BankAccountIban(); bankAccountIban.AccountHolderName = "Wile E. Coyote"; bankAccountIban.Iban = "IT60X0542811101000000123456"; Address address = new Address(); address.City = "Burbank"; address.CountryCode = "US"; address.HouseNumber = "411"; address.State = "California"; address.Street = "N Hollywood Way"; address.Zip = "91505"; CompanyInformation companyInformation = new CompanyInformation(); companyInformation.Name = "Acme Labs"; ContactDetailsBase contactDetails = new ContactDetailsBase(); contactDetails.EmailAddress = "*****@*****.**"; PersonalName name = new PersonalName(); name.FirstName = "Wile"; name.Surname = "Coyote"; name.SurnamePrefix = "E."; name.Title = "Mr."; PayoutCustomer customer = new PayoutCustomer(); customer.Address = address; customer.CompanyInformation = companyInformation; customer.ContactDetails = contactDetails; customer.Name = name; BankTransferPayoutMethodSpecificInput bankTransferPayoutMethodSpecificInput = new BankTransferPayoutMethodSpecificInput(); bankTransferPayoutMethodSpecificInput.BankAccountIban = bankAccountIban; bankTransferPayoutMethodSpecificInput.Customer = customer; bankTransferPayoutMethodSpecificInput.PayoutDate = "20150102"; bankTransferPayoutMethodSpecificInput.PayoutText = "Payout Acme"; bankTransferPayoutMethodSpecificInput.SwiftCode = "swift"; PayoutReferences references = new PayoutReferences(); references.MerchantReference = "AcmeOrder001"; CreatePayoutRequest body = new CreatePayoutRequest(); body.AmountOfMoney = amountOfMoney; body.BankTransferPayoutMethodSpecificInput = bankTransferPayoutMethodSpecificInput; body.References = references; try { PayoutResponse response = await client.Merchant("merchantId").Payouts().Create(body); } catch (DeclinedPayoutException e) { HandleDeclinedPayout(e.PayoutResult); } catch (ApiException e) { HandleApiErrors(e.Errors); } } #pragma warning restore 0168 }
private async System.Threading.Tasks.Task levantar() { try { string emailPaypal = txt_emaillevantar.Text; double valor = double.Parse(txt_moneylevantar.Text.Replace(".", ",")); if (emailPaypal == String.Empty || emailPaypal.Contains("@") == false || emailPaypal.Contains(".") == false) { throw new Exception("O email indicado não é válido."); } if (valor <= 0) { throw new Exception("Valor indicado inválido"); } int id_user = int.Parse(Session["id_user"].ToString()); Models.User user = new User(id_user); double saldo = user.getSaldo(); if (saldo - valor < 0) { throw new Exception("O seu saldo não permite executar esta ação!"); } var body = new CreatePayoutRequest() { SenderBatchHeader = new SenderBatchHeader() { EmailMessage = $"O teu levantamento foi sucedido, recebeste {valor}", EmailSubject = "Recebeste dinheiro da Food4U!!" }, Items = new List <PayoutItem>() { new PayoutItem() { RecipientType = "EMAIL", Amount = new Currency() { CurrencyCode = "EUR", Value = valor.ToString().Replace(",", "."), }, Receiver = emailPaypal, } } }; PayoutsPostRequest request = new PayoutsPostRequest(); request.RequestBody(body); Transacao.LevantarDinheiro(id_user, saldo, valor); var response = await CreatePayout.client().Execute(request); var result = response.Result <CreatePayoutResponse>(); Debug.WriteLine("Status: {0}", result.BatchHeader.BatchStatus); Debug.WriteLine("Batch Id: {0}", result.BatchHeader.PayoutBatchId); Debug.WriteLine("Links:"); foreach (LinkDescription link in result.Links) { Debug.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method); } } catch (Exception erro) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "MostrarNotificação", $"ShowNotification('Erro','{erro.Message}', 'error')", true); } }
public async Task <PayoutData> CreatePayout(string pullPaymentId, CreatePayoutRequest payoutRequest, CancellationToken cancellationToken = default) { var response = await _httpClient.SendAsync(CreateHttpRequest($"api/v1/pull-payments/{HttpUtility.UrlEncode(pullPaymentId)}/payouts", bodyPayload : payoutRequest, method : HttpMethod.Post), cancellationToken); return(await HandleResponse <PayoutData>(response)); }
/// <remarks/> public void CreatePayoutAsync(CreatePayoutRequest CreatePayoutRequest, object userState) { if ((this.CreatePayoutOperationCompleted == null)) { this.CreatePayoutOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreatePayoutOperationCompleted); } this.InvokeAsync("CreatePayout", new object[] { CreatePayoutRequest}, this.CreatePayoutOperationCompleted, userState); }
/// <remarks/> public void CreatePayoutAsync(CreatePayoutRequest CreatePayoutRequest) { this.CreatePayoutAsync(CreatePayoutRequest, null); }