public void Sale_TransactUsBankAccountWithToken()
        {
            Result <Customer> result = gateway.Customer.Create(new CustomerRequest());

            Assert.IsTrue(result.IsSuccess());

            string nonce   = TestHelper.GenerateValidUsBankAccountNonce(gateway);
            var    request = new PaymentMethodRequest
            {
                CustomerId         = result.Target.Id,
                PaymentMethodNonce = nonce,
                Options            = new PaymentMethodOptionsRequest {
                    VerificationMerchantAccountId = MerchantAccountIDs.US_BANK_MERCHANT_ACCOUNT_ID
                }
            };
            Result <PaymentMethod> paymentMethodResult = gateway.PaymentMethod.Create(request);

            Assert.IsTrue(paymentMethodResult.IsSuccess());

            Assert.IsInstanceOf(typeof(UsBankAccount), paymentMethodResult.Target);
            UsBankAccount usBankAccount = (UsBankAccount)paymentMethodResult.Target;

            Assert.IsTrue(usBankAccount.IsVerified);
            Assert.AreEqual(1, usBankAccount.Verifications.Count);

            var transactionRequest = new TransactionRequest
            {
                Amount            = SandboxValues.TransactionAmount.AUTHORIZE,
                MerchantAccountId = MerchantAccountIDs.US_BANK_MERCHANT_ACCOUNT_ID
            };

            UsBankAccountGateway usBankAccountGateway = new UsBankAccountGateway(gateway);
            Result <Transaction> transactionResult    = usBankAccountGateway.Sale(usBankAccount.Token, transactionRequest);

            Assert.IsTrue(transactionResult.IsSuccess());
            Transaction transaction = transactionResult.Target;

            Assert.AreEqual(TransactionStatus.SETTLEMENT_PENDING, transaction.Status);

            UsBankAccountDetails usBankAccountDetails = transaction.UsBankAccountDetails;

            Assert.AreEqual(usBankAccount.RoutingNumber, usBankAccountDetails.RoutingNumber);
            Assert.AreEqual(usBankAccount.Last4, usBankAccountDetails.Last4);
            Assert.AreEqual(usBankAccount.AccountType, usBankAccountDetails.AccountType);
            Assert.AreEqual(usBankAccount.AccountHolderName, usBankAccountDetails.AccountHolderName);
            AchMandate achMandate = usBankAccountDetails.AchMandate;

            Assert.AreEqual(usBankAccount.AchMandate.Text, achMandate.Text);
            Assert.AreEqual("DateTime", achMandate.AcceptedAt.GetType().Name);
        }
Пример #2
0
        public void SampleNotification_ReturnsANotificationForATransactionSettlementDeclinedWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.TRANSACTION_SETTLEMENT_DECLINED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.TRANSACTION_SETTLEMENT_DECLINED, notification.Kind);
            Transaction transaction = notification.Transaction;

            Assert.AreEqual(TransactionStatus.SETTLEMENT_DECLINED, transaction.Status);
            Assert.AreEqual(100.00, transaction.Amount);
            Assert.AreEqual("my_id", transaction.Id);

            UsBankAccountDetails usBankAccountDetails = transaction.UsBankAccountDetails;

            Assert.AreEqual("123456789", usBankAccountDetails.RoutingNumber);
            Assert.AreEqual("1234", usBankAccountDetails.Last4);
            Assert.AreEqual("checking", usBankAccountDetails.AccountType);
            Assert.AreEqual("Dan Schulman", usBankAccountDetails.AccountHolderName);
        }
Пример #3
0
 public BillingSource(UsBankAccountDetails bank)
 {
     Type        = PaymentMethodType.BankAccount;
     Description = $"{bank.BankName}, *{bank.Last4}";
 }
