Set up the Forward API configuration

Forward API parameters

Your FlexCharge credentials

Retrieve your credentials from your Merchant Portal, and use them when setting up your configuration.

Forward request VariableFlexCharge credential
$app_key-FlexchargeApi Key
$app_secret-FlexchargeApi secret
$FlexCharge_MIDMerchant id
$tokenization_key-FlexChargeTokenization key
This credential can be inserted as is in the body of your Forward request.Site Id

You can find credentials in at this place


Forward requests parameters


In order to send successful calls to FlexCharge API requests, you will need to provide the required parameters in the body of your Forward configuration.

Forward request parametersDescriptionExample
$merchant_idYour Braintree merchant id
$nameName of the configurationFor Evaluate requests:
flexcharge_evaluate

For Transmit requests:
flexcharge_transmit
$urlDestination URLFor sandbox testing:
https://api-sandbox.flex-charge.com/v1/

For production:
<https://api.flex-charge.com/vl/>

----
Add /evaluate or /transmit according to your request
$payment_method_nonceBraintree payment method nonce to fetch payment details
$methodAPI methodSet to POST



The types of API calls to forward

There are 2 API calls you will build for FlexCharge:

Name of RequestPurposeTransactions to sendDescription
EvaluateEvaluation if a transaction can be rescued or notDeclined transactionsContains Payment Method Token.
Will return 'Approved', 'Declined' or 'Challenge'
See complete documentation.
TransmitRisk model to improve rescue rate.Approved transactionsDoesn't contain Payment Method token.
Returns a 200 on success.
See complete documentation.
curl https://forwarding.sandbox.braintreegateway.com/ \
-H "Content-Type: application/json" \
-H "flexcharge-app-key: <FC_APP_KEY>" \
-H "flexcharge-app-secret: <FC_APP_SECRET>" \
-X POST \
-u "<BRAINTREE_PUBLIC_KEY>:<BRAINTREE_PRIVATE_KEY>" \
-d '{
  "merchant_id": "<BRAINTREE_MERCHANT_ID>",
  "payment_method_nonce": "fake-valid-nonce",
  "name": "flexcharge_evaluate",
  "url": "https://api-sandbox.flex-charge.com/v1/evaluate",
  "method": "POST",
  "override": {
    "body": {
      "transaction": {
        "id": "3478613",
        "timestampUtc": "0001-01-01T00:00:00Z",
        "timezoneUtcOffset": 0,
        "amount": 15000,
        "currency": "USD",
        "responseCode": "203",
        "avsResultCode": "M",
        "cvvResultCode": "NA",
        "cavvResultCode": "2",
        "responseCodeSource": "Braintree",
        "responseDescription": "Activity limit exceeded",
        "responseStatus": "DECLINED",
        "transactionType": "CAPTURE",
        "dynamicDescriptor": "MyShoesStore"
      },
      "payer": {
        "id": "customer123",
        "email": "[email protected]",
        "phone": "+1 555-123-4567",
        "birthdate": "1990-01-01"
      },
      "merchant": {
        "country": "US",
        "mcc": 5999,
        "id": "merchant123",
        "name": "Acme Inc."
      },
      "billingInformation": {
        "firstName": "John",
        "lastName": "Doenowitz",
        "phone": "+1 555-123-4567",
        "country": "United States",
        "countryCode": "US",
        "addressLine1": "123 Main St.",
        "state": "CA",
        "city": "San Francisco",
        "zipcode": "94111"
      },
      "mid": "<FC_MID>",
      "environment": "<FC_environment>",
      "siteUrl": "https://www.someSite.com",
      "orderSource": "ecommerce",
      "siteId": "<FC_SITE_ID>",
      "isDeclined": true,
      "isMIT": false,
      "orderId": "{enter a GUUID}",
      "idempotencyKey": "{enter a GUUID}"
    }
  }'
curl https://forwarding.sandbox.braintreegateway.com/ \
-H "Content-Type: application/json" \
-H "flexcharge-app-key: <FC_APP_KEY>" \
-H "flexcharge-app-secret: <FC_SECRET_KEY>" \
-X POST \
-u "<BRAINTREE_PUBLIC_KEY>:<BRAINTREE_PRIVATE_KEY>" \
-d '{
  "merchant_id": "<BRAINTREE_MERCHANT_ID>",
  "payment_method_nonce": "fake-valid-nonce",
  "name": "flexcharge_transmit",
  "url": "https://api-sandbox.flex-charge.com/v1/transmit",
  "method": "POST",
  "override": {
    "body": {
      "transaction": {
        "id": "3478613",
        "timestampUtc": "0001-01-01T00:00:00Z",
        "timezoneUtcOffset": 0,
        "amount": 19975,
        "currency": "USD",
        "responseCode": "203",
        "avsResultCode": "M",
        "cvvResultCode": "NA",
        "processorName": "Acme Payments",
        "cavvResultCode": "2",
        "responseCodeSource": "NMI",
        "responseStatus": "DECLINED",
        "transactionType": "CAPTURE"
      },
      "payer": {
        "id": "customer123",
        "email": "[email protected]"
      },
      "billingInformation": {
        "firstName": "John",
        "lastName": "Doenowitz",
        "phone": "+1 555-123-4567",
        "country": "United States",
        "countryCode": "US",
        "addressLine1": "123 Main St.",
        "state": "CA",
        "city": "San Francisco",
        "zipcode": "94111"
      },
      "mid": "<FC_MID>",
      "orderId": "{enter a GUUID}",
      "isDeclined": false
    }
  }
}'



Testing scenarios


Transaction rescued by FlexCharge

Transaction was originally declined, then rescued by FlexCharge automatically.

AmountAny amount over $10 and under $200.
NameAny.
Email[email protected] (won't work without this email address)
Card4000002760003184
CVVAny.
Exp dateAny future date.
Format must be MM / YYYY.
PhoneValid US phone number, complete with country code.

✔️

Successful test results

  • Transaction was sent over to FlexCharge
  • The client side: Customer is redirected to success page
  • Test transaction appears as successful on your CRM


Transaction that doesn't need FlexCharge

Test that your regular transactions are not affected by the widgets: run a successful transaction with your usual test card.

✔️

Successful test results

  • Transaction was not sent over to FlexCharge
  • Client side and Merchant's CRM behave as expected

That's it you're good to go!