-
Notifications
You must be signed in to change notification settings - Fork 139
Description
I've a working Braintree PayPal integration, meaning that I can tokenize payment and create transaction. It's pretty much the same code as presented in the guide (https://developer.paypal.com/braintree/docs/guides/paypal/checkout-with-paypal/javascript/v3/#invoking-the-checkout-with-paypal-flow).
I'm passing Braintree Client Token as "authorization" while creating Braintree Client, and then pass that client instance to create PayPal Checkout component, and finally load PayPal SDK by calling the loadPayPalSDK method on the PayPal Checkout instance. Again, same way as in the guide.
// Create a client.
braintree.client.create({
authorization: 'braintree-client-token'
}).then(function (clientInstance) {
// Create a PayPal Checkout component.
return braintree.paypalCheckout.create({
client: clientInstance
});
}).then(function (paypalCheckoutInstance) {
return paypalCheckoutInstance.loadPayPalSDK({
currency: 'USD',
intent: 'capture'
});
}).then(function (paypalCheckoutInstance) {
return paypal.Buttons({
fundingSource: paypal.FUNDING.PAYPAL,
createOrder: function () {
return paypalCheckoutInstance.createPayment({...});
},
onApprove: function (data, actions) {
return paypalCheckoutInstance.tokenizePayment(data).then(function (payload) {
// Submit 'payload.nonce' to your server
});
},
onCancel: function (data) {
console.log('PayPal payment cancelled', JSON.stringify(data, 0, 2));
},
onError: function (err) {
console.error('PayPal error', err);
}
}).render('#paypal-button');
});However, I have noticed that whenever on the server-side I generate Braintree Client Token by passing Merchant Account ID (as opposed to not passing this parameter at all, and I guess using default merchant), I'm getting following warnings in browser console after clicking the PayPal button. https://www.sandbox.paypal.com/smart/buttons is the source of these warnings. I'm omitting some sensitive details in logs.
smart_button_validation_error_derived_payee_transaction_mismatch
{
"payees": "[{\"merchantId\":\"AAA\",\"email\":{\"stringValue\":\"biller-xyz@example.com\"}}]",
"merchantID": "[\"BBB\"]",
"referer": "www.sandbox.paypal.com",
"sdkCorrelationID": "prebuild",
"sessionID": "1b[redacted]0f",
"clientID": "AS-[redacted]-d4",
"env": "sandbox",
"sdkVersion": "5.0.468"
}smart_button_validation_error_derived_payee_transaction_mismatch_sandbox
smart_button_validation_error_payee_no_match
Payee(s) passed in transaction does not match expected merchant id. Please ensure you are passing merchant-id=AAA or merchant-id=biller-xyz@example.com to the sdk url.
Like I've said, everything seems to be working, but I'm wondering what is the impact of these warnings.
- Do they need to be fixed? I know how to do it - by passing
merchant-idto theloadPayPalSDKmethod. But unfortunately, I don't have access to merchant ID value, or even know where it comes from. I only have access to Merchant Account ID. - Shouldn't
braintree-webitself handle passing correct merchant IDs and/or merchant account IDs around? After all documentation does not mention that we might need to do it ourselves. The only thing that is mentioned, is that if you load PayPal SDK manually with script tag (which I do not), you need to pass the client ID. - Without the fix, PayPal SDK gets loaded from https://www.paypal.com/sdk/js with client ID, but without merchant ID.
Bonus question: Does Merchant Account ID affect payment method tokenization? I had another problem where the same Braintree Client Token (without merchant account ID) worked for creating Google Pay transactions, but not for PayPal.