You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/integrate_with_govuk_pay/index.html.md.erb
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -57,8 +57,24 @@ In some cases you may be comfortable releasing a service before a payment has be
57
57
In most cases, you’ll want to confirm that a payment has been completed before releasing the service to your users. Typically you’ll do this when your user visits the `return_url` on your service.
58
58
59
59
The following example UML sequence diagram shows a typical happy-path payment journey:
60
-
61
-

60
+

61
+
62
+
1. A user visits your service and tells you they want to make a payment. The user typically does this with some kind of call to action, such as a Buy a fishing license button.
63
+
1. The user’s browser sends a request to your service to start the payment journey.
64
+
1. Your service starts a user session.
65
+
1. Your service creates a payment using the `POST /v1/payments` endpoint. This request includes `amount`, `description`, `reference`, and `return_url` values for the payment. You can [read more about these parameters in our API reference](/api_reference/create_a_payment_reference/#json-body-parameters-for-39-create-a-payment-39).
66
+
1. GOV.UK Pay returns a `201` successful response. This response contains `payment_id` and `next_url` attributes.
67
+
1. Your service extracts the values of `payment_id` and `next_url` from the response.
68
+
1. Your service stores the `payment_id` in a list of incomplete payment journeys, and records the incomplete journey in the user session.
69
+
1. Your service uses a `302` redirect to send the user to the `next_url` from the payment creation response. The user’s browser will automatically follow this redirect.
70
+
1. The user enters their card details on GOV.UK Pay and confirms the payment.
71
+
1. GOV.UK Pay redirects the user to the `return_url` you sent when you created the payment.
72
+
1. Your service gets the `return_url` from the session cookie.
73
+
1. Your service finds the incomplete payment journey using data from the user session, then looks up the `payment_id`.
74
+
1. Your service gets information about the outcome of the payment from GOV.UK Pay using the `GET /v1/payments/{PAYMENT_ID}` endpoint.
75
+
1. GOV.UK Pay returns a `200` response that includes `”status”: “success”` or `”status”: “failed”`, depending on the outcome of the payment.
76
+
1. Your service marks the payment journey as complete.
77
+
1. Your service displays a payment success or payment failure confirmation screen to your user, depending on the payment status.
62
78
63
79
## Identifying your user when they return to your service
0 commit comments