Skip to content

Commit

Permalink
Merge pull request #2006 from SwedbankPay/feature/dx-2207_post_purcha…
Browse files Browse the repository at this point in the history
…se_31

DX-2207: Post Purchase 3.1 and other stuff.
  • Loading branch information
arebra authored Oct 23, 2023
2 parents 0905b60 + 78cfd5e commit ff658ba
Show file tree
Hide file tree
Showing 11 changed files with 740 additions and 19 deletions.
4 changes: 4 additions & 0 deletions _includes/callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Menu v1), it is critical that you do **not** use the `paymentId` or
`transactionId` when performing a `GET` to retrieve the payment's status. Use
the `paymentOrderId`.

## Callback Example

{% if api_resource == "paymentorders" %}

{:.code-view-header}
Expand All @@ -87,6 +89,8 @@ the `paymentOrderId`.
}
```

## Callback Example v3.1

If you have implemented v3.1, the callback will only contain the `paymentOrder`
node.

Expand Down
7 changes: 4 additions & 3 deletions _includes/checkout-v3-resource-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Content-Type: application/json
{% endcapture %}
{% include accordion-table.html content=table %}

## FailedPostPurchaseAttempts (3.1 only)
## FailedPostPurchaseAttempts

{:.code-view-header}
**Request**
Expand All @@ -274,15 +274,16 @@ Content-Type: application/json
GET /psp/paymentorders/{{ page.payment_order_id }}/failedpostpurchaseattempts HTTP/1.1
Host: {{ page.api_host }}
Authorization: Bearer <AccessToken>
Content-Type: application/json
Accept: application/json;version=3.1
```

{:.code-view-header}
**Response**

