webdna / commerce-braintree Goto Github PK
View Code? Open in Web Editor NEWBraintree gateway for Craft Commerce
License: Other
Braintree gateway for Craft Commerce
License: Other
Hi there,
We recently had a bug brought to our attention by a customer. They tried to purchase with the country set as "Slovak Republic". Which is the default naming convention in Craft Commerce, as well as the official name of the country, however it didn't work. Braintree return response is "Country name is not an accepted country." Braintree expects "Slovakia".
I confirmed this bug locally. And "fixed" the bug by changing the name in Craft Commerce to "Slovakia".
The same happens for places like South Korea. BT expects "Korea, South" but Craft uses "Korea (South). And I'm sure there are others.
I realize I could, and probably should, go through the BT docs for the country names they expect and then cross reference the differences in Craft Commerce, then update in Craft accordingly. However I still wanted to bring this to your attention. Because I'm sure other people using the plugin, whether current or future, will potentially run into this same issue.
Perhaps this could be avoided by using the "Alpha-2 code" instead of the full country name. But I'm not sure what a change like that would entail from the plugin POV and whether a change like that would break integrations that people currently have developed.
At the minimum it should be mentioned in the README / docs for the plugin that country names in Craft Commerce need to match what BT needs to prevent issues like this.
Thanks ๐
EDIT:
I've created a Google Sheet to help find the mismatches between CC and BT.
EDIT 2:
Something to keep in mind, it seems like country names aren't part of the project config.
I'm currently investigating options for a new Craft Commerce v4 build.
Does this payment gateway support purchasing a subscription product and one-off products in the same cart, i.e. the same transaction? Or do subscriptions need to be handled separately from one-off purchases?
Recently we received a support request from a customer claiming to be double charged. I was able to figure out how it happened to them.
If the user enters a postal code with invalid characters like 12345-____
, they can proceed to payment and submit payment via the Drop-in UI (I realize I need to build in validation to prevent users from progressing to the next checkout step).
First attempt with invalid postal code results in this, which should be expected. Not sure why the error message is tripled.
Here's the gateway response from the transaction details
{
"errors": [
[],
[],
[]
],
"params": {
"transaction": {
"type": "sale",
"amount": "59",
"orderId": "REDACTED_ORDER_ID",
"options": {
"submitForSettlement": "true"
},
"customer": {
"firstName": "Zack",
"lastName": "Spear",
"email": "REDACTED"
},
"paymentMethodNonce": "tokencc_OI_WHY_IS_THIS_A_NONCE_LOL",
"merchantAccountId": "REDACTED_ID_GOES_HERE",
"billing": {
"firstName": "zack",
"lastName": "spear",
"company": "Test",
"streetAddress": "2345 Test St.",
"extendedAddress": null,
"locality": "Testville",
"region": "OR",
"postalCode": "97217-____",
"countryCodeAlpha2": "US"
},
"shipping": {
"firstName": "zack",
"lastName": "spear",
"company": "Test",
"streetAddress": "2345 Test St.",
"extendedAddress": null,
"locality": "Testville",
"region": "OR",
"postalCode": "97217-____",
"countryCodeAlpha2": "US"
}
}
},
"message": "Postal code can only contain letters, numbers, spaces, and hyphens.\nPostal code can only contain letters, numbers, spaces, and hyphens.\nPostal code can only contain letters, numbers, spaces, and hyphens.",
"creditCardVerification": null,
"transaction": null,
"subscription": null,
"merchantAccount": null,
"verification": null
}
After going back to the user info form and correcting the postal code then coming back to the payment form, upon submission the form responds with this error:
Now from the user's perspective the transaction failed. However, looking at the order details in the CMS & in Braintree, this attempt succeeds.
Gateway response for the success. Seems to be missing some information.
{
"success": true,
"transaction": {
"id": "[REDACTED]",
"status": "submitted_for_settlement",
"type": "sale",
"currencyIsoCode": "USD",
"amount": "59.00",
"merchantAccountId": "[REDACTED]",
"subMerchantAccountId": null,
"masterMerchantAccountId": null,
"orderId": "[REDACTED]",
"createdAt": {
"date": "2021-02-26 21:40:02.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updatedAt": {
"date": "2021-02-26 21:40:04.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"customer": {
"id": null,
"firstName": "Zack",
"lastName": "Spear",
"company": null,
"email": "[REDACTED]",
"website": null,
"phone": null,
"fax": null
},
"billing": {
"id": null,
"firstName": "zack",
"lastName": "spear",
"company": "Test",
"streetAddress": "2345 Test St.",
"extendedAddress": null,
"locality": "Testville",
"region": "OR",
"postalCode": "97217-1234",
"countryName": "United States of America",
"countryCodeAlpha2": "US",
"countryCodeAlpha3": "USA",
"countryCodeNumeric": "840"
},
"refundId": null,
"refundIds": [],
"refundedTransactionId": null,
"partialSettlementTransactionIds": [],
"authorizedTransactionId": null,
"settlementBatchId": null,
"shipping": {
"id": null,
"firstName": "zack",
"lastName": "spear",
"company": "Test",
"streetAddress": "2345 Test St.",
"extendedAddress": null,
"locality": "Testville",
"region": "OR",
"postalCode": "97217-1234",
"countryName": "United States of America",
"countryCodeAlpha2": "US",
"countryCodeAlpha3": "USA",
"countryCodeNumeric": "840"
},
"customFields": null,
"avsErrorResponseCode": null,
"avsPostalCodeResponseCode": "M",
"avsStreetAddressResponseCode": "N",
"cvvResponseCode": "M",
"gatewayRejectionReason": null,
"processorAuthorizationCode": "[REDACTED]",
"processorResponseCode": "1000",
"processorResponseText": "Approved",
"additionalProcessorResponse": null,
"voiceReferralNumber": null,
"purchaseOrderNumber": null,
"taxAmount": null,
"taxExempt": false,
"scaExemptionRequested": null,
"processedWithNetworkToken": false,
"creditCard": {
"token": null,
"bin": "[REDACTED]",
"last4": "[REDACTED]",
"cardType": "Visa",
"expirationMonth": "[REDACTED]",
"expirationYear": "[REDACTED]",
"customerLocation": "US",
"cardholderName": "Zack Spear",
"imageUrl": "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=production",
"prepaid": "No",
"healthcare": "No",
"debit": "No",
"durbinRegulated": "No",
"commercial": "No",
"payroll": "No",
"issuingBank": "[REDACTED]",
"countryOfIssuance": "USA",
"productId": "A",
"globalId": null,
"accountType": null,
"uniqueNumberIdentifier": null,
"venmoSdk": false
},
"statusHistory": [
[],
[]
],
"planId": null,
"subscriptionId": null,
"subscription": {
"billingPeriodEndDate": null,
"billingPeriodStartDate": null
},
"addOns": [],
"discounts": [],
"descriptor": [],
"recurring": false,
"channel": null,
"serviceFeeAmount": null,
"escrowStatus": null,
"disbursementDetails": [],
"disputes": [],
"authorizationAdjustments": [],
"paymentInstrumentType": "credit_card",
"processorSettlementResponseCode": null,
"processorSettlementResponseText": null,
"networkResponseCode": "00",
"networkResponseText": "Successful approval/completion or V.I.P. PIN verification is successful",
"riskData": {
"id": null,
"decision": "Not Evaluated",
"fraudServiceProvider": "fraud_protection"
},
"threeDSecureInfo": null,
"shipsFromPostalCode": null,
"shippingAmount": null,
"discountAmount": null,
"networkTransactionId": "[REDACTED]",
"processorResponseType": "approved",
"authorizationExpiresAt": {
"date": "2021-03-05 21:40:04.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"retryIds": [],
"retriedTransactionId": null,
"refundGlobalIds": [],
"partialSettlementTransactionGlobalIds": [],
"refundedTransactionGlobalId": null,
"authorizedTransactionGlobalId": null,
"globalId": "[REDACTED]",
"retryGlobalIds": [],
"retriedTransactionGlobalId": null,
"retrievalReferenceNumber": null,
"installmentCount": null,
"installments": [],
"refundedInstallments": [],
"responseEmvData": null,
"acquirerReferenceNumber": null,
"merchantIdentificationNumber": "[REDACTED]",
"terminalIdentificationNumber": "[REDACTED]",
"merchantName": "[REDACTED]",
"merchantAddress": {
"streetAddress": null,
"locality": "ANAHEIM",
"region": "CA",
"postalCode": "[REDACTED]",
"phone": "[REDACTED]"
},
"pinVerified": false,
"creditCardDetails": [],
"customerDetails": [],
"billingDetails": [],
"shippingDetails": [],
"subscriptionDetails": [],
"graphQLId": "[REDACTED]"
}
}
This failure also results in our order email failing as the custom template relies on paymentInstrumentType
to display the payment type of CC or PayPayl.
Job data from failed email
{
"orderId": 103621,
"orderData": {
"number": "[REDACTED]",
"reference": "[REDACTED]",
"couponCode": null,
"isCompleted": true,
"dateOrdered": {
"date": "2/26/2021",
"time": "1:40 PM"
},
"datePaid": {
"date": "2/26/2021",
"time": "1:40 PM"
},
"dateAuthorized": null,
"currency": "USD",
"gatewayId": 2,
"lastIp": "[REDACTED]",
"message": null,
"returnUrl": "/order?num=[REDACTED]",
"cancelUrl": "/checkout/payment",
"orderStatusId": "1",
"orderLanguage": "en-US",
"orderSiteId": 1,
"origin": "web",
"billingAddressId": null,
"shippingAddressId": "100058",
"makePrimaryShippingAddress": null,
"makePrimaryBillingAddress": null,
"shippingSameAsBilling": null,
"billingSameAsShipping": null,
"estimatedBillingAddressId": null,
"estimatedShippingAddressId": null,
"estimatedBillingSameAsShipping": null,
"shippingMethodHandle": "freeShipping",
"shippingMethodName": "Free Shipping",
"customerId": 3,
"registerUserOnOrderComplete": null,
"paymentSourceId": null,
"storedTotalPrice": 59,
"storedTotalPaid": 0,
"storedItemTotal": 59,
"storedItemSubtotal": 0,
"storedTotalShippingCost": 0,
"storedTotalDiscount": 0,
"storedTotalTax": 0,
"storedTotalTaxIncluded": 0,
"id": 103621,
"tempId": null,
"draftId": null,
"revisionId": null,
"uid": "[REDACTED]",
"siteSettingsId": 106048,
"fieldLayoutId": 48,
"contentId": 50367,
"enabled": true,
"archived": false,
"siteId": 1,
"title": null,
"slug": null,
"uri": null,
"dateCreated": {
"date": "12/5/2020",
"time": "1:16 PM"
},
"dateUpdated": {
"date": "2/26/2021",
"time": "1:40 PM"
},
"dateDeleted": null,
"trashed": false,
"propagateAll": false,
"newSiteIds": [],
"resaving": false,
"duplicateOf": null,
"previewing": false,
"hardDelete": false,
"ref": null,
"status": "enabled",
"structureId": null,
"url": null,
"guid": "[REDACTED]",
"guidType": "Trial",
"deviceCountOrder": "1",
"customerType": "Business",
"confirmEmail": "[REDACTED]",
"oemCustomerFirstName": null,
"oemCustomerLastName": null,
"oemCustomerEmail": "",
"referral": null,
"referralOther": null,
"newsletterSignupOld": null,
"newsletterSignup": false,
"fromRegistrationWizard": "letsBoogie",
"registrationWizardSite": "[REDACTED]",
"adjustmentSubtotal": 0,
"adjustmentsTotal": 0,
"paymentCurrency": "USD",
"email": "[REDACTED]",
"isPaid": true,
"itemSubtotal": 59,
"itemTotal": 59,
"lineItems": [
{
"id": 58689,
"weight": 0,
"length": 0,
"height": 0,
"width": 0,
"qty": 1,
"note": "",
"privateNote": "",
"purchasableId": "5479",
"orderId": 103621,
"lineItemStatusId": null,
"taxCategoryId": 1,
"shippingCategoryId": 1,
"dateCreated": "2021-02-26T13:22:24-08:00",
"dateUpdated": "2021-02-26T13:40:04-08:00",
"adjustments": [],
"description": "Basic",
"options": {
"FlashGUID": "[REDACTED]",
"FlashGUIDParam": "[REDACTED]",
"deviceCountOrder": "1"
},
"optionsSignature": "[REDACTED]",
"onSale": false,
"price": 59,
"saleAmount": 0,
"salePrice": 59,
"sku": "new-basic",
"total": 59,
"priceAsCurrency": "$59.00",
"saleAmountAsCurrency": "$0.00",
"salePriceAsCurrency": "$59.00",
"subtotalAsCurrency": "$59.00",
"totalAsCurrency": "$59.00",
"discountAsCurrency": "$0.00",
"shippingCostAsCurrency": "$0.00",
"taxAsCurrency": "$0.00",
"taxIncludedAsCurrency": "$0.00",
"adjustmentsTotalAsCurrency": "$0.00",
"subtotal": 59
}
],
"orderAdjustments": [],
"outstandingBalance": 0,
"paidStatus": "paid",
"recalculationMode": "none",
"shortNumber": "4e25621",
"totalPaid": 59,
"total": 59,
"totalPrice": 59,
"totalQty": 1,
"totalSaleAmount": 0,
"totalTaxablePrice": 59,
"totalWeight": 0,
"adjustmentSubtotalAsCurrency": "$0.00",
"adjustmentsTotalAsCurrency": "$0.00",
"itemSubtotalAsCurrency": "$59.00",
"itemTotalAsCurrency": "$59.00",
"outstandingBalanceAsCurrency": "$0.00",
"totalPaidAsCurrency": "$59.00",
"totalAsCurrency": "$59.00",
"totalPriceAsCurrency": "$59.00",
"totalSaleAmountAsCurrency": "$0.00",
"totalTaxablePriceAsCurrency": "$59.00",
"totalTaxAsCurrency": "$0.00",
"totalTaxIncludedAsCurrency": "$0.00",
"totalShippingCostAsCurrency": "$0.00",
"totalDiscountAsCurrency": "$0.00",
"storedTotalPriceAsCurrency": "$59.00",
"storedTotalPaidAsCurrency": "$0.00",
"storedItemTotalAsCurrency": "$59.00",
"storedItemSubtotalAsCurrency": "$0.00",
"storedTotalShippingCostAsCurrency": "$0.00",
"storedTotalDiscountAsCurrency": "$0.00",
"storedTotalTaxAsCurrency": "$0.00",
"storedTotalTaxIncludedAsCurrency": "$0.00",
"paidStatusHtml": "<span class=\"commerceStatusLabel\"><span class=\"status green\"></span> Paid</span>",
"customerLinkHtml": "<span><a href=\"https://unraid.net/admin/commerce/customers/3\">[REDACTED]</a></span>",
"orderStatusHtml": "<span class=\"commerceStatusLabel\"><span class=\"status green\"></span> New</span>",
"totalTax": 0,
"totalTaxIncluded": 0,
"totalShippingCost": 0,
"totalDiscount": 0
},
"commerceEmailId": "1",
"orderHistoryId": 44294,
"description": null
}
I plan to build in validation to prevent postal code issues in the first place. However, I wanted to bring attention to the fact that even with a correction to the postal code we're hitting this issue.
If you need more information please let me know.
Thanks in advance.
It would be great if the inputs for the plugin configuration could be switched to the autosuggestField instead of of the textField. This would allow environment settings to be used.
https://docs.craftcms.com/v3/extend/environmental-settings.html#autosuggest-inputs
{% from "_includes/forms" import autosuggestField, lightswitchField %}
{{ autosuggestField({
label: 'Merchant Id'|t('commerce'),
id: 'merchantId',
class: 'ltr',
name: 'merchantId',
value: gateway.merchantId,
errors: gateway.getErrors('merchantId'),
suggestEnvVars: true
}) }}
{{ autosuggestField({
label: 'Public Key'|t('commerce'),
id: 'publicKey',
class: 'ltr',
name: 'publicKey',
value: gateway.publicKey,
errors: gateway.getErrors('publicKey'),
suggestEnvVars: true,
}) }}
{{ autosuggestField({
label: 'Private Key'|t('commerce'),
id: 'privateKey',
class: 'ltr',
name: 'privateKey',
value: gateway.privateKey,
errors: gateway.getErrors('privateKey'),
suggestEnvVars: true
}) }}
The plugin could then use the parseEnv method in Craft to retrieve the setting.
https://docs.craftcms.com/v3/extend/environmental-settings.html
Craft::parseEnv($this->merchantId)
This would also the public / private keys to be set via environment variables rather than them being stored in the project config like it is currently.
Hello,
We're trying to setup a test in to use Braintree using the plug-in. The initialisation of the drop-in fails with a PayPal-related error "A linked PayPal Sandbox account is required to use PayPal ". We don't want to use Paypal anyway so is there a way to disable that initialisation?
The documentation mentions a getPaymentFormHtml()
method that can be used to customise the initialisation of the drop-in. How can we access this method? Is it a javascript method, is it available in the plug-in's php files?
Apologies for the newbie questions. Looking forward to your help.
#13 fixes this.
Will this plugin be upgraded for Craft 4?
Thanks for the plugin!
I'm unfortunately having some issues. When calling the default getPaymentFormHtml()
method to get the Drop-in UI I am unable to get the PayPal payment option to work.
Clicking the blue PayPal button will trigger the PayPal popup window to appear but then it quickly disappears and an error displays in the Drop-in UI, "Something went wrong on our end." and a few errors are logged in the console.
I am on the current latest versions
Please let me know if I need to provide additional info. Thanks in advance.
Are there any plans to add support for collecting device data for use in Premium Management Tools?
I imagine it would be an opt-in feature people could enable in their configs.
On the front-end, it looks like following the instructions in the first link could be added to the templates for DropIn UI or hosted fields. The a field add to the BasePaymentForm. And then lastly, adding the prop to the transaction.
It looks like someone at least thought about this, as the deviceData field is commented out.
I'm currently not able to get a successful payment submission unless I'm 1) Signed into my CMS account and 2) even when I'm signed in an address is required. Both of which I can't have as we're only having a guest checkout and address isn't required for every customer type as we're selling Digital Products which aren't physically shipped.
I've successfully tested payments with the Braintree gateway disabled and the built-in Dummy gateway enabled. So this makes me believe the issue is coming from this plugin.
When I'm not signed in the error I receive when submitting is:
Unable to make payment at this time.
When an address is not set on the cart the error I receive when submitting is:
Trying to get property 'iso' of non-object
I'm using the Drop-in UI provided by the plugin via getPaymentFormHtml()
.
Happy to provide any additional info you need from me.
Thanks in advance ๐
Setting a site in Craft to Chinese, locale zh
, results in the Drop-in UI not rending.
French, German, & Spanish work just fine.
Here's a low level example of it working: https://codepen.io/zackspear/pen/JjbaYzV
Craft Commerce release 3.3.0 - 2021-04-20
Deprecated craft\commerce\services\Gateways::getGatewayOverrides() and the commerce-gateways.php config file. Gateway-specific config files should be used instead. (#1963)
From BrainTree support
If your integration is utilizing the Drop-in UI, the CVV field should appear https://developer.paypal.com/braintree/docs/guides/drop-in/setup-and-integration/javascript/v3#credit-cards immediately and automatically once any CVV rule is enabled in your gateway.
Is this accurate? Does the drop-in widget via your plugin honor these additional fields?
{{ cart.gateway.getPaymentFormHtml({})|raw }}
To avoid user confusion the drop-in ui submit payment button should remain disabled until a payment method is added.
#12 fixes this issue by removing the reset function before the conditionals that check whether or not the button should be reset.
When I try creating a gateway of type "Braintree" (regardless of the settings I enter), I'm getting the following error:
2020-03-24 23:58:46 [-][1][2epl5p5fb84p5cl7pgkh04g6ae][info][application] Unexpected data encountered in config data - Braintree\Gateway Object
(
[config] => Braintree\Configuration Object
(
[_environment:Braintree\Configuration:private] => production
[_merchantId:Braintree\Configuration:private] =>
[_publicKey:Braintree\Configuration:private] =>
[_privateKey:Braintree\Configuration:private] =>
[_clientId:Braintree\Configuration:private] =>
[_clientSecret:Braintree\Configuration:private] =>
[_accessToken:Braintree\Configuration:private] =>
[_proxyHost:Braintree\Configuration:private] =>
[_proxyPort:Braintree\Configuration:private] =>
[_proxyType:Braintree\Configuration:private] =>
[_proxyUser:Braintree\Configuration:private] =>
[_proxyPassword:Braintree\Configuration:private] =>
[_timeout:Braintree\Configuration:private] => 60
[_sslVersion:Braintree\Configuration:private] =>
[_acceptGzipEncoding:Braintree\Configuration:private] => 1
)
[graphQLClient] => Braintree\GraphQLClient Object
(
[_service] => Braintree\GraphQL Object
(
[_config:protected] => Braintree\Configuration Object
(
[_environment:Braintree\Configuration:private] => production
[_merchantId:Braintree\Configuration:private] =>
[_publicKey:Braintree\Configuration:private] =>
[_privateKey:Braintree\Configuration:private] =>
[_clientId:Braintree\Configuration:private] =>
[_clientSecret:Braintree\Configuration:private] =>
[_accessToken:Braintree\Configuration:private] =>
[_proxyHost:Braintree\Configuration:private] =>
[_proxyPort:Braintree\Configuration:private] =>
[_proxyType:Braintree\Configuration:private] =>
[_proxyUser:Braintree\Configuration:private] =>
[_proxyPassword:Braintree\Configuration:private] =>
[_timeout:Braintree\Configuration:private] => 60
[_sslVersion:Braintree\Configuration:private] =>
[_acceptGzipEncoding:Braintree\Configuration:private] => 1
)
[_useClientCredentials:Braintree\Http:private] =>
)
)
)
Versions
Craft CMS: 3.4.10.1
Craft Commerce: 3.0.12
Braintree for Craft Commerce: 2.3.4
My employer is in the process of switching to Braintree with a PayPal integration and I'm seeing the same issue as #6.
Control Panel payment gateway modal is wonky.
The gateway (in our case Braintree) fails to instantiate on subsequent modal opening. Fields appear but dead.
Refresh the page and pop it again (first time) and the fields will initialize.
we do get the "harmless" console warning "Double-instantiating a menu button on an element" from garnish.js
Amazon S3 1.2.15
Aws serverless image handler 1.1.4
Braintree for Craft Commerce 2.4.0
Colour Swatches 1.4.2
Control Panel CSS 2.3.1
Craft Commerce 3.4.2
Feed Me 4.4.0
Gift Voucher 2.6.1
Klaviyo Connect 4.0.6
oEmbed 1.3.12
Redactor 2.8.8
SEOMate 1.1.11
ShipStation Connect 1.3.6
Sprig 1.8.1
Stamped 1.0.1
Super Table 2.6.8
Tags 1.0.7
Typed link field 1.0.25
After updating to Craft Commerce 2.2 we are now receiving this error from this plugin:
Class kuriousagency\commerce\braintree\gateways\Gateway contains 3 abstract methods
and must therefore be declared abstract or implement the remaining methods
(craft\commerce\base\SubscriptionGatewayInterface::getHasBillingIssues,
craft\commerce\base\SubscriptionGatewayInterface::getBillingIssueDescription,
craft\commerce\base\SubscriptionGatewayInterface::getBillingIssueResolveFormHtml)
Looks like those methods just need to be implemented in your Gateway.
In the Braintree dashboard do you know if there's a way to submit the user details (name & email, craft order/reference #, etc.) as a part of the "Customer Info" for the transaction? Currently blank for both address and address-less transactions. This way we can cross reference orders within Craft Commerce to Braintree if need be.
Cheers
Env
craftcms/cms 3.4.15
craftcms/commerce 3.1.2
kuriousagency/commerce-braintree 2.3.5
Steps to reproduce
Expected
Field "EUR Merchant Account Id"
Actual
No field for Merchant Account Id
Hint
After clicking "Save" button the value for "merchantAccountId" is set to NULL (See project.yaml)
Possible Solution
Remove condition "{% if currencies|length > 1 %}" in src/templates/gatewaySettings.twig
I'm unable to process payments via Braintree in the CMS or on the frontend using the default craft templates.
When creating an order in the frontend using the default craft commerce templates the braintree-ui components load fine and it accepts the payment method.
But the submit button remains disabled after the first click and doesn't redirect to the order success route.
If I then try and process the payment in the CMS the following happens:
If I re-try the payment it continues to fail.
Hello,
I have setup the plugin using sandbox credentials. The drop-in appears as expected (with a Paypal not linked error). I select "Credit card" and then enter the test credit card details and the card seems to be tokenised without a problem but the "Purchase" button is disabled so I cannot complete the transaction.
Can you please help?
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
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):
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!
Hi!
Is this plugin compatible with Craft Commerce 3?
When I try to upgrade to the latest version I get the following output:
Performing update with Composer ... error: An error occurred
Output:
<warning>Package "craftcms/vue-asset" listed for update is not installed. Ignoring.</warning>
<warning>Package "danielstjules/stringy" listed for update is not installed. Ignoring.</warning>
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- kuriousagency/commerce-braintree 2.3.2 requires craftcms/commerce ^2.0.0-beta.12 -> satisfiable by craftcms/commerce[2.2.15, 2.2.14, 2.2.13, 2.2.12, 2.2.11, 2.2.10, 2.2.9, 2.2.8, 2.2.7, 2.2.6, 2.2.5, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.13, 2.1.12.1, 2.1.12, 2.1.11, 2.1.10, 2.1.9, 2.0.0-beta.12, 2.0.0-beta.12.1, 2.0.0-beta.13, 2.0.0-beta.13.1, 2.0.0-beta.14, 2.0.0-beta.15, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.0.1, 2.1.0.2, 2.1.1, 2.1.1.1, 2.1.2, 2.1.3, 2.1.3.1, 2.1.4, 2.1.5, 2.1.5.1, 2.1.5.2, 2.1.6, 2.1.6.1, 2.1.7, 2.1.8] but these conflict with your requirements or minimum-stability.
- kuriousagency/commerce-braintree 2.3.2 requires craftcms/commerce ^2.0.0-beta.12 -> satisfiable by craftcms/commerce[2.2.15, 2.2.14, 2.2.13, 2.2.12, 2.2.11, 2.2.10, 2.2.9, 2.2.8, 2.2.7, 2.2.6, 2.2.5, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.13, 2.1.12.1, 2.1.12, 2.1.11, 2.1.10, 2.1.9, 2.0.0-beta.12, 2.0.0-beta.12.1, 2.0.0-beta.13, 2.0.0-beta.13.1, 2.0.0-beta.14, 2.0.0-beta.15, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.0.1, 2.1.0.2, 2.1.1, 2.1.1.1, 2.1.2, 2.1.3, 2.1.3.1, 2.1.4, 2.1.5, 2.1.5.1, 2.1.5.2, 2.1.6, 2.1.6.1, 2.1.7, 2.1.8] but these conflict with your requirements or minimum-stability.
- kuriousagency/commerce-braintree 2.3.2 requires craftcms/commerce ^2.0.0-beta.12 -> satisfiable by craftcms/commerce[2.2.15, 2.2.14, 2.2.13, 2.2.12, 2.2.11, 2.2.10, 2.2.9, 2.2.8, 2.2.7, 2.2.6, 2.2.5, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.13, 2.1.12.1, 2.1.12, 2.1.11, 2.1.10, 2.1.9, 2.0.0-beta.12, 2.0.0-beta.12.1, 2.0.0-beta.13, 2.0.0-beta.13.1, 2.0.0-beta.14, 2.0.0-beta.15, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.0.1, 2.1.0.2, 2.1.1, 2.1.1.1, 2.1.2, 2.1.3, 2.1.3.1, 2.1.4, 2.1.5, 2.1.5.1, 2.1.5.2, 2.1.6, 2.1.6.1, 2.1.7, 2.1.8] but these conflict with your requirements or minimum-stability.
- Installation request for kuriousagency/commerce-braintree 2.3.2 -> satisfiable by kuriousagency/commerce-braintree[2.3.2].
<warning>Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.</warning>
Fatal error: Uncaught Braintree\Exception\Authorization in C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\Util.php:66 Stack trace: #0 C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\Http.php(76): Braintree\Util::throwStatusCodeException(403) #1 C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\TransactionGateway.php(705): Braintree\Http->post('/merchants/3gv8...', Array) #2 C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\TransactionGateway.php(53): Braintree\TransactionGateway->_doCreate('/transactions', Array) #3 C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\TransactionGateway.php(429): Braintree\TransactionGateway->create(Array) #4 C:\xampp\htdocs\pmteacher\payment_checkout.php(31): Braintree\TransactionGateway->sale(Array) #5 {main} thrown in C:\xampp\htdocs\pmteacher\vendor\braintree\braintree_php\lib\Braintree\Util.php on line 66
On some projects the $ may lose its reference to jQuery in DropinUi.js
Braintree\Exception\Authentication in vendor/braintree/braintree_php/lib/Braintree/Util.php:56
Versions
Craft CMS: 3.4.10.1 (Pro Edition)
Craft Commerce: 3.0.12 (Lite Edition)
Braintree for Craft Commerce: 2.3.5
Hey there, we're very close to going live with the plugin so naturally we've been doing some thorough testing. When testing Braintree's "Card numbers for unsuccessful verification" I'm getting a successful transaction โ redirected to the thank you page with order details and in the CMS the transaction has a status of "Success".
I wouldn't imagine this to be what's supposed to happen. Or am I missing something here?
Any insight would be great.
Thanks in advance ๐
In the gateway settings stored in the project config, I would like to be able to set testMode
to an environment variable, e.g. $BRAINTREE_TEST_MODE
. It looks like Craft supports boolean strings ("true"
/ "false"
) in environment variables: craftcms/cms#3975
I would like to change the value of Merchant ID, Public Key and Private Key based on the environment (so locally they are set to the sandbox credentials, but on the production server they are set to the live ones), but that doesn't work if the value of "Test" has to be hardcoded in the project config.
I can do this only by editing the DropinUi.js file directly.
Getting the following error after updating to beta-2
:
DropinUi.js?v=1675350836:26 Uncaught TypeError: Cannot read properties of null (reading 'value')
at DropinUi.js?v=1675350836:26:53
at NodeList.forEach (<anonymous>)
at init (DropinUi.js?v=1675350836:23:37)
at check (DropinUi.js?v=1675350836:16:4)
at DropinUi.js?v=1675350836:20:4
at DropinUi.js?v=1675350836:187:3
This error is occurring because there are other forms on our payment page and DropinUi.js
is trying to access .value
attributes on a query that hasn't returned an element.
Because payment forms must now be namespaced, there's a different way the variables in DropinUi.js
could be populated without having to loop through every form element in the page. If you were to add data-handle="{{ gateway.handle }}
to the drop-in UI element in dropin-ui.twig
, you would then be able to use the handle to access the necessary elements directly in DropinUi.js
, e.g.
amount = document.querySelector('[name="paymentForm[' + $dropinUi.dataset.handle + '][amount]"]').value
Hi,
I purchased your Braintree for the Craft plugin app store in order to use it for subscriptions. I succesfully added Braintree as a gateway and I set it up using a Sand Box account.
The Sandbox account has currently 2 subscription plans.
When I go to Commerce > System Settings > Subscription Plans > +New Subscription plan , I get the following error. Can you please help?
Braintree\Exception\Authentication
1. in /path/to/mysite/vendor/braintree/braintree_php/lib/Braintree/Util.php at line 56
47484950515253545556575859606162636465 * @param string $statusCode HTTP status code to throw exception from
* @param null|string $message
* @throws Exception multiple types depending on the error
* @return void
*/
public static function throwStatusCodeException($statusCode, $message=null)
{
switch($statusCode) {
case 401:
throw new Exception\Authentication();
break;
case 403:
throw new Exception\Authorization($message);
break;
case 404:
throw new Exception\NotFound();
break;
case 426:
throw new Exception\UpgradeRequired();
2. in /path/to/mysite/vendor/braintree/braintree_php/lib/Braintree/Http.php at line 39 โ Braintree\Util::throwStatusCodeException(401)
33343536373839404142434445 public function get($path)
{
$response = $this->_doRequest('GET', $path);
if ($response['status'] === 200) {
return Xml::buildArrayFromXml($response['body']);
} else {
Util::throwStatusCodeException($response['status']);
}
}
public function post($path, $params = null)
{
$response = $this->_doRequest('POST', $path, $this->_buildXml($params));
3. in /path/to/mysite/vendor/braintree/braintree_php/lib/Braintree/PlanGateway.php at line 21 โ Braintree\Http::get('/merchants/x9n68q6x644s6gt3/plan...')
15161718192021222324252627 $this->_http = new Http($gateway->config);
}
public function all()
{
$path = $this->_config->merchantPath() . '/plans';
$response = $this->_http->get($path);
if (key_exists('plans', $response)){
$plans = ["plan" => $response['plans']];
} else {
$plans = ["plan" => []];
}
Attempting to create a new subscription and am receiving the following error:
craft\commerce\errors\PaymentSourceException: Customer ID is invalid. in /Users/Shared/Sites/abcdefg.com/vendor/kuriousagency/commerce-braintree/src/gateways/Gateway.php:257
Stack trace:
#0 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/commerce/src/services/PaymentSources.php(185): kuriousagency\commerce\braintree\gateways\Gateway->createPaymentSource(Object(kuriousagency\commerce\braintree\models\Payment), 16823)
#1 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/commerce/src/controllers/SubscriptionsController.php(217): craft\commerce\services\PaymentSources->createPaymentSource(16823, Object(kuriousagency\commerce\braintree\gateways\Gateway), Object(kuriousagency\commerce\braintree\models\Payment))
#2 [internal function]: craft\commerce\controllers\SubscriptionsController->actionSubscribe()
#3 /Users/Shared/Sites/abcdefg.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#4 /Users/Shared/Sites/abcdefg.com/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#5 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('subscribe', Array)
#6 /Users/Shared/Sites/abcdefg.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('subscribe', Array)
#7 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('commerce/subscr...', Array)
#8 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/cms/src/web/Application.php(565): craft\web\Application->runAction('commerce/subscr...', Array)
#9 /Users/Shared/Sites/abcdefg.com/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#10 /Users/Shared/Sites/abcdefg.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#11 /Users/Shared/Sites/abcdefg.com/web/index.php(21): yii\base\Application->run()
#12 {main}
This results in a message of "Unable to start the subscription. Please check your payment details." on the front end.
After contacting Braintree support, this is what they had to say:
At the moment the issues we're seeing on our server logs are that your customer ids are invalid. One such example of this invalid customer id is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxโ. The reason this ID in invalid is because it doesn't exist in your vault.
You've mentioned that you're using a plugin, there may be some configuration issue with it, however as Braintree don't develop plugins for any platform I don't have any insight as to what is causing the issue. Your best course of action would be to contact the developer of your plugin and mention the information I have provided you with.
Hi, I am planning to add Braintree subscription support to the gateway.
We placed the code into our payment form and doesn't get to the thank you page in Chrome.
Looked into it and In vendor/kuriousagency/commerce-braintree/src/assetbundles/dropinui/dist/js/DropinUi.js
on line 157 It uses jQuery to submit the form, this doesn't always work.
Changing this to $form[0].submit(); works for us
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.