Skip to main content

Opayo (Sage Pay)

Classic WebBased payment system

init

The fields success_url and failure_url are used to manage the return redirection.

It should be noted that context can be lost during redirection, so it is recommended to include cart-id and public-txn-id in the URL. The specific method of adding them depends on the application, but it is preferable to include them in the PATH.

Example:

http://xcart.test/payment_return/{cart-id}/{public-txn-id} (PATH)

http://xcart.test/payment_return?cart_id={cart-id}&public_txn_id={public-txn-id} (query string)

The transaction status is changed from I (STATUS_INITIALIZED) to P (STATUS_INPROGRESS)

PATCH api/storefront/carts/{cart-id}/payment/{public-txn-id}

{
"action": "init",
"actionMetaData": [
{
"name": "success_url",
"value": "http://xcart.test/payment_return/{cart-id}/{public-txn-id}"
},
{
"name": "failure_url",
"value": "http://xcart.test/payment_return/{cart-id}/{public-txn-id}"
}
]
}

Response example

{
"id": "000007-IM2D",
"status": "P",
"value": 19.99,
"type": "sale",
"data": [
{
"name": "test_mode",
"value": "1"
}
],
"backendTransactions": [],
"processor": "XC\\SagePay\\Model\\Payment\\Processor\\SagePayForm",
"actionData": [
{
"name": "VPSProtocol",
"value": "4.00"
},
{
"name": "TxType",
"value": "PAYMENT"
},
{
"name": "Vendor",
"value": "xcarttest"
},
{
"name": "Crypt",
"value": "@b82b95d810a9803ac0ac652aa9f59c68b6597fc0ebaf1bb5cea29e0f8401911a1f32020125dbf578089f0012f25e82388de55f6d24a63f48dbe44185672185d89117aea9107ac428a4d2f4879ec40b2a4e49039145cef52d82d07526a698d4c2e66194730a053e4c01b5d83f7c822fcf28458715034cc03b90ab90f1e571fcccb122790144e5937fbe7a3be4e3926ba9261b6a6fdb73de8b74deeeaee401259e7816087faa489b465c7040d752df4543e09a46f350ff59cf0ab7d4ea325ff95ca9df381214e107db16da8d38796a050c1db26e8250d003176b684c12c7656d820e74f5ea01422c09fcc0bb185ef62500d2d1e70b015b3b4aa216dde47f669378184b70ae6ad075c054b9285c73101acf36743016091fefc57020ba8f67947e49af7dbb41c7465c874ce421f38689ef50de05a2819f57fda265e103c6b0e333b8f19dd16b85e42cab2e035bc6ce909b8284667fdfb3b2b42e904b5e060b66a40aa9b175466257e5acad259f6dadb000281b18e2772f5f7e1110fd099c5d86fd0dfce6945dfc19d2dece636c38cb81ed8d2486e66fcad4d712ad4e00b41525fec70a0bad7213879419001a1ac8b390706f31467799e3a26e09d60227833b0849ada5caee72a411f5e342f98bb1946c29936386c89c44539300213a663b82c5de3ab66fb43d129274a08ea485cf0133129121d8d4424813adead1d1de1cfd8e11d3aa36f6d095fc10fc06bc0701cd8ae7606d1a59ce80dfd7bd062727e76f878ebb249fa3e4cbe34b0d9762e63ebd5ff71e606e99d650096cc27a3823cb3e6ff930cb2d70f183b2a7b1387fa93185f43469e3ffd6d02c7477b9de151da3b63f2e1b0a96423c4aaf5db2ff49f111f7794069177deccbe838fdd33fc2cd3c117d139f177400e0c841574c9b1d4919f86db45c9362849f450d02acf2ef7233eb53052e3f28a2f721066a3889429da673be124d"
}
],
"actionMetaData": [
{
"name": "url",
"value": "https://test.sagepay.com/gateway/service/vspform-register.vsp"
},
{
"name": "method",
"value": "post"
}
]
}

The actionData field contains data for redirection.

The actionMetaData field contains the redirection value - the URL and the method.

Redirection should be done through form submission. For example (pseudocode):

<form action="{actionMetaData.url}" method="{actionMetaData.method}">
<input type="text" name="VPSProtocol" value="{actionData.VPSProtocol}" />
<input type="text" name="TxType" value="{actionData.TxType}" />
<input type="text" name="Vendor" value="{actionData.Vendor}" />
<input type="text" name="Crypt" value="{actionData.Crypt}" />
</form>

As a result, the user will be redirected to one of the URLs specified in the init request. In the GET data, there will be a field named crypt whose value needs to be included in the pay request.

pay

The crypt field from the payment system's return data needs to be supplied in the pay request.

PATCH api/storefront/carts/{cart-id}/payment/{public-txn-id}

{
"action": "pay",
"actionData": [
{
"name": "crypt",
"value": "@b82b95d810a9803ac0ac652aa9f59c68e90c55d9066b0bac351ab9105ec539268d97cc7c6f63de9f7466160dfb2f189c19fa2ec470751ce9d438316855fb32bf30ebf1f84c79761495df990c3e7c3a72afb44cb9c02cfe753c55a8ab278c0c669e842e49368195e27ec7e2b83c4a0515047fc740160f676f6df0c938e5a99fff2302c543c47e92c03df1d8c9898abaaccdfd208e908c5a0cb17785768c0b85d8b8b462892e0ba73d1835ded1bfd75533ecb989367dff465832d8689b100969a2c093af78f0c89a8310b1e394ecf94a7b1451a9ab5a287dff1eef321c6400fc852f6e6870591dc7891be98f52d8d9f75b2db39b4aefd1a7e9a7d454becf4732dd2a210eaa158aeaaee0c810fe6d017552169b62dc06ce122fae2122390272704b01f7ec96300c6cc720fef4834a4d2d005b027fc5d13963a16e84d3f01221d41678b73083e8ca34c05221d0d452915ce266935995df5270bb7a059e1c2976384674e7c0750dbf929bb37bc9b62698edefe16c9d2f047ebd3bc19c8512bc30cca2f2a3328f82e8129aa8fff6da7500f670e202d8c1cd68eb67dcfae2638e33b71b6c3817558ccf53a78073ae84fbf9ec882e7a5f5e96c827d202d0ff979bcd3e7fa0f247879cde0ee87376f681b63c40e264aec8c4c0ccfffd2f023d649cdc6a8fab35d08ddb303d66fa33a46b71e237cdb6f12db560c6993bd7151b4d393baa64de645e03c93b2a8e307702d95a240de0277c7ae1ea95a6ec7bc713f78e88799b5290c23c5b6f51a94da845913b0ef61f2ba61de529c0eb114e3a6913f32e0903d34cf4bc45fe285fa784fd79b95b99bb"
}
]
}