```http
HTTP/1.1 200 OK
Content-Type: application/json
Content-Type: application/json; charset=utf-8; version=3.1
api-supported-versions: 3.0, 3.1
{
"paymentorder": "/psp/paymentorders/5adc265f-f87f-4313-577e-08d3dca1a26c",
Expand Down
2 changes: 1 addition & 1 deletion _includes/fields/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
href='/features/technical-reference/status' -%}
{%- endcapture -%}
{%- capture text -%}
`Initialized`, `Paid`, `Failed`, `Cancelled`, or `Aborted`. Indicates the
`Initialized`, `Paid`, `Failed`, `Reversed` `Cancelled`, or `Aborted`. Indicates the
{% clink payment order's current status %}{{ url }}{% endclink %}.
{%- endcapture -%}
{%- comment -%}
Expand Down
6 changes: 3 additions & 3 deletions _includes/payment-order-3-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Content-Type: application/json;version=3.1
"description": "Test Purchase",
"userAgent": "Mozilla/5.0...",
"language": "sv-SE",
"instrument": false,
"implementation": "PaymentsOnly",
"instrument": null,
"urls": {
"hostUrls": [ "https://example.com", "https://example.net" ], //Seamless View only
"paymentUrl": "https://example.com/perform-payment",
Expand Down Expand Up @@ -94,7 +93,8 @@ Content-Type: application/json;version=3.1

```http
HTTP/1.1 200 OK
Content-Type: application/json
Content-Type: application/json; charset=utf-8; version=3.1
api-supported-versions: 2.0, 3.0, 3.1
{
"paymentorder": {
Expand Down
187 changes: 187 additions & 0 deletions _includes/payment-order-cancel-3-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{% capture features_url %}{% include utils/documentation-section-url.md href='/features' %}{% endcapture %}
{% capture documentation_section %}{% include utils/documentation-section.md %}{% endcapture %}

## Cancel v3.1

The `cancellations` resource lists the cancellation transactions on a
specific payment.

## Create Cancel Transaction

{% if documentation_section contains "checkout-v3" %}

To cancel a previously created payment, you must perform the `cancel` operation
against the accompanying `href` returned in the `operations` list. You can only
cancel a payment - or part of a payment - which has not been captured yet.

{% else %}

To cancel a previously created payment, you must perform the
`create-paymentorder-cancel` operation against the accompanying `href` returned
in the `operations` list. You can only cancel a payment - or part of a payment -
which has not been captured yet.

{% endif %}

## Cancel Request v3.1

{:.code-view-header}
**Request**

```http
POST /psp/paymentorders/{{ page.payment_order_id }}/cancellations HTTP/1.1
Host: {{ page.api_host }}
Authorization: Bearer <AccessToken>
Content-Type: application/json;version=3.1
{
"transaction": {
"description": "Test Cancellation",
"payeeReference": "ABC123"
}
}
```

{:.table .table-striped}
| Required | Field | Type | Description |
| :--------------: | :----------------------- | :----------- | :--------------------------------------------------------------------------------------------- |
| {% icon check %} | `transaction` | `object` | The transaction object. |
| {% icon check %} | {% f description %} | `string` | A textual description of why the transaction is cancelled. |
| {% icon check %} | {% f payeeReference %} | `string` | {% include fields/payee-reference.md %} |

## Cancel Response v3.1

If the cancel request succeeds, the response should be similar to the
example below:

{:.code-view-header}
**Response**

```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8; version=3.1
api-supported-versions: 3.1
{
"paymentOrder": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d",
"created": "2020-03-03T07:19:27.5636519Z",
"updated": "2020-03-03T07:21:00.5605905Z",
"operation": "Purchase",
"status": "Cancelled",
"currency": "SEK",
"amount": 1500,
"vatAmount": 375,
"remainingCaptureAmount": 0,
"remainingCancellationAmount": 0,
"remainingReversalAmount": 0,
"description": "Test Purchase",
"initiatingSystemUserAgent": "<should be set by the system calling POST:/psp/paymentorders>",
"language": "sv-SE",
"availableInstruments": [ "CreditCard", "Invoice-PayExFinancingSe", "Invoice-PayMonthlyInvoiceSe", "Swish", "CreditAccount", "Trustly" ],
"implementation": "PaymentsOnly",
"integration": "HostedView|Redirect",
"instrumentMode": true,
"guestMode": true,
"orderItems": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/orderitems"
},
"urls": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/urls"
},
"payeeInfo": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/payeeInfo"
},
"payer": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/payers"
},
"history": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/history"
},
"failed": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/failed"
},
"aborted": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/aborted"
},
"paid": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/paid"
},
"cancelled": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/cancelled"
},
"financialTransactions": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/financialtransactions"
},
"failedAttempts": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/failedattempts"
},
"postpurchaseFailedAttempts": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/postpurchasefailedattempts"
},
"metadata": {
"id": "/psp/paymentorders/8be318c1-1caa-4db1-e2c6-08d7bf41224d/metadata"
}
},
"operations": [
]
}
```

{% capture table %}
{:.table .table-striped .mb-5}
| Property | Type | Description |
| :-------------------------- | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {% f paymentOrder, 0 %} | `string` | The relative URL of the payment order this capture transaction belongs to. |
| {% f id %} | `string` | The relative URL of the created capture transaction. |
| {% f created %} | `string` | The ISO-8601 date and time of when the transaction was created. |
| {% f updated %} | `string` | The ISO-8601 date and time of when the transaction was updated. |
| {% f operation %} | `string` | {% include fields/operation.md %} |
| {% f status %} | `string` | {% include fields/status.md %} |
| {% f currency %} | `string` | The currency of the payment order. |
| {% f amount %} | `integer` | {% include fields/amount.md %} |
| {% f vatAmount %} | `integer` | {% include fields/vat-amount.md %} |
| {% f remainingCaptureAmount %} | `integer` | The remaining authorized amount that is still possible to capture. |
| {% f remainingCancellationAmount %} | `integer` | The remaining authorized amount that is still possible to cancel. |
| {% f remainingReversalAmount %} | `integer` | The remaining captured amount that is still available for reversal. |
| {% f description %} | `string` | {% include fields/description.md %} |
| {% f initiatingSystemUserAgent %} | `string` | {% include fields/initiating-system-user-agent.md %} |
| {% f language %} | `string` | {% include fields/language.md %} |
| {% f availableInstruments %} | `string` | A list of instruments available for this payment. |
| {% f implementation %} | `string` | The merchant's Digital Payments implementation type. `Enterprise` or `PaymentsOnly`. We ask that you don't build logic around this field's response. It is mainly for information purposes, as the implementation types might be subject to name changes. If this should happen, updated information will be available in this table. |
| {% f integration %} | `string` | The merchant's Digital Payments integration type. `HostedView` (Seamless View) or `Redirect`. This field will not be populated until the payer has opened the payment UI, and the client script has identified if Swedbank Pay or another URI is hosting the container with the payment iframe. We ask that you don't build logic around this field's response. It is mainly for information purposes. as the integration types might be subject to name changes, If this should happen, updated information will be available in this table. |
| {% f instrumentMode %} | `bool` | Set to `true` or `false`. Indicates if the payment is initialized with only one payment instrument available. |
| {% f guestMode %} | `bool` | Set to `true` or `false`. Indicates if the payer chose to pay as a guest or not. When using the Payments Only implementation, this is triggered by not including a `payerReference` in the original `paymentOrder` request. |
| {% f orderItems %} | `string` | The URL to the `orderItems` resource where information about the order items can be retrieved. |
| {% f urls %} | `string` | The URL to the `urls` resource where all URLs related to the payment order can be retrieved. |
| {% f payeeInfo %} | `string` | {% include fields/payee-info.md %} |
| {% f payer %} | `string` | The URL to the [`payer` resource]({{ features_url }}/technical-reference/resource-sub-models#payer) where information about the payer can be retrieved. |
| {% f history %} | `string` | The URL to the `history` resource where information about the payment's history can be retrieved. |
| {% f failed %} | `string` | The URL to the `failed` resource where information about the failed transactions can be retrieved. |
| {% f aborted %} | `string` | The URL to the `aborted` resource where information about the aborted transactions can be retrieved. |
| {% f paid %} | `string` | The URL to the `paid` resource where information about the paid transactions can be retrieved. |
| {% f cancelled %} | `string` | The URL to the `cancelled` resource where information about the cancelled transactions can be retrieved. |
| {% f financialTransactions %} | `string` | The URL to the `financialTransactions` resource where information about the financial transactions can be retrieved. |
| {% f failedAttempts %} | `string` | The URL to the `failedAttempts` resource where information about the failed attempts can be retrieved. |
| {% f postpurchaseFailedAttempts %} | `string` | The URL to the `postpurchaseFailedAttempts` resource where information about the failed capture, cancel or reversal attempts can be retrieved. |
| {% f metadata %} | `string` | The URL to the `metadata` resource where information about the metadata can be retrieved. |
| {% f operations %} | `array` | {% include fields/operations.md %} [See Operations for details]({{ features_url }}/technical-reference/operations). |
{% endcapture %}
{% include accordion-table.html content=table %}

## Cancel Sequence Diagram

Cancel can only be done on a authorized transaction. If you perform a cancel
after doing a partial capture, you will cancel the remaining authorized amount.

```mermaid
sequenceDiagram
participant SwedbankPay as Swedbank Pay
Merchant->>SwedbankPay: POST < {{ include.api_resource }} cancellation>
activate Merchant
activate SwedbankPay
SwedbankPay-->>Merchant: transaction resource
deactivate SwedbankPay
deactivate Merchant
```
Loading

0 comments on commit ff658ba

Please sign in to comment.