MasterCard Gateway (formerly TNS) gateway guide
Adding a MasterCard Gateway (formerly TNS) gateway
Note that if your TNS merchant account is set up for single-step pay/purchase mode, the pay_mode setting must be set to true . If it is not provided or set to false, Purchase actions will default to a two-step Authorize and Capture.
To set the regional url for the gateway, pass one of three values for the region gateway field: asia_pacific, europe, or north_america. If no value is passed for this field, it will default to north_america.
To learn more about creating and managing gateways in our Marketplace, review the Gateway user guide. For gateways not included in the Marketplace, review the steps below.
Create a gateway
Visit your Connections area to review all gateways and add new ones. When creating your gateways, select the gateway name and authentication mode (if prompted) before completing required fields. Select ☑️Sandbox to create a gateway in Sandbox mode, for processing test card data and transactions in your Spreedly environment.

With pay_mode set and region specified, you just need your userid and password to create a TNS gateway.
To add a MasterCard Gateway (formerly TNS) gateway:
curl https://core.spreedly.com/v1/gateways.xml \
-u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
-H 'Content-Type: application/xml' \
-d '<gateway>
<gateway_type>tns</gateway_type>
<userid>Your userid</userid>
<password>Your password</password>
<region>north_america</region>
<pay_mode>true</pay_mode>
</gateway>'<gateway>
<token>IwiokZMEbaxOsNfnJorNvpPRozi</token>
<gateway_type>tns</gateway_type>
<name>MasterCard Payment Gateway Service (formerly TNS)</name>
<description nil="true"/>
<userid>Your userid</userid>
<region>north_america</region>
<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">false</supports_offsite_purchase>
<supports_offsite_authorize type="boolean">false</supports_offsite_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">false</supports_3dsecure_2_mpi_purchase>
<supports_3dsecure_2_mpi_authorize type="boolean">false</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>
</characteristics>
<credentials>
<credential>
<name>userid</name>
<value>Your userid</value>
</credential>
<credential>
<name>region</name>
<value>north_america</value>
</credential>
</credentials>
<gateway_settings>
<pay_mode>true</pay_mode>
</gateway_settings>
<gateway_specific_fields>
</gateway_specific_fields>
<payment_methods>
<payment_method>credit_card</payment_method>
</payment_methods>
<state>retained</state>
<redacted type="boolean">false</redacted>
<created_at type="dateTime">2019-09-19T14:37:52Z</created_at>
<updated_at type="dateTime">2019-09-19T14:37:52Z</updated_at>
</gateway>Gateway specific fields
<gateway_specific_fields>
<gateway_specific_field>order_certainty</gateway_specific_field>
<gateway_specific_field>expected_number_of_captures</gateway_specific_field>
</gateway_specific_fields>Gateway specific Response fields
A response from the gateway may contain an authorization_code. You can find this information in gateway_specific_response_fields. For example, a transaction could have:
<transaction>
<token>LgpTNGjsWQs9DwdxcbreUVz0R8p</token>
<transaction_type>Purchase</transaction_type>
<gateway_specific_response_fields>
<tns>
<authorization_code>123456</authorization_code>
</tns>
</gateway_specific_response_fields>
</transaction>To request any gateway_specific_fields or gateway_specific_response_fields, please contact Support with your request and the gateway documentation for the fields of interest.
Partial capture
To capture one authorization in more than one payment, set order_certainty on the authorize and expected_number_of_captures on every capture. Use the same expected count on each capture.
order_certainty accepts FINAL when the authorized amount will not change.
expected_number_of_captures is the total number of captures you will make, from 1 to 99. Set it to 1 on the last capture. After that many captures succeed, Mastercard stops further captures and voids any authorized amount you did not capture.
This requires Automatically Reverse Outstanding Authorization Amounts on the Mastercard merchant profile. Ask your payment service provider to enable it. Without that privilege, another capture can still succeed.
Authorize
{
"transaction": {
"payment_method_token": "PAYMENT_METHOD_TOKEN",
"amount": 500,
"currency_code": "USD",
"gateway_specific_fields": {
"tns": { "order_certainty": "FINAL" }
}
}
}Each capture, using the authorization token
{
"transaction": {
"amount": 200,
"gateway_specific_fields": {
"tns": { "expected_number_of_captures": "2" }
}
}
}Partial refund
Refund part of a purchase or capture by sending a lower amount. No gateway specific field is required.
{
"transaction": {
"amount": 200
}
}Updated 3 days ago

