Download the PHP package whatwedo/sylius-datatrans-payment-plugin without Composer

On this page you can find all versions of the php package whatwedo/sylius-datatrans-payment-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-datatrans-payment-plugin

Sylius Datatrans Payment Plugin

Datatrans payment gateway for Sylius, based on the Datatrans JSON API v1 and the Redirect payment page.

Requirements

Installation

Register the bundle in config/bundles.php if Symfony Flex did not do it:

Import the routes, e.g. in config/routes/whatwedo_sylius_datatrans_payment.yaml:

Gateway configuration

Create a payment method in the Sylius admin and choose the gateway Datatrans Payment.

Field Description
Merchant ID Your Datatrans merchant id.
Password Server-to-server API password. In the Datatrans dashboard go to UPP Administration > Security. The stored password is never rendered back; leave the field empty to keep it.
Endpoint https://api.sandbox.datatrans.com for testing, https://api.datatrans.com for production. The payment page (pay.sandbox.datatrans.com / pay.datatrans.com) is derived from it.
Sign / HMAC SHA256 Legacy settings of the old XML/redirect API. They are optional and unused: JSON API v1 requests are authenticated with merchant id and password.
Generate link Do not redirect the customer during checkout, only create the transaction. Used for payment links created in the admin (see below).
Payment methods Payment methods offered on the Datatrans payment page (Visa, Mastercard, TWINT, PostFinance Pay, ...).

Payment flow

  1. On checkout the capture action creates a transaction (POST /v1/transactions) with the payment amount and currency, the order number as refno and the order locale as payment page language (falls back to de if Datatrans does not support the locale). The customer is redirected to the Datatrans payment page.
  2. Datatrans redirects back to Sylius, which asks the gateway for the payment status (GET /v1/transactions/{id}). The response is stored in the payment details under datatrans.
  3. If a payment already has a paid or authorized transaction, retrying the payment does not create a second transaction. A new transaction is only created if Datatrans reports a definite status for the existing ones that is neither paid nor authorized. If their status cannot be determined (Datatrans error response, network error), no new transaction is created and the customer can retry later.
  4. When a transaction is replaced, its id is moved to previousTransactionIds in the payment details, so the id of a transaction that is paid after it was replaced (e.g. in a second browser tab) is kept. If the current transaction is not paid, the status check also looks at these previous transactions and completes the payment if one of them is paid. If the status of a previous transaction cannot be determined, the payment status is unknown and the payment is left unchanged until a later check succeeds.
Datatrans status Sylius payment
settled, transmitted completed
authorized authorized
canceled cancelled
failed failed
initialized new
challenge_required, challenge_ongoing, authenticated, anything else unchanged (unknown)

A paid or authorized status is only accepted if currency and amount reported by Datatrans match the Sylius payment; otherwise the status is treated as unknown and the payment is left untouched for manual review: it is neither completed nor cancelled automatically. If the transaction could not be created, the Datatrans error is stored in the payment details under error and the payment fails.

Status check command

Customers sometimes close the browser before they are redirected back to the shop. The following command fetches the status of all Datatrans payments in state new or authorized that have a transaction and applies the transitions from the table above.

A payment in state new is cancelled after two weeks if Datatrans still reports a pending status (initialized, challenge_required, challenge_ongoing, authenticated) for it. The two weeks are counted from the later of the payment creation date and the transaction expiry (detail.init.expires). The timeout never cancels payments in state authorized, payments with a paid current or previous transaction, or payments for which the status of the current or a previous transaction could not be fetched (Datatrans error or network error). Payments without a current transaction (e.g. the replacement could not be created) are checked through their previous transactions only. If a payment cannot be checked, its changes are discarded and the next payment is checked; if the entity manager was closed by a database error, the command stops and exits with a non-zero code.

Run it regularly, e.g. every 10 minutes:

Payment links from the admin

With Generate link enabled, a payment whose details contain a payment-link entry (the URL the customer returns to after paying, e.g. the shop order page) can be paid through /pay-from-link/{payment}?token={order token}. The route only works for payments in state new and returns a 404 if the token query parameter does not match the order's token value.

Show the link with a copy button in an admin template that has a payment variable:

Development

The tests are plain unit tests (tests/Unit) and need no database or Sylius application.


All versions of sylius-datatrans-payment-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
payum/core Version ^1.7
sylius/sylius Version >=1.11
symfony/http-client Version ^5.4 || ^6.0 || ^7.0 || ^8.0
symfony/validator Version ^5.4 || ^6.0 || ^7.0 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package whatwedo/sylius-datatrans-payment-plugin contains the following files

Loading the files please wait ...