eventsreg / cfpayment

CFPayment modules
0 stars 0 forks source link

Update existing Braintree gateway to be usable for current "Blue" mode. #8

Open jasonbrookins opened 5 years ago

jasonbrookins commented 5 years ago

The current Braintree gateway is older and uses the "Orange" mode instead of the newer "Blue" mode (the difference is largely in the user credentials - the former only used a username/password; the latter uses public/private keys).

There are java packages for it here:

https://developers.braintreepayments.com/start/hello-server/java https://developers.braintreepayments.com/client_libraries/java/braintree-java-2.95.0.jar

https://developers.braintreepayments.com/reference/request/payment-method/create/java#examples

So, the java methods need to be fed CFPayment information coming in and return the transaction response in CFPayment structures. Testing the implementation is going to be difficult, as well.

https://sandbox.braintreegateway.com/login
Sandbox credentials:

Merchant ID: 9dcqy4pjq3v4m4tq
Public Key:  jyqr36f7kx2qsmfx
Private Key: 77dd270249a6fde850d933d84cd9424d
jasonbrookins commented 5 years ago

Transaction Procedure:

Payment method nonce The payment method nonce is a string returned by the client SDK to represent a payment method. This string is a reference to the customer payment method details that were provided in your payment form and should be sent to your server where it can be used with the server SDKs to create a new transaction request.

To setup braintree Configure the environment and API credentials:

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('use_your_merchant_id');
Braintree_Configuration::publicKey('use_your_public_key');
Braintree_Configuration::privateKey('use_your_private_key');

BraintreeGateway gateway = new BraintreeGateway(
  Environment.SANDBOX,
  "your_merchant_id",
  "your_public_key",
  "your_private_key"
);

BraintreeGateway gateway = new BraintreeGateway(
  Environment.PRODUCTION,
  "YOUR_PRODUCTION_MERCHANT_ID",
  "YOUR_PRODUCTION_PUBLIC_KEY",
  "YOUR_PRODUCTION_PRIVATE_KEY"
);
https://developers.braintreepayments.com/reference/request/transaction/sale/java#credit_card

TransactionRequest request = new TransactionRequest()
 .amount(new BigDecimal("10.00"))
 .orderId("order id")
 .merchantAccountId("a_merchant_account_id")
 .paymentMethodNonce(nonceFromTheClient)
 .customer()
   .firstName("Drew")
   .lastName("Smith")
   .company("Braintree")
   .phone("312-555-1234")
   .fax("312-555-1235")
   .website("http://www.example.com")
   .email("drew@example.com")
   .done()
 .billingAddress()
   .firstName("Paul")
   .lastName("Smith")
   .company("Braintree")
   .streetAddress("1 E Main St")
   .extendedAddress("Suite 403")
   .locality("Chicago")
   .region("IL")
   .postalCode("60622")
   .countryCodeAlpha2("US")
   .done()
 .shippingAddress()
   .firstName("Jen")
   .lastName("Smith")
   .company("Braintree")
   .streetAddress("1 E 1st St")
   .extendedAddress("Suite 403")
   .locality("Bartlett")
   .region("IL")
   .postalCode("60103")
   .countryCodeAlpha2("US")
   .done()
 .options()
   .submitForSettlement(true)
   .done();

Result<Transaction> result = gateway.transaction().sale(request);
jbrookins13 commented 5 years ago

https://developers.braintreepayments.com/reference/request/customer/create/java#customer-with-a-payment-method-and-billing-address

jasonbrookins commented 5 years ago

Testing values: https://developers.braintreepayments.com/reference/general/testing/java

https://developers.braintreepayments.com/reference/client-reference/javascript/v2/best-practices#custom-ui

https://articles.braintreepayments.com/get-started/currencies https://developers.braintreepayments.com/reference/general/currencies

jbrookins13 commented 5 years ago

https://developers.braintreepayments.com/start/hello-client/javascript/v3

jbrookins13 commented 5 years ago

https://articles.braintreepayments.com/risk-and-security/compliance/pci-compliance https://tokenex.com/enough-of-pci-how-do-we-get-our-company-out-of-scope/ https://www.pcisecuritystandards.org/document_library?category=saq&document=saq

jbrookins13 commented 5 years ago

https://stackoverflow.com/questions/52426708/braintree-cant-generate-paymentmethodnonce-without-braintree-dropin-lib

jasonbrookins commented 5 years ago

Authorization Exception: https://stackoverflow.com/questions/15650445/braintree-api-throws-braintree-exceptions-authorizationexception-on-createcard-c

jasonbrookins commented 5 years ago

The /api/gateway/braintree.cfc has been rewritten to use the Java SDK 2.96.0.

jasonbrookins commented 5 years ago

Files to be updated:

api/core.cfc 
api/gateway/base.cfc
api/gateway/braintree/braintree.cfc
api/model/creditcard.cfc
jars/braintreeTest.cfm2.96.0.jar

Update: These files have been added to CFPayment, so they are, in theory, ready to be utilized (after minor testing).

jasonbrookins commented 5 years ago

@jazzjeff : The steps for setting up a production Braintree account are here: https://developers.braintreepayments.com/start/go-live/

The CFPayment Braintree gateway needs this information below PLUS the "Merchant Account ID" (which is the user-generated name for the account, not to be confused with the "Merchant ID" which is a number generated by Braintree) (see admin screenshot). The environment will be "Sandbox" if TestMode is set to true for the payment processor; otherwise it will be "Production":

BraintreeGateway gateway = new BraintreeGateway(
  Environment.PRODUCTION,
  "YOUR_PRODUCTION_MERCHANT_ID",
  "YOUR_PRODUCTION_PUBLIC_KEY",
  "YOUR_PRODUCTION_PRIVATE_KEY"
);

The admin screen for the Braintree payment processor looks like this (currently with my Sandbox credentials):

Screen Shot 2019-06-11 at 5 04 13 PM

The Braintree admin area where this information can be found looks like this (at least for my Sandbox account):

Screen Shot 2019-06-11 at 5 08 32 PM

jasonbrookins commented 5 years ago

@jazzjeff : Their documents say this about testing the production account:

"It is important to test your production account by creating a couple of low-value sale transactions for each of the payment method types you plan to accept. Be sure to submit the transactions for settlement (Note: we mark them for settlement automatically), and then confirm that the funds have deposited into your bank account. This typically happens a few days after they have settled."