Swiftpack.co - Adyen/adyen-terminal-api-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Adyen.
Adyen/adyen-terminal-api-ios 1.1.0
Adyen Terminal API for iOS
⭐️ 1
🕓 2 weeks ago
iOS
.package(url: "https://github.com/Adyen/adyen-terminal-api-ios.git", from: "1.1.0")

Adyen Terminal API for iOS

TerminalAPIKit for iOS helps with integrating Terminal API into your iOS app by providing the necessary models for creating SaletoPOIRequest and SaletoPOIResponse.

Installation

TerminalAPIKit for iOS is available through Swift Package Manager.

Swift Package Manager

  1. Follow Apple's [Adding Package Dependencies to Your App](https://raw.github.com/Adyen/adyen-terminal-api-ios/develop/ https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app ) guide on how to add a Swift Package dependency.
  2. Use https://github.com/Adyen/adyen-terminal-api-ios as the repository URL.
  3. Specify the version to be at least 1.0.0.

Usage

Creating requests

To create a SaleToPOIRequest do the following:

  1. Create an instance of MessageHeader, representing the MessageHeader
    let header = MessageHeader(
        protocolVersion: "3.0",
        messageClass: .service,
        messageCategory: .payment,
        messageType: .request,
        serviceIdentifier: "YOUR_SERVICE_IDENTIFIER",
        saleIdentifier: "YOUR_SERVICE_IDENTIFIER",
        poiIdentifier: "YOUR_POI_IDENTIFIER"
    )
  1. Create an instance of PaymentTransaction, repesenting the the PaymentRequest
    let saleData = SaleData(
        saleTransactionIdentifier:
            TransactionIdentifier(
                transactionIdentifier: "YOUR_TRANSACTION_IDENTIFIER",
                date: Date()
            )
    )
    
    let paymentTransaction = PaymentTransaction(
        amounts: Amounts(
            currency: "TRANSACTION_CURRENCY",
            requestedAmount: TRANSACTION_AMOUNT
        )
    )
    
    let paymentRequest = PaymentRequest(
        saleData: saleData,
        paymentTransaction: paymentTransaction
    )
  1. Combine header and paymentRequest into an instance of Message<PaymentRequest> representing SaleToPOIRequest.
    let message = Message(header: header, body: paymentRequest)
  1. Encode the message to JSON and send it to the appropriate endpoint. TerminalAPIKit provides a Coder class to help with the JSON encoding and decoding.
    let jsonData = try Coder.encode(message)

Receiving responses

Once you have obtained a response from one of the endpoints, decode it from Data as follows:

    let message = try Coder.decode(Message<PaymentResponse>.self, from: response)

The message object has a type of Message<PaymentResponse> that represents SaleToPOIResponse. The header and body properties of the message represent MessageHeader and PaymentResponse respectively.

Requirements

  • iOS 13.0+
  • Xcode 13.4+
  • Swift 5.6

Support

If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our support team.

Contributing

We strongly encourage you to join us in contributing to this repository so everyone can benefit from it:

  • New features and functionality
  • Resolved bug fixes and issues
  • Any general improvements

Read our contribution guidelines to find out how.

License

This repository is open source and available under the MIT license. For more information, see the LICENSE file.

GitHub

link
Stars: 1
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.1.0
2 weeks ago

Removed

  • Requests that are not supported by Adyen's Terminal API:
BatchRequest
CardReaderAPDURequest
CardReaderInitRequest
CardReaderPowerOffRequest
InputUpdateRequest 
LoyaltyRequest
PINRequest
SoundRequest
TransactionReportRequest
TransmitRequest

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics