|
| 1 | +--- |
| 2 | +group: graphql |
| 3 | +title: PayPal Payflow Link payment method |
| 4 | +--- |
| 5 | + |
| 6 | +PayPal [PayFlow Link](https://developer.paypal.com/docs/classic/payflow/integration-guide/) is available for merchants in the United States and Canada only. Customers are not required to have a personal PayPal account. Instead, customers enter their credit card information in a form that is hosted by PayPal. |
| 7 | + |
| 8 | +The Payflow gateway uses a secure token to send non-credit card transaction data to the Payflow server for storage in a way that cannot be intercepted and manipulated maliciously. This token secures the data for a one-time transaction and is valid for 30 minutes. When the AWS client runs the `placeOrder` mutation, Magento requests a secure token. The Payflow server returns the token as a string of up to 32 alphanumeric characters. |
| 9 | + |
| 10 | +## Payflow Link workflow |
| 11 | + |
| 12 | +The following diagram shows the workflow for placing an order when Payflow Link is the selected payment method. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +1. The PWA client uses the [`setPaymentMethodOnCart`]({{page.baseurl}}/graphql/reference/quote-payment-method.html) mutation to set the payment method to `payflow_link`. |
| 17 | + |
| 18 | +2. The mutation returns a `Cart` object. |
| 19 | + |
| 20 | +3. The client runs the [`placeOrder`]({{page.baseurl}}/graphql/reference/quote-place-order.html) mutation, which creates an order in Magento and begins the authorization process. |
| 21 | + |
| 22 | +4. Magento requests a secure token from the Payflow Link gateway. |
| 23 | + |
| 24 | +5. The gateway response includes a secure token, a secure token ID, and the URL to use for requesting the Payflow form in step 9. |
| 25 | + |
| 26 | +6. The `placeOrder` mutation returns an order ID. Magento does not return secure token information. The order has the status `payment pending`. |
| 27 | + |
| 28 | +7. The client runs the [`getPayflowLinkToken`]({{page.baseurl}}/graphql/reference/paypal-get-payflow-link-token.html) mutation to retrieve the secure token information. |
| 29 | + |
| 30 | +8. Magento returns the token information. |
| 31 | + |
| 32 | +9. The client displays a payment form in an iframe rendered from the URL specified by the `paypal_url` from `getPayflowLinkToken` mutation response. When the customer completes the form, the client sends the payment information directly to the Payflow gateway, bypassing the Magento server. |
| 33 | + |
| 34 | +10. After PayPal processes the payment, the gateway runs a silent post request against the Magento server. As a result, Magento sets the order status to pending, and the order is ready to be invoiced. |
| 35 | + |
| 36 | +11. The Payflow gateway returns control of the customer's browser to the client. |
| 37 | + |
| 38 | +## Additional Payment information |
| 39 | + |
| 40 | +You must set the following attributes when setting the payment method to `payflow_link`: |
| 41 | + |
| 42 | +Attribute | Data Type | Description |
| 43 | +--- | --- | --- |
| 44 | +`cancel_url` | String! | The URL PayPal will redirect back to upon payment cancellation |
| 45 | +`error_url` | String! | The URL PayPal will redirect back to upon payment error |
| 46 | +`return_url` | String! | The URL PayPal will redirect back to upon payment success |
| 47 | + |
| 48 | +## Example setPaymentMethodOnCart mutation |
| 49 | + |
| 50 | +The following example shows the [`setPaymentMethodOnCart`]({{page.baseurl}}/graphql/reference/quote-payment-method.html) mutation constructed for the Payflow Link payment method. |
| 51 | + |
| 52 | +**Request** |
| 53 | + |
| 54 | +``` text |
| 55 | +mutation { |
| 56 | + setPaymentMethodOnCart(input: { |
| 57 | + payment_method: { |
| 58 | + code: "payflow_link" |
| 59 | + additional_data: { |
| 60 | + payflow_link: { |
| 61 | + return_url: "https://www.example.com/payflow/test/return", |
| 62 | + error_url: "https://www.example.com/payflow/test/error", |
| 63 | + cancel_url: "https://www.example.com/payflow/test/cancel" |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG" |
| 68 | + }) { |
| 69 | + cart { |
| 70 | + selected_payment_method { |
| 71 | + code |
| 72 | + title |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +**Response** |
| 80 | + |
| 81 | +```json |
| 82 | +{ |
| 83 | + "data": { |
| 84 | + "setPaymentMethodOnCart": { |
| 85 | + "cart": { |
| 86 | + "selected_payment_method": { |
| 87 | + "code": "payflow_link", |
| 88 | + "title": "PayPal Payflow Link" |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
0 commit comments