sol-parts / payum-wayforpay
Payum gateway for WayForPay acquiring: hosted checkout, AUTH hold payments, signed callbacks and refunds
Requires
- php: >=8.2
- ext-json: *
- ext-mbstring: *
- payum/core: ^1.7
- php-http/discovery: ^1.14
- psr/http-factory: ^1.0
- psr/http-message: ^1.1|^2.0
Requires (Dev)
- nyholm/psr7: ^1.8
- phpunit/phpunit: ^11.5
Suggests
- sol-parts/payum-contracts: Dispatch the shared DoCapture request to settle (SETTLE) AUTH hold payments
Provides
None
Conflicts
None
Replaces
None
README
Provides WayForPay acquiring integration for
Payum: hosted checkout with instant debit
(SALE) or two-stage hold payments (AUTH), signed callbacks and refunds.
All signatures are HMAC-MD5 over the documented fields joined with ;.
Supported operations:
Capture— create the payment page server-to-server (PURCHASEwithbehavior=offline) and redirect the customer to the returned URL.Authorize— same flow withmerchantTransactionType=AUTH: the funds are locked on the customer's card and the store settles the payment later.DoCapture(the shared request fromsol-parts/payum-contracts, when installed) — settle anAUTHhold viaSETTLEfor the payment amount.Cancel— release an activeAUTHhold viaREFUND(resultVoided). For any other state it is a no-op.Refund— refund of a paid order viaREFUND, full payment amount.Notify— theserviceUrlcallback triggers aCHECK_STATUSsync and is answered with the signedacceptacknowledgement WayForPay requires.Sync— re-fetch the order state viaCHECK_STATUS.GetStatus— maps WayForPay transaction statuses to Payum ones (see the table below).
Responses of CHECK_STATUS, SETTLE and REFUND are verified against their
merchantSignature before the state is applied.
Payment flow
sequenceDiagram
autonumber
actor C as Customer
participant S as Store
participant W as WayForPay
C->>S: Places an order
S->>W: PURCHASE (behavior=offline)
W-->>S: Payment page URL
S-->>C: Redirect to the payment page
C->>W: Pays
W-->>C: Redirect to returnUrl
W->>S: Callback to serviceUrl
S->>W: CHECK_STATUS
S-->>W: Signed accept
S-->>C: Order result page
Loading
While an order is still payable the capture flow does not create a new payment: the returning customer is redirected to the same payment page.
Status mapping
| Transaction status | Payum status |
|---|---|
InProcessing, Pending, RefundInProcessing |
pending |
WaitingAuthComplete |
authorized — the funds are locked, the store settles via DoCapture |
Approved |
captured |
Refunded, Voided |
refunded — covers both a released hold and a refunded payment; the host application distinguishes them by the previous transaction state |
Declined with reason code 1104 (insufficient funds) |
pending — the customer can retry on the same payment page |
Declined |
failed |
Expired |
expired |
Statuses are matched case-insensitively.
Installation
composer require sol-parts/payum-wayforpay
Usage with PayumBuilder
use Payum\Core\GatewayFactoryInterface; use Payum\Core\PayumBuilder; use SolParts\PayumWayForPay\WayForPayGatewayFactory; $payum = (new PayumBuilder()) ->addGatewayFactory('wayforpay', static function (array $config, GatewayFactoryInterface $coreGatewayFactory) { return new WayForPayGatewayFactory($config, $coreGatewayFactory); }) ->addGateway('wayforpay', [ 'factory' => 'wayforpay', 'merchant_account' => 'your-merchant-account', 'secret_key' => 'your-secret-key', ]) ->getPayum();
Usage with Symfony PayumBundle
Register the gateway factory:
# config/services.yaml services: app.wayforpay_gateway_factory: class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder arguments: [SolParts\PayumWayForPay\WayForPayGatewayFactory] tags: - { name: payum.gateway_factory_builder, factory: wayforpay }
Configure a gateway:
# config/packages/payum.yaml payum: gateways: wayforpay: factory: wayforpay merchant_account: '%env(WAYFORPAY_MERCHANT_ACCOUNT)%' secret_key: '%env(WAYFORPAY_SECRET_KEY)%'
Options
| Option | Required | Description |
|---|---|---|
merchant_account |
yes | Merchant account issued by WayForPay. |
secret_key |
yes | Merchant secret key used for all request and response signatures. |
WayForPay publishes a test merchant for integration testing in its documentation.
Payment details
ConvertPaymentAction fills amount — in major units, as a string with two
decimals (1547.36) — currency, orderReference, orderDate and a single
product line with the payment description, so the product total always equals
the payment amount including discounts and delivery.
The gateway attaches returnUrl to the after-URL of the payment token and
serviceUrl to a notify token. merchantDomainName is taken from the
returnUrl host unless the payment details provide it.
Caveats
REFUNDis a single operation for both releasing a hold and refunding a captured payment. The gateway always uses the full payment amount; partial refunds are not implemented.- A
REFUNDresponse is signed with four fields only (merchantAccount,orderReference,transactionStatus,reasonCode), unlikeCHECK_STATUSandSETTLE. - Error responses are reported with the HTTP status code and a truncated body snippet — balancer errors (429, 5xx) answer with HTML, not JSON.
License
Released under the MIT License.