This is a beta release of documentation for Magento 2.4, published for previewing soon-to-be-released functionality. Content in this version is subject to change. Links to the v2.4 code base may not properly resolve until the code is officially released.

createPayflowProToken mutation

The createPayflowProToken mutation initiates a Payflow Pro transaction and receives a token. The payload must contain the redirect URLs to use when the transaction is successful, when the customer cancels the transaction, or when an error occurs.

See Paypal Payflow Pro payment method for detailed information about the workflow of PayPal Payflow Pro transactions.

Syntax

createPayflowProToken(input: PayflowProTokenInput): CreatePayflowProTokenOutput

Example usage

The following example requests a token in a Payflow Pro transaction.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mutation {
  createPayflowProToken(
    input: {
      cart_id: "Po1WkfK7d3vZE0qga610NwJIbxgqllpt"
      urls: {
        return_url: "paypal/action/return.html"
        cancel_url: "paypal/action/cancel.html"
        error_url: "paypal/action/error.html"
      }
    }
  ) {
    response_message
    result
    result_code
    secure_token
    secure_token_id
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
{
  "data": {
    "createPayflowProToken": {
      "response_message": "Approved",
      "result": 0,
      "result_code": 0,
      "secure_token": "5JRGtIDsaJUuEPq0lR5m9ugqG",
      "secure_token_id": "H3roFRhGjKzxCKr5TlA8mooClBpQxgBY"
    }
  }
}

Input attributes

The createPayflowProToken mutation requires the cart_id and a set of response URLs.

PayflowProTokenInput object

The PayflowProTokenInput object must contain the following attributes:

Attribute Data Type Description
cart_id String! The unique ID that identifies the customer’s cart
urls PayflowProUrlInput! A set of URLs that PayPal uses for callback

PayflowProUrlInput object

The PayflowProUrlInput object contains a set of relative URLs that PayPal will use in response to various actions during the authorization process. Magento prepends the base URL to this value to create a full URL. For example, if the full URL is https://www.example.com/path/to/page.html, the relative URL is path/to/page.html.

Use this input for Payflow Pro and Payment Pro payment methods.

The PayflowProUrlInput object must contain the following attributes:

Attribute Data Type Description
cancel_url String! The relative URL of the page that PayPal will redirect to when the buyer cancels the transaction in order to choose a different payment method. If the full URL to this page is https://www.example.com/paypal/action/cancel.html, the relative URL is paypal/action/cancel.html
error_url String! The relative URL of the transaction error page that PayPal will redirect to upon payment error. If the full URL to this page is https://www.example.com/paypal/action/error.html, the relative URL is paypal/action/error.html
return_url String! The relative URL of the final confirmation page that PayPal will redirect to upon payment success. If the full URL to this page is https://www.example.com/paypal/action/return.html, the relative URL is paypal/action/return.html

Output attributes

The createPayflowProToken mutation previously returned a PayflowProToken object, which has been deprecated. The mutation now returns a CreatePayflowProTokenOutput object. The contents of these objects are identical.

The CreatePayflowProTokenOutput object contains the following attributes:

Attribute Data Type Description
response_message String! The RESPMSG returned by PayPal. If the result is 0, the response_message is Approved
result Int! Contains a non-zero value if any errors occurred
result_code Int! The RESULT returned by PayPal. A value of 0 indicates the transaction was approved
secure_token String! Secure token generated by PayPal
secure_token_id String! Secure token ID generated by PayPal