Search code examples
c#braintree

how can i get payment without payment method nonce?


i need to get payment with Braintree and as far as i understand from the Braintree's documentation,followed the these steps;

  1. created a Gateway

     BraintreeGateway Gateway = new BraintreeGateway
    {
        Environment = Braintree.Environment.SANDBOX,
        MerchantId = "xxxxxxxxxxx",
        PublicKey = "yyyyyyyyyyyyyyy",
        PrivateKey = "zzzzzzzzzzzzzzz",
    };
    
  2. created a Customer

    var request = new CustomerRequest
    {
        FirstName = "firstName",
        LastName = "lastName",
        Email = "eMail",
        Phone = "phone",
    };
    string CustomerId = Gateway.Customer.Create(request).Target.Id;
    
  3. created a credit card of the customer as using returened customerid

    var creditCardRequest = new CreditCardRequest
    {
        CustomerId = CustomerId,
        Number = "credit_card_number",
        ExpirationDate = "ex_date",
        CVV = "cc_cvv"
    };
    
    string creditCardToken = Gateway.CreditCard.Create(creditCardRequest).Target.Token;
    

what then? need a transaction with amount but the using what i found is not related with customer or credit card. Can someone help about what i should do next? Especially i need a method without 3d secure.


Solution

  • The answer of support: To create a transaction, you must include an amount and either a paymentMethodNonce, a paymentMethodToken, or a customerId. Passing a customerId is equivalent to passing the paymentMethodToken of the customer's default payment method.

      TransactionRequest transactionRequest = new TransactionRequest()
        {
            Amount = amount,
            CustomerId = customer.Id,
            Options = new TransactionOptionsRequest
            {
                SubmitForSettlement = true
            }
        };
    
        Result<Transaction> result = Gateway.Transaction.Sale(transactionRequest);