/// <summary> /// Redeems a transfer token. /// </summary> /// <param name="token">the transfer token</param> /// <param name="amount">the amount to transfer</param> /// <param name="currency">the currency</param> /// <param name="description">the description of the transfer</param> /// <param name="destination">the transfer instruction destination</param> /// <param name="refId">the reference id of the transfer</param> /// <returns>a transfer record</returns> /// <remarks>amount, currency, description, destination and refId are nullable</remarks>> public Transfer RedeemTokenBlocking( Token token, double?amount, string currency, string description, TransferDestination destination, string refId) { return(RedeemToken(token, amount, currency, description, destination, refId).Result); }
/// <summary> /// Redeems a transfer token. /// </summary> /// <param name="token">the transfer token</param> /// <param name="amount">the amount to transfer</param> /// <param name="currency">the currency</param> /// <param name="description">the description of the transfer</param> /// <param name="destination">the transfer instruction destination</param> /// <param name="refId">the reference id of the transfer</param> /// <returns>a transfer record</returns> /// <remarks>amount, currency, description, destination and refId are nullable</remarks>> public Task <Transfer> RedeemToken( Token token, double?amount, string currency, string description, TransferDestination destination, string refId) { var payload = new TransferPayload { TokenId = token.Id, Description = token.Payload.Description }; if (destination != null) { payload.TransferDestinations.Add(destination); } if (amount.HasValue) { payload.Amount.Value = Util.DoubleToString(amount.Value); } if (currency != null) { payload.Amount.Currency = currency; } if (description != null) { payload.Description = description; } if (refId != null) { payload.RefId = refId; } else if (!string.IsNullOrEmpty(token.Payload.RefId)) { payload.RefId = token.Payload.RefId; } else { logger.Warn("refId is not set. A random ID will be used."); payload.RefId = Util.Nonce(); } return(client.CreateTransfer(payload)); }
/// <summary> /// Adds a transfer destination. /// </summary> /// <param name="destination">destination</param> /// <returns>builder</returns> public StandingOrderTokenBuilder AddDestination(TransferDestination destination) { var instructions = payload.StandingOrder.Instructions; if (instructions == null) { instructions = new TransferInstructions { }; } instructions.TransferDestinations.Add(destination); payload.StandingOrder.Instructions = instructions; return(this); }
/// <summary> /// Creates a standing order token and authorizes a money transfer from a payer to a payee. /// </summary> /// <param name="payer">payer Token member</param> /// <param name="payeeAlias">payee Token member alias</param> /// <param name="keyLevel">the level of signature to provide</param> /// <returns>a standing order Token</returns> public static Token CreateStandingOrderToken( UserMember payer, Alias payeeAlias, Level keyLevel) { // We'll use this as a reference ID. Normally, a payer who // explicitly sets a reference ID would use an ID from a db. // E.g., a bill-paying service might use ID of a "purchase". // We don't have a db, so we fake it with a random string: string purchaseId = Util.Nonce(); // Set SEPA destination. TransferDestination sepaDestination = new TransferDestination { Sepa = new TransferDestination.Types.Sepa { Bic = "XUIWC2489", Iban = "DE89 3704 0044 0532 0130 00" } }; // Set the details of the token. StandingOrderTokenBuilder builder = payer.CreateStandingOrderTokenBuilder( 10.0, // amount "EUR", // currency "DAIL", // frequency of the standing order DateTime.Now, // start date DateTime.Now.AddDays(7)) // end date // source account: .SetAccountId(payer.GetAccountsBlocking()[0].Id()) // payee token alias: .SetToAlias(payeeAlias) // optional description: .SetDescription("Credit card statement payment") // ref id (if not set, will get random ID) .SetRefId(purchaseId) .AddDestination(sepaDestination); // Get the token redemption policy and resolve the token payload. PrepareTokenResult result = payer.PrepareStandingOrderTokenBlocking(builder); // Create the token: Default behavior is to provide the member's signature // at the specified level. In other cases, it may be necessary to provide // additional signatures with payer.createToken(payload, signatures). Token token = payer.CreateTokenBlocking(result.TokenPayload, keyLevel); return(token); }
/** * Sets transfer destinations for a given token request. * * @param payee Payee Token member (the member requesting the transfer token be created) * @param requestId token request id * @param tokenClient Token SDK client * @param setTransferDestinationsCallback callback url */ /// <summary> /// Sets transfer destinations for a given token request. /// </summary> /// <param name="payee">Payee Token member (the member requesting the transfer token be created)</param> /// <param name="requestId">token request id</param> /// <param name="tokenClient">Token SDK client</param> /// <param name="setTransferDestinationsCallback">callback url</param> public static void SetTokenRequestTransferDestinations( TppMember payee, string requestId, Tokenio.Tpp.TokenClient tokenClient, string setTransferDestinationsCallback) { TokenRequestTransferDestinationsCallbackParameters parameters = tokenClient.ParseSetTransferDestinationsUrl(setTransferDestinationsCallback); IList <TransferDestination> transferDestinations = new List <TransferDestination>(); if (parameters.SupportedTransferDestinationTypes .Contains(DestinationCase.FasterPayments)) { TransferDestination destination = new TransferDestination { FasterPayments = new TransferDestination.Types.FasterPayments { SortCode = Util.Nonce(), AccountNumber = Util.Nonce() } }; transferDestinations.Add(destination); } else { transferDestinations.Add(new TransferDestination { Sepa = new TransferDestination.Types.Sepa { Bic = Util.Nonce(), Iban = Util.Nonce() } }); } payee.SetTokenRequestTransferDestinationsBlocking(requestId, transferDestinations); }
/// <summary> /// Redeems a transfer token to transfer money from payer bank account to payee bank account. /// </summary> /// <param name="payee">payee Token member</param> /// <param name="accountId">account id of the payee</param> /// <param name="tokenId">ID of the token to redeem</param> /// <returns>a transfer Transfer</returns> public static Transfer RedeemTransferToken( TppMember payee, string accountId, // account ID of the payee string tokenId) { // ID of token to redeem // We'll use this as a reference ID. Normally, a payee who // explicitly sets a reference ID would use an ID from a db. // E.g., an online merchant might use the ID of a "shopping cart". // We don't have a db, so we fake it with a random string: string cartId = Util.Nonce(); // Retrieve a transfer token to redeem. Token transferToken = payee.GetTokenBlocking(tokenId); // Set token destination TransferDestination tokenDestination = new TransferDestination { Token = new TransferDestination.Types.Token { MemberId = payee.MemberId(), AccountId = accountId } }; // Payee redeems a transfer token. // Money is transferred to a payee bank account. Transfer transfer = payee.RedeemTokenBlocking( transferToken, tokenDestination, // if refId not set, transfer will use token refID: cartId); return(transfer); }
/// <summary> /// Adds a destination account to a standing order token request. /// </summary> /// <param name="destination">destination</param> /// <returns>builder</returns> public StandingOrderBuilder AddDestination(TransferDestination destination) { this.requestPayload.StandingOrderBody.Instructions .TransferDestinations.Add(destination); return(this); }
/// <summary> /// Adds a transfer destination to a transfer token request. /// </summary> /// <param name="destination">destination</param> /// <returns>builder</returns> public TransferBuilder AddDestination(TransferDestination destination) { requestPayload.TransferBody.Instructions.TransferDestinations.Add(destination); return(this); }
/// <summary> /// Redeems a transfer token. /// </summary> /// <param name="token">the transfer token</param> /// <param name="destination">the transfer instruction destination</param> /// <returns>a transfer record</returns> public Transfer RedeemTokenBlocking(Token token, TransferDestination destination) { return(RedeemToken(token, destination).Result); }
/// <summary> /// Redeems a transfer token. /// </summary> /// <param name="token">the transfer token</param> /// <param name="destination">the transfer instruction destination</param> /// <returns>a transfer record</returns> public Task <Transfer> RedeemToken(Token token, TransferDestination destination) { return(RedeemToken(token, null, null, null, destination, null)); }
/// <summary> /// Adds a transfer destination. /// </summary> /// <param name="destination">destination</param> /// <returns>builder</returns> public TransferTokenBuilder AddDestination(TransferDestination destination) { payload.Transfer.Instructions.TransferDestinations.Add(destination); return(this); }