GithubHelp home page GithubHelp logo

braintree / braintree_aspnet_example Goto Github PK

View Code? Open in Web Editor NEW
56.0 78.0 56.0 2.02 MB

An example Braintree integration in the ASP.NET framework

License: MIT License

C# 30.73% CSS 58.24% JavaScript 0.41% HTML 10.49% ASP.NET 0.13%

braintree_aspnet_example's Introduction

Braintree ASP.NET Example

An example Braintree integration for ASP.NET.

Setup Instructions

These instructions assume you are using Visual Studio Community 2017. This has not been tested in Xamarin Studio, or other versions of Visual Studio. This project is also set up to use NuGet package restore, so all dependencies should be automatically installed.

  1. Open braintree_aspnet_example.sln in Visual Studio.

  2. Open the Web.config in BraintreeASPExample, and fill in your Braintree API Credentials in the BraintreeEnvironment, BraintreeMerchantId, BraintreePublicKey, and BraintreePrivateKey keys. Credentials can be found by navigating to Account > My User > View Authorizations in the Braintree Control Panel. Full instructions can be found on our support site.

  3. Start the project by pressing the play button in the toolbar.

Running Tests

There are unit and integration tests. To run the integration tests, you will need to have IIS Express and Firefox (version 46.x or below) installed and your API credentials filled in. You can run all the tests by opening the Test Explorer and clicking Run All.

Testing Transactions

Sandbox transactions must be made with sample credit card numbers, and the response of a Transaction.Sale() call is dependent on the amount of the transaction.

Pro Tips

  • If you do not want to or are unable to use NuGet package restore, make sure to download and reference the following packages:
    • Braintree 3.3.0 or higher
    • Moq 4.5 or higher (needed for BraintreeASPExampleTests only)
    • Selenium WebDriver 2.52 or higher (needed for BraintreeASPExampleTests only)

Help

Disclaimer

This code is provided as is and is only intended to be used for illustration purposes. This code is not production-ready and is not meant to be used in a production environment. This repository is to be used as a tool to help merchants learn how to integrate with Braintree. Any use of this repository or any of its code in a production environment is highly discouraged.

braintree_aspnet_example's People

Contributors

braintreeps avatar crookedneighbor avatar danakatz avatar epreuve avatar evanhahn avatar hlaueriksson avatar iboneva avatar jackellenberger avatar jdlc avatar kyletraynor avatar lilaconlee avatar pblesi avatar sestevens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

braintree_aspnet_example's Issues

Build error

CheckoutsController.cs
Line 27 has this:
var clientToken = gateway.ClientToken.generate();

It should be this:
var clientToken = gateway.ClientToken.Generate();

Could not create SSL/TLS secure channel.

As of 2016.12.14, we encountered an issue generate client token on a machine without SSL, such as SANDBOX or testing environment.

Tried your example, its great and thanks for sharing and teaching.
Submitting this issue would like to question about should example add following 2 lines before generate the token? so that the example would works great as it download.

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Thank you.

The Form doesn't send nonce value back to the server

General information

Sandbox
C# Windows

Issue description

The form doesn't send the value of nonce to server side.
It does post back but without any nonce value.

I tried to make a hidden text box and set the value from js but it still returns null value.

This Device is not capable of making Apple Pay payments

General information

  • Environment: Sandbox
  • Language, language version, and OS:

Issue description

Hi,

I am currently in the middle of integrating Apple pay javascript on the web.
It is creating apple pay session and it does support v3 but it returns false on canMakePayment()

I am unable to find out the issue over here as i am following the exact code provided by braintree

https://developers.braintreepayments.com/guides/apple-pay/client-side/javascript/v3

I am also attaching the error i am facing right now.

braintree-error

------------------------- My Code --------------------------------------

if (!ApplePaySession.canMakePayments()) {
    console.error('This device is not capable of making Apple Pay payments');
}

braintree.client.create({
    authorization: '@BraintreeManager.Gateway.ClientToken.generate()'
}, function (clientErr, clientInstance) {
    if (clientErr) {
        console.error('Error creating client:', clientErr);
        return;
    }

    braintree.applePay.create({
        client: clientInstance
    }, function (applePayErr, applePayInstance) {
        if (applePayErr) {
            console.error('Error creating applePayInstance:', applePayErr);
            return;
        }

        // Alternatively, check if the device has an Apple Pay card available.
        // You can do this if your checkout flow defaults to Apple Pay
        // or if you are displaying Apple Pay buttons on a product detail page.

        // Use your Apple Pay merchant identifier
        // to check if payments can be made.
      
        

        var promise = ApplePaySession.canMakePaymentsWithActiveCard(applePayInstance.merchantIdentifier);
        promise.then(function (canMakePaymentsWithActiveCard) {
            if (canMakePaymentsWithActiveCard) {
                // Set up Apple Pay buttons
                var createApplePay = document.getElementById("create-apple-pay");
                createApplePay.innerHTML = '<div class="apple-pay-set-up-button apple-pay-setup-button-white-with-line">';
                console.log("Inside set up apple pay button");


            }
        });
    });
});

