solidusio / solidus_braintree

💳 Integrate Solidus with Braintree
https://www.braintreepayments.com/
BSD 3-Clause "New" or "Revised" License
19 stars 55 forks source link

Add device data to PayPal checkout #124

Closed gsmendoza closed 1 year ago

gsmendoza commented 1 year ago

Closes #120

Please note that at the moment there's no way to see the information about device data in Braintree for PayPal orders. They still recommend to send those information though, so that's what we are doing here.

gsmendoza commented 1 year ago

Hi @SyborgStudios ! I'm trying to add device data to the PayPal checkout flow, similar to your work in #103. Perhaps you can help me with this issue I'm having?

When I test PayPal checkout with this PR, I can confirm that the device data is saved in the PayPal SolidusBraintree::Source object of the transaction:

image

However, when I view the transaction made with this source object in Braintree, I can't find the Premium Fraud Management Tools Information section which should show if the transaction captured the device data. Here's a screenshot of the PayPal transaction in Braintree:

image

Compare this to the screenshot I took in https://github.com/solidusio/solidus_braintree/pull/116, where Braintree shows that it captured the device data of the Hosted Form transaction.

Do you have any idea why the Premium Fraud Management Tools Information section is not appearing on the PayPal transactions in Braintree? Do we need to configure anything in Braintree to enable Fraud Management specifically for PayPal checkout?

gsmendoza commented 1 year ago

Based on the log, it appears that Braintree is receiving the device data (see the [Braintree] <device-data>{"correlation_id":"9f34a0f46135b8922d1a907f74f59bf7"}</device-data> line below). However, unlike with credit card transactions, it's not returning a risk-data section in its transaction response:

Started PATCH "/checkout/update/confirm" for ::1 at 2023-03-14 14:04:36 +0800
Processing by CheckoutsController#update as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "accept_terms_and_conditions"=>"accepted", "state"=>"confirm"}

...

