webdna / commerce-braintree

Braintree gateway for Craft Commerce
Other
2 stars 11 forks source link

Error when trying to make a payment #52

Open angieherrera opened 1 year ago

angieherrera commented 1 year ago

Hi!

I have successfully installed this plugin on a Craft 4.5.5 / Commerce 4.3.0 set up. However, whenever I try to make a payment, I get the following error:

TypeError
webdnalcommercelbraintree|responses|PaymentResponse:_construct(): Argument #1 (Sdata) must be of type array, Braintree|Result Error given, called in /[my]/[path]/[to]/vendor/webdna/commerce-braintree/src/gateways/Gateway.php on line 516

Full screenshot: 231014-1

The code to render the form looks like this:

<form id="paymentForm" method="post" action="">
   {{ csrfInput() }}
   {{ actionInput('commerce/payments/pay') }}
   {{ redirectInput('/store/checkout/order?number={number}') }}
   {{ hiddenInput('cancelUrl', '/store/checkout/payment'|hash) }}
   {{ hiddenInput('orderEmail', cart.email) }}

   {% namespace cart.gateway.handle|commercePaymentFormNamespace %}
      {{ cart.gateway.getPaymentFormHtml({})|raw }}
   {% endnamespace %}

   <button class="btn secondary">Pay Now</button>
</form>

That renders like so (note missing CVV field): CleanShot 2023-10-16 at 09 32 25

I'm not sure what, if anything, needs to be adjusted in my code, or if this is an issue with the plugin.

Thank you!

smockensturm commented 1 year ago

Same. Is this gateway no longer supported?

jalendport commented 1 year ago

I ran into this as well, and evidently there are several newer beta versions of this plugin that somehow Craft doesn't know about (I'll poke P&T and have them check into why that is happening). In the meantime, make sure the line in your composer.json is updated to "webdna/commerce-braintree": "^3.0.0-beta.1" (note the presence of the ^ which means Composer isn't version locked to beta.1), and then run a composer update. The latest beta at the time of this comment is beta.11, and updating to that fixed my errors.

@angieherrera also fwiw, if you update the SDK versions in the gateway settings to the latest available, particularly the "Drop-in UI SDK Version", you'll want to make sure your "Pay Now" button has the type="submit" attribute, or it won't load the payment form on the frontend.

In order to get the CVV field showing up in the payment form on the frontend, you'll want to make sure you set up some CVV rules in your Braintree dashboard per https://developer.paypal.com/braintree/docs/guides/drop-in/setup-and-integration/javascript/v3/#credit-cards (see also: https://developer.paypal.com/braintree/articles/guides/fraud-tools/basic/avs-cvv-rules).

smockensturm commented 1 year ago

Awesome. Yeah, we chased it down and we're operational. But this is very helpful. Thank you.