dLocal gateway guide
Additional notes |
---|
The current supported dLocal API can respond with a success message for a request to void an authorization that has already been captured, but that void request will have no effect on the payment. |
dLocal requires a Country code to be sent for each transaction. The Country can be added to a transaction by overriding the Country field of the billing address during the transaction or by sending the optional country gateway specific field. Alternately, the Country code will default to match the Country field in the billing address that was provided when the payment method token was created .. |
Adding a dLocal gateway
To add a dLocal gateway:
curl https://core.spreedly.com/v1/gateways.xml \
-u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
-H 'Content-Type: application/xml' \
-d '<gateway>
<gateway_type>d_local</gateway_type>
<login>Your login</login>
<trans_key>Your trans_key</trans_key>
<secret_key>Your secret_key</secret_key>
</gateway>'
<gateway>
<token>LAynfqGFs6oWO2s3Q0MtxOQXnWY</token>
<gateway_type>d_local</gateway_type>
<name>dLocal</name>
<description nil="true"/>
<merchant_profile_key nil="true"/>
<sub_merchant_key nil="true"/>
<login>Your login</login>
<characteristics>
<supports_purchase type="boolean">true</supports_purchase>
<supports_authorize type="boolean">true</supports_authorize>
<supports_capture type="boolean">true</supports_capture>
<supports_credit type="boolean">true</supports_credit>
<supports_general_credit type="boolean">false</supports_general_credit>
<supports_void type="boolean">true</supports_void>
<supports_adjust type="boolean">false</supports_adjust>
<supports_verify type="boolean">true</supports_verify>
<supports_reference_purchase type="boolean">false</supports_reference_purchase>
<supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
<supports_offsite_purchase type="boolean">true</supports_offsite_purchase>
<supports_offsite_synchronous_purchase type="boolean">false</supports_offsite_synchronous_purchase>
<supports_offsite_synchronous_authorize type="boolean">false</supports_offsite_synchronous_authorize>
<supports_3dsecure_purchase type="boolean">false</supports_3dsecure_purchase>
<supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
<supports_3dsecure_2_mpi_purchase type="boolean">true</supports_3dsecure_2_mpi_purchase>
<supports_3dsecure_2_mpi_authorize type="boolean">true</supports_3dsecure_2_mpi_authorize>
<supports_store type="boolean">false</supports_store>
<supports_remove type="boolean">false</supports_remove>
<supports_fraud_review type="boolean">false</supports_fraud_review>
<supports_network_tokenization type="boolean">true</supports_network_tokenization>
<supports_populate_mit_fields type="boolean">false</supports_populate_mit_fields>
<supports_inquire_by_gateway_transaction_id type="boolean">true</supports_inquire_by_gateway_transaction_id>
<supports_inquire_by_order_id type="boolean">true</supports_inquire_by_order_id>
<supports_transaction_retry type="boolean">false</supports_transaction_retry>
<supports_stored_stored_credentials type="boolean">false</supports_stored_stored_credentials>
<supports_inquire type="boolean">true</supports_inquire>
</characteristics>
<credentials>
<credential>
<name>login</name>
<value>Your login</value>
</credential>
</credentials>
<gateway_settings>
</gateway_settings>
<gateway_specific_fields>
<gateway_specific_field>document</gateway_specific_field>
<gateway_specific_field>document2</gateway_specific_field>
<gateway_specific_field>birth_date</gateway_specific_field>
<gateway_specific_field>user_reference</gateway_specific_field>
<gateway_specific_field>dynamic_descriptor</gateway_specific_field>
<gateway_specific_field>notification_url</gateway_specific_field>
<gateway_specific_field>installments</gateway_specific_field>
<gateway_specific_field>installments_id</gateway_specific_field>
<gateway_specific_field>idempotency_key</gateway_specific_field>
<gateway_specific_field>additional_data</gateway_specific_field>
<gateway_specific_field>device_id</gateway_specific_field>
<gateway_specific_field>force_type</gateway_specific_field>
<gateway_specific_field>original_order_id</gateway_specific_field>
<gateway_specific_field>country</gateway_specific_field>
</gateway_specific_fields>
<payment_methods>
<payment_method>credit_card</payment_method>
<payment_method>pix</payment_method>
</payment_methods>
<state>retained</state>
<redacted type="boolean">false</redacted>
<sandbox type="boolean">false</sandbox>
<mode>default</mode>
<created_at type="dateTime">2023-02-07T15:03:40Z</created_at>
<updated_at type="dateTime">2023-02-07T15:03:40Z</updated_at>
</gateway>
Third-party 3D Secure 2 auth data
Spreedly will automatically handle the field mapping for sending third-party 3DS2 authentication data to Dlocal. For more information about how to use this feature, see the [3DS2 Third-party Authentication Guide](To be Added). Spreedly fields map to the relevant Dlocal fields as described in the following table. Please see Dlocal’s transaction variable documentation for detailed descriptions of each of these fields and when to use them.
SPREEDLY FIELD | DLOCAL FIELD |
---|---|
three_ds_version | three_dsecure_version |
ecommerce_indicator | eci |
authentication_value | cavv |
directory_server_transaction_id | ds_transaction_id |
authentication_response_status | authentication_response |
enrolled | enrollment_response |
xid | xid |
Gateway specific fields
When interacting with a dLocal gateway to run transactions, there are a number of gateway specific fields you can specify. See below for usage notes for certain fields, and dLocal’s documentation for more information.
document
the customer’s national identification number, required for Auths and Purchases.- Passing
notification_url
for refunds will allow dLocal to send httpPOST
notices of the refund’s finalization to that url, if the refund is not immediate. - birth_date is expected in the format
DD-MM-YYYY
idempotency_key
is for safely retrying requests without accidentally performing the same operation twice.device_id
dLocal device ID used in fraud prevention. Described as event_uuid in dLocal docsadditional_data
open ended object used in fraud prevention. Described as additional_risk_data in dLocal docsforce_type
is an optional field that indicates the card type in cases where the card can act as either debit or credit. This field only applies for transactions in Brazil. Possible values are:CREDIT
orDEBIT
.original_order_id
is an ID given by the merchant in their system for the original transaction in the event it is rejected and needs to be retried.save
is an optional boolean field. When set totrue
on a purchase, authorize, or verify, it will save the card to the merchant’s dLocal account, and will also generate thesaved_card_type
gateway specific response field.country
is optional and can be added to a transaction to override the Country field of the billing address during the transaction.
curl https://core.spreedly.com/v1/gateways/LlkjmEk0xNkcWrNixXa1fvNoTP4/purchase.xml \
-u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
-H 'Content-Type: application/xml' \
-d '<transaction>
<payment_method_token>56wyNnSmuA6CWYP7w0MiYCVIbW6</payment_method_token>
<amount>100</amount>
<currency_code>USD</currency_code>
<gateway_specific_fields>
<d_local>
<document>1234567890</document>
<document2>0987654321</document2>
<birth_date>01-01-1980</birth_date>
<user_reference>1357924680</user_reference>
<dynamic_descriptor>dynamic description</dynamic_descriptor>
<notification_url>http://example.com</notification_url>
<installments>3</installments>
<installments_id>INS54434</installments_id>
<idempotency_key>key</idempotency_key>
<device_id>123</device_id>
<force_type>DEBIT</force_type>
<original_order_id>ABC123</original_order_id>
<save>true</save>
<additional_data>
<submerchant>
<item>socks</item>
</submerchant>
</additional_data>
<country>Mexico</country
</d_local>
</gateway_specific_fields>
</transaction>'
<transaction>
<on_test_gateway type="boolean">true</on_test_gateway>
<created_at type="dateTime">2023-06-20T16:20:47Z</created_at>
<updated_at type="dateTime">2023-06-20T16:20:47Z</updated_at>
<succeeded type="boolean">true</succeeded>
<state>succeeded</state>
<token>CXAzQtugF1GOgr1hkY3lXJhyXhY</token>
<transaction_type>Purchase</transaction_type>
<order_id nil="true"/>
<ip nil="true"/>
<description nil="true"/>
<email nil="true"/>
<merchant_name_descriptor nil="true"/>
<merchant_location_descriptor nil="true"/>
<merchant_profile_key nil="true"/>
<gateway_specific_fields>
<d_local>
<document>1234567890</document>
<document2>0987654321</document2>
<birth_date>01-01-1980</birth_date>
<user_reference>1357924680</user_reference>
<dynamic_descriptor>dynamic description</dynamic_descriptor>
<notification_url>http://example.com</notification_url>
<installments>3</installments>
<installments_id>INS54434</installments_id>
<idempotency_key>key</idempotency_key>
<device_id>123</device_id>
<force_type>DEBIT</force_type>
<original_order_id>ABC123</original_order_id>
<save>true</save>
<additional_data>
<submerchant>
<item>socks</item>
</submerchant>
</additional_data>
<country>Mexico</country
</d_local>
</gateway_specific_fields>
<gateway_specific_response_fields>
</gateway_specific_response_fields>
<gateway_transaction_id>67</gateway_transaction_id>
<sub_merchant_key nil="true"/>
<gateway_latency_ms type="integer">0</gateway_latency_ms>
<warning nil="true"/>
<application_id nil="true"/>
<amount type="integer">100</amount>
<local_amount nil="true"/>
<currency_code>USD</currency_code>
<retain_on_success type="boolean">false</retain_on_success>
<payment_method_added type="boolean">false</payment_method_added>
<smart_routed type="boolean">false</smart_routed>
<stored_credential_initiator nil="true"/>
<stored_credential_reason_type nil="true"/>
<stored_credential_gateway_override nil="true"/>
<populate_mit_fields type="boolean">false</populate_mit_fields>
<message key="messages.transaction_succeeded">Succeeded!</message>
<gateway_token>T11bJAANtTWnxl36GYjKWvbNK0g</gateway_token>
<gateway_type>test</gateway_type>
<shipping_address>
<name>Newfirst Newlast</name>
<address1 nil="true"/>
<address2 nil="true"/>
<city nil="true"/>
<state nil="true"/>
<zip nil="true"/>
<country nil="true"/>
<phone_number nil="true"/>
</shipping_address>
<response>
<success type="boolean">true</success>
<message>Successful purchase</message>
<avs_code nil="true"/>
<avs_message nil="true"/>
<cvv_code nil="true"/>
<cvv_message nil="true"/>
<pending type="boolean">false</pending>
<result_unknown type="boolean">false</result_unknown>
<error_code nil="true"/>
<error_detail nil="true"/>
<cancelled type="boolean">false</cancelled>
<fraud_review nil="true"/>
<created_at type="dateTime">2023-06-20T16:20:47Z</created_at>
<updated_at type="dateTime">2023-06-20T16:20:47Z</updated_at>
</response>
<api_urls>
</api_urls>
<payment_method>
<token>1rpKvP8zOUhj4Y9EDrIoIYQzzD5</token>
<created_at type="dateTime">2017-06-26T17:04:38Z</created_at>
<updated_at type="dateTime">2023-06-16T13:48:47Z</updated_at>
<email>[email protected]</email>
<data>
<my_payment_method_identifier>448</my_payment_method_identifier>
<extra_stuff>
<some_other_things>Can be anything really</some_other_things>
</extra_stuff>
</data>
<storage_state>retained</storage_state>
<test type="boolean">true</test>
<metadata>
<key>string value</key>
</metadata>
<callback_url nil="true"/>
<last_four_digits>1111</last_four_digits>
<first_six_digits>411111</first_six_digits>
<card_type>visa</card_type>
<first_name>Newfirst</first_name>
<last_name>Newlast</last_name>
<month type="integer">3</month>
<year type="integer">2032</year>
<address1 nil="true"/>
<address2 nil="true"/>
<city nil="true"/>
<state nil="true"/>
<zip nil="true"/>
<country nil="true"/>
<phone_number nil="true"/>
<company nil="true"/>
<full_name>Newfirst Newlast</full_name>
<eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
<shipping_address1 nil="true"/>
<shipping_address2 nil="true"/>
<shipping_city nil="true"/>
<shipping_state nil="true"/>
<shipping_zip nil="true"/>
<shipping_country nil="true"/>
<shipping_phone_number nil="true"/>
<issuer_identification_number nil="true"/>
<click_to_pay type="boolean">false</click_to_pay>
<managed nil="true"/>
<payment_method_type>credit_card</payment_method_type>
<errors>
</errors>
<verification_value></verification_value>
<number>XXXX-XXXX-XXXX-1111</number>
<fingerprint>e3cef43464fc832f6e04f187df25af497994</fingerprint>
<stored_credential_usage>
<test>
<original_network_transaction_id>37be5367d6dbe4a88c9d</original_network_transaction_id>
<network_transaction_id>37be5367d6dbe4a88c9d</network_transaction_id>
</test>
</stored_credential_usage>
</payment_method>
<attempt_3dsecure type="boolean">false</attempt_3dsecure>
</transaction>
Syncing Transactions
Spreedly supports updating the status of transactions that have been initiated at the dLocal gateway. dLocal currently supports using gateway_transaction_id
or order_id
for updates. The gateway_transaction_id
would be the payment_id
of the order. While order_id
is the unique identifier used by the merchant in dLocal’s system. See our documentation for more information.
Custom Terminal State Rules
When syncing your transaction, there are some transaction states that are ineligible for update. The dLocal gateway deviates from this rule. With dLocal, transactions with the state succeeded
are still eligible for update only if that transaction is in a pending status at the gateway.
Gateway specific response fields
A response from dLocal may contain the acquirer, notification_url
, ticket
, saved_card_type
, country
, and status
gateway specific response fields.
For example, a transaction could have something like this:
<transaction>
<token>LgpTNGjsWQs9DwdxcbreUVz0R8p</token>
<transaction_type>Purchase</transaction_type>
<gateway_specific_response_fields>
<d_local>
<acquirer>Test</acquirer>
<notification_url>test.com</notification_url>
<ticket>123456</ticket>
<saved_card_type>CREDIT</saved_card_type>
<country>BR</country>
<status>PAID</status>
</d_local>
</gateway_specific_response_fields>
</transaction>
When syncing your transaction, there are some transaction states that are ineligible for update. The dLocal gateway deviates from this rule. With dLocal, transactions with the state succeeded
are still eligible for update only if that transaction is in a pending status at the gateway.
Local Payment Methods
Pix
Pix is a payment method for instant direct bank transfers in Brazil, which is built and owned by the Central Bank (Banco Central) and operated by Brazilian banks, digital accounts, and wallets.
The user can complete the payment using any Home Banking or Ewallet App, by copying and pasting a Transaction ID or scanning a QR code. For more information about PIX see Pix dLocal documentation.
Available country code | BR |
---|
Parameters:
FIELD NAME | M/O | DESCRIPTION |
---|---|---|
payment_method_id | M | Pix unique identifier |
payment_method_flow | M | Specify the type of flow to use |
notification_url | M | Notification URL to receive changes about the transaction state |
offsite_sync | O | Identify the transaction as synchronous, default is false |
Pix Transactions
The Spreedly integration with dLocal Gateway offers one mode of transacting via PIX using Direct PIX payment
For offsite transaction it is necessary to reach out to your dLocal account manager to ensure your account is properly configured.
Create Pix Payment Method
curl https://core.spreedly.com/v1/payment_methods.xml \
-u 'JK2TAjqm7aDifCK74iN178aPQmg:e671vkMEWTi1saL1lGu15y6MIA56WrbeWquqvX41zx63gs7cjly4GkJ6l1PqejEx' \
-H 'Content-Type: application/xml' \
-d '<payment_method>
<payment_method_id>PQ</payment_method_id>
<payment_method_flow>DIRECT</payment_method_flow>
<notification_url>http://merchant.com/notifications</notification_url>
<offsite_sync>false</offsite_sync>
<first_name>Joe</first_name>
<last_name>Doe</last_name>
<payment_method_type>pix</payment_method_type>
<test>true</test>
</payment_method>'
Response:
<transaction>
<token>E6foqTMrnuqGjeYrefgp2E8DQal</token>
<created_at>2023-02-08T17:10:08Z</created_at>
<updated_at>2023-02-08T17:10:11Z</updated_at>
<succeeded>true</succeeded>
<transaction_type>AddPaymentMethod</transaction_type>
<retained>false</retained>
<state>succeeded</state>
<message_key>messages.transaction_succeeded</message_key>
<message>Succeeded!</message>
<payment_method>
<token>M8LXGso28THgXfzQIxVlNav8Fuq</token>
<created_at>2023-02-08T17:10:10Z</created_at>
<updated_at>2023-02-08T17:10:11Z</updated_at>
<email/>
<data/>
<storage_state>cached</storage_state>
<test>true</test>
<metadata/>
<callback_url/>
<payment_method_id>PQ</payment_method_id>
<payment_method_flow>DIRECT</payment_method_flow>
<notification_url>http://merchant.com/notifications</notification_url>
<payment_method_type>pix</payment_method_type>
<errors/>
</payment_method>
</transaction>
Once the payment method has been created, the merchant is able to perform a purchase transaction as show below:
Create Pending Transaction
curl https://core.spreedly.com/v1/gateways/LlkjmEk0xNkcWrNixXa1fvNoTP4/purchase.xml \
-u 'Ll6fAtoVSTyVMlJEmtpoJV8S:RKOCG5D8D3fZxDSg504D0IxU2XD4Io5VXmyzdCtTivHFTTSy' \
-H 'Content-Type: application/xml' \
-d '<transaction>
<amount>100</amount>
<currency_code>BRL</currency_code>
<payment_method_token>M8LXGso28THgXfzQIxVlNav8Fuq</payment_method_token>
<redirect_url>https://c129-181-142-153-145.ngrok.io/dlocal/webhooks</redirect_url>
<callback_url>https://c129-181-142-153-145.ngrok.io/dlocal/webhooks</callback_url>
<billing_address>
<country>Brazil</country>
</billing_address>
<gateway_specific_fields>
<d_local>
<document>71575743221</document>
</d_local>
</gateway_specific_fields>
</transaction>'
Response:
<transaction>
<on_test_gateway>true</on_test_gateway>
<created_at>2023-02-08T17:10:20Z</created_at>
<updated_at>2023-02-08T17:10:42Z</updated_at>
<succeeded>false</succeeded>
<state>pending</state>
<token>JwPJExqtNBuhAf2591hCpAbcztb</token>
<transaction_type>OffsitePurchase</transaction_type>
<order_id/>
<ip/>
<description/>
<email/>
<merchant_name_descriptor/>
<merchant_location_descriptor/>
<merchant_profile_key/>
<gateway_specific_fields>
<d_local>
<document>71575743221</document>
</d_local>
</gateway_specific_fields>
<gateway_specific_response_fields>
<d_local>
<ticket>
<type>CUSTOM</type>
<format>Code 128</format>
<number>441812557</number>
<expiration_date>2023-02-14T23:59:00.000+0000</expiration_date>
<id>9000000507325</id>
<barcode>441812557</barcode>
<company_name>The Best Company</company_name>
<company_id>112903</company_id>
<image_url>https://sandbox.dlocal.com/gmf-apm/payments/M-d70840e8-0d01-49fb-adb4-42f5e2f41829</image_url>
<amount>1</amount>
</ticket>
</d_local>
</gateway_specific_response_fields>
<gateway_transaction_id>D-15104-1b9eb11f-6053-4c1c-9c53-3379835ae5cc</gateway_transaction_id>
<sub_merchant_key/>
<gateway_latency_ms>14546</gateway_latency_ms>
<stored_credential_initiator/>
<stored_credential_reason_type/>
<populate_mit_fields>false</populate_mit_fields>
<warning/>
<application_id/>
<amount>100</amount>
<local_amount/>
<currency_code>BRL</currency_code>
<reference>D-15104-1b9eb11f-6053-4c1c-9c53-3379835ae5cc</reference>
<setup_verification/>
<message_key>messages.transaction_pending</message_key>
<message>Pending</message>
<gateway_token>SfrX6pMOYkt9LgY7VJJxN5dCsOB</gateway_token>
<gateway_type>d_local</gateway_type>
<response>
<success>true</success>
<message>The payment is pending.</message>
<avs_code/>
<avs_message/>
<cvv_code/>
<cvv_message/>
<pending>true</pending>
<result_unknown>false</result_unknown>
<error_code/>
<error_detail/>
<cancelled>false</cancelled>
<fraud_review/>
<created_at>2023-02-08T17:10:37Z</created_at>
<updated_at>2023-02-08T17:10:42Z</updated_at>
</response>
<billing_address>
<name/>
<address1/>
<address2/>
<city/>
<state/>
<zip/>
<country>BR</country>
<phone_number/>
</billing_address>
<shipping_address>
<name/>
<address1/>
<address2/>
<city/>
<state/>
<zip/>
<country/>
<phone_number/>
</shipping_address>
<api_urls>
<callback_conversations>http://core.spreedly.test/v1/callbacks/HbAWSmqx20RnAhEzQKdOo70ORPq/conversations.xml</callback_conversations>
</api_urls>
<redirect_url>https://c129-181-142-153-145.ngrok.io/dlocal/webhooks</redirect_url>
<callback_url>https://c129-181-142-153-145.ngrok.io/dlocal/webhooks</callback_url>
<attempt_3dsecure>false</attempt_3dsecure>
<challenge_url/>
<required_action>none</required_action>
<three_ds_context/>
<setup_response>
<success>true</success>
<message>The payment is pending.</message>
<avs_code/>
<avs_message/>
<cvv_code/>
<cvv_message/>
<pending>true</pending>
<result_unknown>false</result_unknown>
<error_code/>
<error_detail/>
<cancelled>false</cancelled>
<fraud_review/>
<created_at>2023-02-08T17:10:37Z</created_at>
<updated_at>2023-02-08T17:10:42Z</updated_at>
</setup_response>
<payment_method>
<token>M8LXGso28THgXfzQIxVlNav8Fuq</token>
<created_at>2023-02-08T17:10:10Z</created_at>
<updated_at>2023-02-08T17:10:11Z</updated_at>
<email/>
<data/>
<storage_state>cached</storage_state>
<test>true</test>
<metadata/>
<callback_url/>
<payment_method_id>PQ</payment_method_id>
<payment_method_flow>DIRECT</payment_method_flow>
<notification_url>http://merchant.com/notifications</notification_url>
<payment_method_type>pix</payment_method_type>
<errors/>
</payment_method>
</transaction>
Callback
Spreedly’s callback system handles situations where a customer runs an asynchronous transaction and the result is not immediately available to return to them. When Spreedly receives a status update on an asynchronous transaction that alters the state of the Spreedly transaction, Spreedly will send a notification to the callback_url
specified in the transaction.
Notification
Whenever dLocal updates the state of a pending transaction, they can notify Spreedly through the webhook mentioned above to update the transaction status. The merchants have to configure the notification_url
in their dLocal dashboard.
For more information on callbacks, see Spreedly’s Offsite Payments documentation.
Updated 23 days ago