Пример #4
0
        protected internal Transaction(NodeWrapper node, IBraintreeGateway gateway)
        {
            Gateway = gateway;

            if (node == null)
                return;

            Id = node.GetString("id");
            Amount = node.GetDecimal("amount");
            AvsErrorResponseCode = node.GetString("avs-error-response-code");
            AvsPostalCodeResponseCode = node.GetString("avs-postal-code-response-code");
            AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code");
            GatewayRejectionReason = (TransactionGatewayRejectionReason)CollectionUtil.Find(
                TransactionGatewayRejectionReason.ALL,
                node.GetString("gateway-rejection-reason"),
                TransactionGatewayRejectionReason.UNRECOGNIZED
            );
            PaymentInstrumentType = (PaymentInstrumentType)CollectionUtil.Find(
                PaymentInstrumentType.ALL,
                node.GetString("payment-instrument-type"),
                PaymentInstrumentType.UNKNOWN
            );
            Channel = node.GetString("channel");
            OrderId = node.GetString("order-id");
            Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);
            EscrowStatus = (TransactionEscrowStatus)CollectionUtil.Find(
                    TransactionEscrowStatus.ALL,
                    node.GetString("escrow-status"),
                    TransactionEscrowStatus.UNRECOGNIZED
            );

            List<NodeWrapper> statusNodes = node.GetList("status-history/status-event");
            StatusHistory = new StatusEvent[statusNodes.Count];
            for (int i = 0; i < statusNodes.Count; i++)
            {
                StatusHistory[i] = new StatusEvent(statusNodes[i]);
            }

            Type = (TransactionType)CollectionUtil.Find(TransactionType.ALL, node.GetString("type"), TransactionType.UNRECOGNIZED);
            MerchantAccountId = node.GetString("merchant-account-id");
            ProcessorAuthorizationCode = node.GetString("processor-authorization-code");
            ProcessorResponseCode = node.GetString("processor-response-code");
            ProcessorResponseText = node.GetString("processor-response-text");
            ProcessorSettlementResponseCode = node.GetString("processor-settlement-response-code");
            ProcessorSettlementResponseText = node.GetString("processor-settlement-response-text");
            AdditionalProcessorResponse = node.GetString("additional-processor-response");
            VoiceReferralNumber = node.GetString("voice-referral-number");
            PurchaseOrderNumber = node.GetString("purchase-order-number");
            Recurring = node.GetBoolean("recurring");
            RefundedTransactionId = node.GetString("refunded-transaction-id");

            #pragma warning disable 0618
            RefundId = node.GetString("refund-id");
            #pragma warning restore 0618

            RefundIds = node.GetStrings("refund-ids/*");
            PartialSettlementTransactionIds = node.GetStrings("partial-settlement-transaction-ids/*");
            AuthorizedTransactionId = node.GetString("authorized-transaction-id");
            SettlementBatchId = node.GetString("settlement-batch-id");
            PlanId = node.GetString("plan-id");
            SubscriptionId = node.GetString("subscription-id");
            TaxAmount = node.GetDecimal("tax-amount");
            TaxExempt = node.GetBoolean("tax-exempt");
            CustomFields = node.GetDictionary("custom-fields");
            CreditCard = new CreditCard(node.GetNode("credit-card"), gateway);
            Subscription = new Subscription(node.GetNode("subscription"), gateway);
            Customer = new Customer(node.GetNode("customer"), gateway);
            CurrencyIsoCode = node.GetString("currency-iso-code");
            CvvResponseCode = node.GetString("cvv-response-code");
            Descriptor = new Descriptor(node.GetNode("descriptor"));
            ServiceFeeAmount = node.GetDecimal("service-fee-amount");
            DisbursementDetails = new DisbursementDetails(node.GetNode("disbursement-details"));
            var paypalNode = node.GetNode("paypal");
            if (paypalNode != null)
            {
                PayPalDetails = new PayPalDetails(paypalNode);
            }
            var coinbaseNode = node.GetNode("coinbase-account");
            if (coinbaseNode != null)
            {
                CoinbaseDetails = new CoinbaseDetails(coinbaseNode);
            }
            var applePayNode = node.GetNode("apple-pay");
            if (applePayNode != null)
            {
                ApplePayDetails = new ApplePayDetails(applePayNode);
            }
            var androidPayNode = node.GetNode("android-pay-card");
            if (androidPayNode != null)
            {
                AndroidPayDetails = new AndroidPayDetails(androidPayNode);
            }
            var amexExpressCheckoutNode = node.GetNode("amex-express-checkout-card");
            if (amexExpressCheckoutNode != null)
            {
                AmexExpressCheckoutDetails = new AmexExpressCheckoutDetails(amexExpressCheckoutNode);
            }
            var venmoAccountNode = node.GetNode("venmo-account");
            if (venmoAccountNode != null)
            {
                VenmoAccountDetails = new VenmoAccountDetails(venmoAccountNode);
            }
            var usBankAccountNode = node.GetNode("us-bank-account");
            if (usBankAccountNode != null)
            {
                UsBankAccountDetails = new UsBankAccountDetails(usBankAccountNode);
            }

            BillingAddress = new Address(node.GetNode("billing"));
            ShippingAddress = new Address(node.GetNode("shipping"));

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            AddOns = new List<AddOn>();
            foreach (var addOnResponse in node.GetList("add-ons/add-on"))
            {
                AddOns.Add(new AddOn(addOnResponse));
            }
            Discounts = new List<Discount>();
            foreach (var discountResponse in node.GetList("discounts/discount"))
            {
                Discounts.Add(new Discount(discountResponse));
            }

            Disputes = new List<Dispute>();
            foreach (var dispute in node.GetList("disputes/dispute"))
            {
                Disputes.Add(new Dispute(dispute));
            }

            var riskDataNode = node.GetNode("risk-data");
            if (riskDataNode != null)
            {
                RiskData = new RiskData(riskDataNode);
            }

            var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
            if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty())
            {
                ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
            }
        }