Unable to run BraintreeASPExample

Unable to run BraintreeASPExample by following the ReadMe file.
2018-10-30_10-12-58

  • Environment: SandBox
  • Language, language version, and OS: VS2017 ASP.NET MVC 4.0

Issue description

We are planning to use Braintree API to pull sales transactions for settlement. We download this example to get a better understanding how to integrate with Braintree. We follow the ReadMe file to enter our Sandbox merchantId, Public and Private key in the web.config file. We cannot run the BraintreeASPExample within VS2017.

Show.html crashes due to Braintree.Transaction' does not contain a definition for 'Customer''

General information

  • Environment: Sandbox

Issue description

After downloading code, restoring nuget, setting sandbox keys and then running.
Using card
2223000048400011
02/20

After returning Show.html returns error on lin 101 with

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''Braintree.Transaction' does not contain a definition for 'Customer''
Customer property does not even exist on object Transaction but rather CustomerDetails. Which unfortunately has only null values.

Nothing in the guide tells you to setup some sort of customerdata.

DI object and lifecycle?

General information

  • Environment: N/A
  • Language, language version, and OS: ASP.NET Core 2.0

Issue description

Hello! I'm not sure if this is most appropriate to be asked here, on the main Braintree dotnet repo, or sent as an email to support, so I'm trying here. Let me know if it should be asked elsewhere, that way I'll know for the future.

What is the proper way to use ASP.NET Core DI with the library? We're using the built-in DI, but I imagine the answer will be the same for all DI containers. I'm currently using the code below, but I'm not sure if it's right. Can the gateway be a singleton? Should I be injecting something else altogether? Should I create a class like IBraintreeConfiguration in this repo and inject that? I can write the code, I just don't know what specifically to inject or what its lifecycle should be. Any advice would be appreciated. Thank you!

Current code in Startup.cs / ConfigureServices():

// Config values are pulled from appsettings.json
var braintreeGateway = new BraintreeGateway
{
    Environment = Braintree.Environment.SANDBOX,
    MerchantId = Configuration["Braintree:MerchantId"],
    PublicKey = Configuration["Braintree:PublicKey"],
    PrivateKey = Configuration["Braintree:PrivateKey"]
};

// Inject gateway as singleton
services.AddSingleton(braintreeGateway);

Onboarding Sub-merchants is not working

Hi ,

I am working with dot net SDK of braintree but it seems it is not recognizing the object like MerchantAccountRequest and TransactionRequest for marketplace

///////////
var request = new TransactionRequest
{
MerchantAccountId = "provider_sub_merchant_account",
Amount = 10.00M,
PaymentMethodNonce = nonceFromTheClient,
ServiceFeeAmount = 10.00m
};

Result result = gateway.Transaction.Sale(request);
/////////////////////

MerchantAccountRequest request = new MerchantAccountRequest
{
Individual = new IndividualRequest
{
FirstName = "Jane",
LastName = "Doe",
Email = "[email protected]",
Phone = "5553334444",
DateOfBirth = "1981-11-19",
Ssn = "456-45-4567",
Address = new AddressRequest
{
StreetAddress = "111 Main St",
Locality = "Chicago",
Region = "IL",
PostalCode = "60622"
}
},
Business = new BusinessRequest
{
LegalName = "Jane's Ladders",
DbaName = "Jane's Ladders",
TaxId = "98-7654321",
Address = new AddressRequest
{
StreetAddress = "111 Main St",
Locality = "Chicago",
Region = "IL",
PostalCode = "60622"
}
},
Funding = new FundingRequest
{
Descriptor = "Blue Ladders",
Destination = FundingDestination.BANK,
Email = "[email protected]",
MobilePhone = "5555555555",
AccountNumber = "1123581321",
RoutingNumber = "071101307"
},
TosAccepted = true,
MasterMerchantAccountId = "14ladders_marketplace",
Id = "blue_ladders_store"
};

Result result = gateway.MerchantAccount.Create(request);

'Some of your info isn't correct. Please try again" Pay by paypal login Error

