コード例 #1
0
        /// <summary>
        /// Adds a transfer source.
        /// </summary>
        /// <param name="source">source</param>
        /// <returns>builder</returns>
        public StandingOrderTokenBuilder SetSource(TransferEndpoint source)
        {
            var instructions = payload.StandingOrder.Instructions;

            if (instructions == null)
            {
                instructions = new TransferInstructions();
            }
            instructions.Source = source;
            payload.StandingOrder.Instructions = instructions;
            return(this);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        /// Creates the builder object from a token request.
        /// </summary>
        /// <param name="member">payer of the token</param>
        /// <param name="tokenRequest">token request</param>
        public TransferTokenBuilder(Member member, TokenRequest tokenRequest)
        {
            if (tokenRequest.RequestPayload.RequestBodyCase != TRANSFER_BODY.TransferBody)
            {
                throw new ArgumentException("Require token request with transfer body.");
            }

            if (tokenRequest.RequestPayload.To == null)
            {
                throw new ArgumentException("No payee on token request.");
            }

            var transferBody = tokenRequest.RequestPayload.TransferBody;
            var instructions = transferBody.Instructions;

            if (instructions == null)
            {
                instructions = new TransferInstructions();
                instructions.Destinations.Add(transferBody.Destinations);
            }

            if (instructions.Metadata == null)
            {
                instructions.Metadata = new TransferInstructions.Types.Metadata();
            }

            this.member  = member;
            this.payload = new TokenPayload
            {
                Version          = "1.0",
                RefId            = tokenRequest.RequestPayload.RefId,
                From             = tokenRequest.RequestOptions.From,
                To               = tokenRequest.RequestPayload.To,
                Description      = tokenRequest.RequestPayload.Description,
                ReceiptRequested = tokenRequest.RequestOptions.ReceiptRequested,
                TokenRequestId   = tokenRequest.Id,
                Transfer         = new TransferBody
                {
                    LifetimeAmount = transferBody.LifetimeAmount,
                    Currency       = transferBody.Currency,
                    Amount         = transferBody.Amount,
                    ConfirmFunds   = transferBody.ConfirmFunds,
                    Instructions   = instructions
                }
            };
            if (tokenRequest.RequestPayload.ActingAs != null)
            {
                this.payload.ActingAs = tokenRequest.RequestPayload.ActingAs;
            }
        }