Authorize.Net payment method

Accept.js is a JavaScript-based solution for sending secure payment data directly to Authorize.Net. The Accept JavaScript library intercepts the payment data before it is passed to Magento and submits it directly to Authorize.Net, which replaces it with a one-time-use token, or payment nonce. This payment nonce, which is returned by the JavaScript library, is used in place of payment data.

Authorize.Net workflow

The following diagram shows the workflow for placing an order when Authorize.Net is the selected payment method.

Authorize.Net sequence diagram

  1. The customer clicks on the Place order button. The embedded Accept.js library captures the payment data and submits it directly to Authorize.Net.

  2. Authorize.Net returns a payment nonce and order details. The client’s browser then posts the nonce to the Magento server along with all the other order information. The payment nonce expires after 24 hours.

  3. The client uses the setPaymentMethodOnCart mutation to send the payment nonce and the last four digits of the card to Magento.

  4. Magento returns a Cart object.

  5. The client runs the placeOrder mutation, which creates an order in Magento and begins the authorization process.

  6. Magento sends a transaction request that includes the payment nonce. The nonce replaces the payment details provided in standard Authorize.Net API calls.

  7. Authorize.Net sends a transaction response.

  8. Magento creates an order and sends an order ID in response to the placeOrder mutation.

Additional payment information

When you set the payment method to authorizenet_acceptjs in the setPaymentMethodOnCart mutation, the payload must contain an authorizenet_acceptjs object.

Attribute Data Type Description
cc_last_4 Int! The last four digits of the credit or debit card
opaque_data_descriptor String! Authorize.Net’s description of the transaction request
opaque_data_value String! The nonce returned by Authorize.Net

Example usage

The following example assigns the authorizenet_acceptjs payment method to the specified cart.

Request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mutation {
  setPaymentMethodOnCart(input: {
    cart_id: "lvdqOLzryManseE2artECZuPClxFgG1o"
    payment_method: {
      code: "authorizenet_acceptjs"
      authorizenet_acceptjs: {
        cc_last_4: 1111
        opaque_data_descriptor: "COMMON.ACCEPT.INAPP.PAYMENT"
        opaque_data_value: "<nonce_value>"
        }
      }
  }) {
    cart {
      selected_payment_method {
        code
        title
      }
    }
  }
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
{
  "data": {
    "setPaymentMethodOnCart": {
      "cart": {
        "selected_payment_method": {
          "code": "authorizenet_acceptjs",
          "title": "Credit Card (Authorize.Net)"
        }
      }
    }
  }
}