i am running the sample application and using paypal to make a test payment. i get a login screen but I am unable to login into paypal to make a test payment. I get a 'Some of your info isn't correct. Please try again." error even though i know that my login details are correct.

I also get the following 2 errors on my chrome console. What am I missing?

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.paypal.com/xoplatform/logger/api/logger with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
(anonymous) @ util.js:71
e @ promise.js:41
(anonymous) @ util.js:35
v @ logger.js:10
(anonymous) @ proxy.js:37
_ @ logger.js:111
(anonymous) @ util.js:98
l @ promise.js:161
o.dispatch @ promise.js:152
o.then @ promise.js:241
(anonymous) @ util.js:97
setTimeout (async)
A @ util.js:87
(anonymous) @ setup.js:275
l @ promise.js:161
o.dispatch @ promise.js:152
o.resolve @ promise.js:96
l @ promise.js:212
o.dispatch @ promise.js:152
o.resolve @ promise.js:96
(anonymous) @ promise.js:43
Promise.then (async)
(anonymous) @ promise.js:309
e @ promise.js:41
e.resolve @ promise.js:309
e.try @ promise.js:408
(anonymous) @ setup.js:242
a @ bootstrap:19
(anonymous) @ load.js:32
a @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83

util.js:71 POST https://www.sandbox.paypal.com/xoplatform/logger/api/logger net::ERR_CONNECTION_RESET
(anonymous) @ util.js:71
e @ promise.js:41
(anonymous) @ util.js:35
v @ logger.js:10
_ @ logger.js:111
(anonymous) @ util.js:98
l @ promise.js:161
o.dispatch @ promise.js:152
o.then @ promise.js:241
(anonymous) @ util.js:97
setTimeout (async)
A @ util.js:87
(anonymous) @ component.js:465
n @ props.js:88
(anonymous) @ fn.js:35
(anonymous) @ serialize.js:34
e.try @ promise.js:400
(anonymous) @ serialize.js:33
(anonymous) @ types.js:68
e.try @ promise.js:400
f. @ types.js:56
_ @ index.js:114
L @ index.js:140

Error with PayPal payment in test application

General information

  • Environment: Sandbox
  • Language, language version, and OS: .Net on Windows 10

Issue description

I set up my braintree sandbox account and link my PayPal sandbox account within. Refresh your test application and PayPal button go to live, but when I click it have error:
{"error":{"errorName":"AUTHORIZATION_ERROR","errorMessage":"Authorization error --- REFUSED_MARK_REF_TXN_NOT_ENABLED:This merchant account is not permitted to create Merchant Initiated Billing Agreement","debugId":"fba7a82adb8cf, fba7a82adb8cf","paypalHttpStatus":403}}

No 3ds in samples

General information

  • Environment: Sandbox and Production
  • Language, language version, and OS: Windows 10, VS 2017 Community, ASP.NET

Issue description

Apparently 3ds v2 is going to be required in Europe from September. I am trying to update my client's code to the latest version, without success.

I can find some 3ds v2 info, and code, and I can find some dropin code and info. What I cannot seem to find is any examples of how these two things fit together. It's all very confused.

Would appreciate if you would update your sample code to meet the requirements we're being told we have to implement. They're not 'end to end' implementations if the code does not contain required elements (i.e. 3ds v2) that we're being told is not optional, but must be implemented.

Have looked over the rest of the documentation, but it's very muddled, and there is nothing that really shows a full implementation of the dropin UI or hosted fields with 3ds.

The handlePaymentMethod is not being called when using PayPal

I have the following code:

<BraintreeDropIn
braintree={braintree}
authorizationToken={authorizationToken}
handlePaymentMethod={this.handlePaymentMethod}
paypal={{
flow: "vault",
singleUse: false
}}
/>

The handlePaymentMethod is called when credit cards are used, but not PayPal.

Am I doing something incorrectly?

Had to Update `ConfigurationManager` to `WebConfigurationManager`

General information

  • Environment: Sandbox
  • Language, language version, and OS: Microsoft.AspNet.Mvc v5.2.3, Visual Studio Community Edition 2017

Issue description

I'm piggy backing on the sample here to develop a plugin for Umbraco.

Really simple issue that I wanted to run by you - but the ConfigurationManager must have been changed recently? To get the sample/ code running I had to make some adjustments to BraintreeConfiguration.cs. Did anyone else need to do this to get it running?

  • Update using using System.Configuration; to using using System.Web.Configuration;
  • Update return ConfigurationManager.AppSettings[setting]; to return WebConfigurationManager.AppSettings[setting];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.