This page explains how to add Swish to your existing iOS Components integration.
Requirements
Select the server-side flow that your integration uses:
Requirement | Description |
---|---|
Integration type | Make sure that you have built a Sessions flow iOS Components integration. |
Setup steps | Before you begin, add Swish in your Customer Area. |
API reference
You do not need to send additional fields for Swish. To see optional fields that you can send for all payment methods, choose the endpoint you integrated:
- /sessions: This is the default with Components v5.0.0 or later.
- /payments: If you implemented an additional use case.
Component configuration
v5.0.0 or later
If your integration uses iOS Components v5.0.0 or later, configure and create an instance of the Swish Component:
let paymentMethods = session.sessionContext.paymentMethods // Check that the payment method is supported before showing the Component. guard let paymentMethod = paymentMethods.paymentMethod(ofType: .other("swish")) else { return } let component = InstantPaymentComponent(paymentMethod: paymentMethod, context: context, order: nil) self.currentComponent = component // Set the session as the delegate. component.delegate = session component.initiatePayment()
v4.x.x
If your integration uses an earlier version of iOS Components:
// Check that the payment method is supported before showing the Component. guard let paymentMethod = paymentMethods.paymentMethod(ofType: SwishPaymentMethod.self) else { return } let style = FormComponentStyle() let component = SwishComponent(paymentMethod: paymentMethod, apiContext: context, style: style) present(component)
There are no configuration steps specific to Swish required for Components.
Test and go live
When you make a Swish payment in the test environment, the payment is authorised within 15 seconds. You can simulate different refusal scenarios, as outlined in the Merchant Swish Simulator, by adding the error code to the shopperStatement
property. For example, "shopperStatement": "FF08"
.
Check the status of Swish test payments in your Customer Area > Transactions > Payments.
To accept live Swish payments, you must submit a request for Swish in your live Customer Area.