D, [2023-03-14T14:04:37.597630 #97584] DEBUG -- : [Braintree] [14/Mar/2023 06:04:37 UTC] POST /merchants/652zwb86tqk9v5wz/transactions
D, [2023-03-14T14:04:37.597716 #97584] DEBUG -- : [Braintree] <?xml version="1.0" encoding="UTF-8"?>
[Braintree] <transaction>
[Braintree]   <amount>26.24</amount>
[Braintree]   <order-id>R421881327-EAPHR9UT</order-id>
[Braintree]   <channel>Solidus</channel>
[Braintree]   <options>
[Braintree]     <store-in-vault-on-success type="boolean">true</store-in-vault-on-success>
[Braintree]   </options>
[Braintree]   <payment-method-token>31hv58g3</payment-method-token>
[Braintree]   <device-data>{"correlation_id":"9f34a0f46135b8922d1a907f74f59bf7"}</device-data>
[Braintree]   <shipping>
[Braintree]     <first-name>1</first-name>
[Braintree]     <last-name>Main St</last-name>
[Braintree]     <street-address>1 Main St 1 Main St</street-address>
[Braintree]     <locality>San Jose</locality>
[Braintree]     <postal-code>95131</postal-code>
[Braintree]     <region>CA</region>
[Braintree]     <country-code-alpha2>US</country-code-alpha2>
[Braintree]   </shipping>
[Braintree]   <customer-id>89585948481</customer-id>
[Braintree]   <type>sale</type>
[Braintree] </transaction>

I, [2023-03-14T14:04:40.260292 #97584]  INFO -- : [Braintree] [14/Mar/2023 06:04:40 UTC] POST /merchants/652zwb86tqk9v5wz/transactions 201
D, [2023-03-14T14:04:40.260362 #97584] DEBUG -- : [Braintree] [14/Mar/2023 06:04:40 UTC] 201 
D, [2023-03-14T14:04:40.260911 #97584] DEBUG -- : [Braintree] <?xml version="1.0" encoding="UTF-8"?>
[Braintree] <transaction>
[Braintree]   <id>kxjte0d6</id>
[Braintree]   <status>authorized</status>
[Braintree]   <type>sale</type>
[Braintree]   <currency-iso-code>EUR</currency-iso-code>
[Braintree]   <amount>26.24</amount>
[Braintree]   <amount-requested>26.24</amount-requested>
[Braintree]   <merchant-account-id>Yolo</merchant-account-id>
[Braintree]   <sub-merchant-account-id nil="true"/>
[Braintree]   <master-merchant-account-id nil="true"/>
[Braintree]   <order-id>R421881327-EAPHR9UT</order-id>
[Braintree]   <created-at type="datetime">2023-03-14T06:04:38Z</created-at>
[Braintree]   <updated-at type="datetime">2023-03-14T06:04:39Z</updated-at>
[Braintree]   <customer>
[Braintree]     <id>89585948481</id>
[Braintree]     <first-name nil="true"/>
[Braintree]     <last-name nil="true"/>
[Braintree]     <company nil="true"/>
[Braintree]     <email>admin@example.com</email>
[Braintree]     <website nil="true"/>
[Braintree]     <phone nil="true"/>
[Braintree]     <fax nil="true"/>
[Braintree]     <global-id>Y3VzdG9tZXJfODk1ODU5NDg0ODE</global-id>
[Braintree]   </customer>
[Braintree]   <billing>
[Braintree]     <id nil="true"/>
[Braintree]     <first-name nil="true"/>
[Braintree]     <last-name nil="true"/>
[Braintree]     <company nil="true"/>
[Braintree]     <street-address nil="true"/>
[Braintree]     <extended-address nil="true"/>
[Braintree]     <locality nil="true"/>
[Braintree]     <region nil="true"/>
[Braintree]     <postal-code nil="true"/>
[Braintree]     <country-name nil="true"/>
[Braintree]     <country-code-alpha2 nil="true"/>
[Braintree]     <country-code-alpha3 nil="true"/>
[Braintree]     <country-code-numeric nil="true"/>
[Braintree]   </billing>
[Braintree]   <refund-id nil="true"/>
[Braintree]   <refund-ids type="array"/>
[Braintree]   <refunded-transaction-id nil="true"/>
[Braintree]   <partial-settlement-transaction-ids type="array"/>
[Braintree]   <authorized-transaction-id nil="true"/>
[Braintree]   <settlement-batch-id nil="true"/>
[Braintree]   <shipping>
[Braintree]     <id nil="true"/>
[Braintree]     <first-name>1</first-name>
[Braintree]     <last-name>Main St</last-name>
[Braintree]     <company nil="true"/>
[Braintree]     <street-address>1 Main St 1 Main St</street-address>
[Braintree]     <extended-address nil="true"/>
[Braintree]     <locality>San Jose</locality>
[Braintree]     <region>CA</region>
[Braintree]     <postal-code>95131</postal-code>
[Braintree]     <country-name>United States of America</country-name>
[Braintree]     <country-code-alpha2>US</country-code-alpha2>
[Braintree]     <country-code-alpha3>USA</country-code-alpha3>
[Braintree]     <country-code-numeric>840</country-code-numeric>
[Braintree]   </shipping>
[Braintree]   <custom-fields/>
[Braintree]   <account-funding-transaction type="boolean">false</account-funding-transaction>
[Braintree]   <avs-error-response-code nil="true"/>
[Braintree]   <avs-postal-code-response-code>A</avs-postal-code-response-code>
[Braintree]   <avs-street-address-response-code>A</avs-street-address-response-code>
[Braintree]   <cvv-response-code>A</cvv-response-code>
[Braintree]   <gateway-rejection-reason nil="true"/>
[Braintree]   <processor-authorization-code nil="true"/>
[Braintree]   <processor-response-code>1000</processor-response-code>
[Braintree]   <processor-response-text>Approved</processor-response-text>
[Braintree]   <additional-processor-response nil="true"/>
[Braintree]   <voice-referral-number nil="true"/>
[Braintree]   <purchase-order-number nil="true"/>
[Braintree]   <tax-amount nil="true"/>
[Braintree]   <tax-exempt type="boolean">false</tax-exempt>
[Braintree]   <sca-exemption-requested nil="true"/>
[Braintree]   <processed-with-network-token type="boolean">false</processed-with-network-token>
[Braintree]   <credit-card>
[Braintree]     <token>31hv58g3</token>
[Braintree]     <bin nil="true"/>
[Braintree]     <last-4 nil="true"/>
[Braintree]     <card-type nil="true"/>
[Braintree]     <expiration-month></expiration-month>
[Braintree]     <expiration-year></expiration-year>
[Braintree]     <customer-location nil="true"/>
[Braintree]     <cardholder-name nil="true"/>
[Braintree]     <image-url>https://assets.braintreegateway.com/payment_method_logo/unknown.png?environment=sandbox</image-url>
[Braintree]     <is-network-tokenized type="boolean">false</is-network-tokenized>
[Braintree]     <prepaid>Unknown</prepaid>
[Braintree]     <healthcare>Unknown</healthcare>
[Braintree]     <debit>Unknown</debit>
[Braintree]     <durbin-regulated>Unknown</durbin-regulated>
[Braintree]     <commercial>Unknown</commercial>
[Braintree]     <payroll>Unknown</payroll>
[Braintree]     <issuing-bank>Unknown</issuing-bank>
[Braintree]     <country-of-issuance>Unknown</country-of-issuance>
[Braintree]     <product-id>Unknown</product-id>
[Braintree]     <global-id>cGF5bWVudG1ldGhvZF9jY18zMWh2NThnMw</global-id>
[Braintree]     <account-type nil="true"/>
[Braintree]     <unique-number-identifier nil="true"/>
[Braintree]     <venmo-sdk type="boolean">false</venmo-sdk>
[Braintree]     <account-balance nil="true"/>
[Braintree]   </credit-card>
[Braintree]   <paypal>
[Braintree]     <token>31hv58g3</token>
[Braintree]     <payer-email>sb-gn0fr17182740@personal.example.com</payer-email>
[Braintree]     <payment-id>PAY-9DS31091353748621MQIA45Q</payment-id>
[Braintree]     <authorization-id>4JL16420HH243914U</authorization-id>
[Braintree]     <image-url>https://assets.braintreegateway.com/payment_method_logo/paypal.png?environment=sandbox</image-url>
[Braintree]     <debug-id>231ed74bdd284</debug-id>
[Braintree]     <payee-id nil="true"/>
[Braintree]     <payee-email nil="true"/>
[Braintree]     <custom-field nil="true"/>
[Braintree]     <payer-id>LBK8SWQMLM5NW</payer-id>
[Braintree]     <payer-first-name>John</payer-first-name>
[Braintree]     <payer-last-name>Doe</payer-last-name>
[Braintree]     <payer-status>VERIFIED</payer-status>
[Braintree]     <payer-phone nil="true"/>
[Braintree]     <seller-protection-status>ELIGIBLE</seller-protection-status>
[Braintree]     <capture-id nil="true"/>
[Braintree]     <refund-id nil="true"/>
[Braintree]     <transaction-fee-amount nil="true"/>
[Braintree]     <transaction-fee-currency-iso-code nil="true"/>
[Braintree]     <refund-from-transaction-fee-amount nil="true"/>
[Braintree]     <refund-from-transaction-fee-currency-iso-code nil="true"/>
[Braintree]     <selected-financing-term nil="true"/>
[Braintree]     <selected-financing-currency-code nil="true"/>
[Braintree]     <selected-financing-discount-percentage nil="true"/>
[Braintree]     <description nil="true"/>
[Braintree]     <shipping-option-id nil="true"/>
[Braintree]     <global-id>cGF5bWVudG1ldGhvZF9wcF8zMWh2NThnMw</global-id>
[Braintree]     <cobranded-card-label nil="true"/>
[Braintree]     <implicitly-vaulted-payment-method-token nil="true"/>
[Braintree]     <implicitly-vaulted-payment-method-global-id nil="true"/>
[Braintree]     <billing-agreement-id>B-50H24068UP681470F</billing-agreement-id>
[Braintree]     <paypal-retail-transaction-id nil="true"/>
[Braintree]     <paypal-retail-transaction-status nil="true"/>
[Braintree]     <paypal-retail-transaction-refund-url nil="true"/>
[Braintree]     <paypal-retail-transaction-lookup-url nil="true"/>
[Braintree]     <app-used-for-scanning nil="true"/>
[Braintree]     <refund-reason nil="true"/>
[Braintree]     <refund-description nil="true"/>
[Braintree]   </paypal>
[Braintree]   <status-history type="array">
[Braintree]     <status-event>
[Braintree]       <timestamp type="datetime">2023-03-14T06:04:39Z</timestamp>
[Braintree]       <status>authorized</status>
[Braintree]       <amount>26.24</amount>
[Braintree]       <user>hello@nebulab.it</user>
[Braintree]       <transaction-source>api</transaction-source>
[Braintree]     </status-event>
[Braintree]   </status-history>
[Braintree]   <plan-id nil="true"/>
[Braintree]   <subscription-id nil="true"/>
[Braintree]   <subscription>
[Braintree]     <billing-period-end-date nil="true"/>
[Braintree]     <billing-period-start-date nil="true"/>
[Braintree]   </subscription>
[Braintree]   <add-ons type="array"/>
[Braintree]   <discounts type="array"/>
[Braintree]   <descriptor>
[Braintree]     <name nil="true"/>
[Braintree]     <phone nil="true"/>
[Braintree]     <url nil="true"/>
[Braintree]   </descriptor>
[Braintree]   <recurring type="boolean">false</recurring>
[Braintree]   <channel>Solidus</channel>
[Braintree]   <service-fee-amount nil="true"/>
[Braintree]   <escrow-status nil="true"/>
[Braintree]   <disbursement-details>
[Braintree]     <disbursement-date nil="true"/>
[Braintree]     <settlement-amount nil="true"/>
[Braintree]     <settlement-currency-iso-code nil="true"/>
[Braintree]     <settlement-currency-exchange-rate nil="true"/>
[Braintree]     <settlement-base-currency-exchange-rate nil="true"/>
[Braintree]     <funds-held nil="true"/>
[Braintree]     <success nil="true"/>
[Braintree]   </disbursement-details>
[Braintree]   <disputes type="array"/>
[Braintree]   <ach-return-responses type="array"/>
[Braintree]   <authorization-adjustments type="array"/>
[Braintree]   <payment-instrument-type>paypal_account</payment-instrument-type>
[Braintree]   <processor-settlement-response-code></processor-settlement-response-code>
[Braintree]   <processor-settlement-response-text></processor-settlement-response-text>
[Braintree]   <network-response-code nil="true"/>
[Braintree]   <network-response-text nil="true"/>
[Braintree]   <three-d-secure-info nil="true"/>
[Braintree]   <ships-from-postal-code nil="true"/>
[Braintree]   <shipping-amount nil="true"/>
[Braintree]   <discount-amount nil="true"/>
[Braintree]   <network-transaction-id nil="true"/>
[Braintree]   <processor-response-type>approved</processor-response-type>
[Braintree]   <authorization-expires-at type="datetime">2023-04-12T06:04:39Z</authorization-expires-at>
[Braintree]   <retry-ids type="array"/>
[Braintree]   <retried-transaction-id nil="true"/>
[Braintree]   <refund-global-ids type="array"/>
[Braintree]   <partial-settlement-transaction-global-ids type="array"/>
[Braintree]   <refunded-transaction-global-id nil="true"/>
[Braintree]   <authorized-transaction-global-id nil="true"/>
[Braintree]   <global-id>dHJhbnNhY3Rpb25fa3hqdGUwZDY</global-id>
[Braintree]   <retry-global-ids type="array"/>
[Braintree]   <retried-transaction-global-id nil="true"/>
[Braintree]   <retrieval-reference-number nil="true"/>
[Braintree]   <ach-return-code nil="true"/>
[Braintree]   <installment-count nil="true"/>
[Braintree]   <installments type="array"/>
[Braintree]   <refunded-installments type="array"/>
[Braintree]   <response-emv-data nil="true"/>
[Braintree]   <acquirer-reference-number nil="true"/>
[Braintree]   <merchant-identification-number nil="true"/>
[Braintree]   <terminal-identification-number nil="true"/>
[Braintree]   <merchant-name nil="true"/>
[Braintree]   <merchant-address>
[Braintree]     <street-address nil="true"/>
[Braintree]     <locality nil="true"/>
[Braintree]     <region nil="true"/>
[Braintree]     <postal-code nil="true"/>
[Braintree]     <phone nil="true"/>
[Braintree]   </merchant-address>
[Braintree]   <pin-verified type="boolean">false</pin-verified>
[Braintree]   <debit-network nil="true"/>
[Braintree]   <processing-mode nil="true"/>
[Braintree]   <payment-receipt>
[Braintree]     <id>kxjte0d6</id>
[Braintree]     <global-id>dHJhbnNhY3Rpb25fa3hqdGUwZDY</global-id>
[Braintree]     <amount>26.24</amount>
[Braintree]     <currency-iso-code>EUR</currency-iso-code>
[Braintree]     <processor-response-code>1000</processor-response-code>
[Braintree]     <processor-response-text>Approved</processor-response-text>
[Braintree]     <processor-authorization-code nil="true"/>
[Braintree]     <merchant-name nil="true"/>
[Braintree]     <merchant-address>
[Braintree]       <street-address nil="true"/>
[Braintree]       <locality nil="true"/>
[Braintree]       <region nil="true"/>
[Braintree]       <postal-code nil="true"/>
[Braintree]       <phone nil="true"/>
[Braintree]     </merchant-address>
[Braintree]     <merchant-identification-number nil="true"/>
[Braintree]     <terminal-identification-number nil="true"/>
[Braintree]     <type>sale</type>
[Braintree]     <pin-verified type="boolean">false</pin-verified>
[Braintree]     <processing-mode nil="true"/>
[Braintree]     <network-identification-code nil="true"/>
[Braintree]   </payment-receipt>
[Braintree] </transaction>
kennyadsl commented 1 year ago

For reference, this is the answer we've got from Braintree:

Thanks for reaching out.

Please note as per our support articles , Premium Fraud Management Tools are compatible with all credit and debit cards and the following:

• Apple Pay • Google Pay • Samsung Pay • Secure Remote Commerce

But not with PayPal. You can and should collect device data for PayPal Checkout with Vault, but risk information won't be included in the Fraud Protection Section of the transaction details as that section won't be in PayPal transactions at all.

I hope I've helped clarify for you today.

kennyadsl commented 1 year ago

I made a real test on the sandbox, and unfortunately, there is no way to understand if we are collecting device information correctly from the Braintree admin panel. For PayPal orders, this is the only thing shown:

Screenshot 2023-04-11 at 13 55 43@2x

While other orders have the following section:

Screenshot 2023-04-11 at 13 56 42@2x

I received no errors so I assume it's working but I'm still trying to understand why we should send device information if there's nothing we can do with them when PayPal is used.