PHPackages                             phpcommerce/ratepay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. phpcommerce/ratepay

ActiveLibrary[Payment Processing](/categories/payments)

phpcommerce/ratepay
===================

v1.2.1(10y ago)28.4k↓66.7%MIT

Since Jan 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/phpcommerce/php-ratepay)[ Packagist](https://packagist.org/packages/phpcommerce/ratepay)[ Docs](https://github.com/phpcommerce/php-ratepay)[ RSS](/packages/phpcommerce-ratepay/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (6)Used By (0)

php-ratepay
===========

[](#php-ratepay)

Example for a RatePAY checkout
------------------------------

[](#example-for-a-ratepay-checkout)

You need to send at least the following gateway operations:

PAYMENT\_INIT -&gt; PAYMENT\_REQUEST -&gt; PAYMENT\_CONFIRM

```
use Doctrine\Common\Annotations\AnnotationRegistry;
use GuzzleHttp\Client;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Exception\RatePAYException;
use PHPCommerce\Vendor\RatePAY\Service\Payment\GatewayClientImpl;
use PHPCommerce\Vendor\RatePAY\Service\Payment\RatepayBrokerImpl;
use PHPCommerce\Vendor\RatePAY\Service\Payment\RatepayConfiguration;
use PHPCommerce\Vendor\RatePAY\Service\Payment\RatepayCredential;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\AddressType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\ContactsType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\CustomerType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\ExternalType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\PaymentType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\RequestHeadType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\PhoneType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\RequestType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\ShoppingBasketItemType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\Type\ShoppingBasketType;
use PHPCommerce\Vendor\RatePAY\Service\Payment\DeviceFingerprintSnippetGenerator;

require_once('vendor/autoload.php');

AnnotationRegistry::registerAutoloadNamespace(
    'JMS\Serializer\Annotation',
    __DIR__ . "/vendor/jms/serializer/src");

//Client := Guzzle 6.x compatible client
$client = new GatewayClientImpl(new Client(), 'https://gateway-int.ratepay.com/api/xml/1_0');

// you can optionally define a logger which will receice debug log messages from the GatewayClient
//$client->setLogger(new Logger());

$ratepayConfiguration = (new RatepayConfiguration())
    ->setGatewayRequestCredentialProfileId("you-profile-id")
    ->setGatewayRequestCredentialSecuritycode("your-security-code")
    ->setGatewayRequestSystemId("systemId");

$ratepayBroker = new RatepayBrokerImpl($ratepayConfiguration, $client);

try {
    $fingerprinter = new DeviceFingerprintSnippetGenerator("4R8Pay");

    $transactionId = $ratepayBroker->paymentInit();

    $paymentRequest = $ratepayBroker->getRequestBuilder()
        ->external(
            (new ExternalType())
                ->setMerchantConsumerId("D1234567890")
                ->setOrderId("50001234")
        )
        ->customer((new CustomerType())
            ->setFirstName("Max")
            ->setLastName("Mustermann")
            ->setGender(CustomerType::GENDER_MALE)
            ->setDateOfBirth(new DateTime("1985-01-01"))
            ->setIpAddress("123.123.123.123")
            ->setCustomerAllowCreditInquiry(true)
            ->setContacts(
                (new ContactsType())
                    ->setEmail("max.mustermann@test.de")
                    ->setPhone(
                        (new PhoneType ())
                            ->setAreaCode("040")
                            ->setDirectDial("1234567890")
                    )
            )
            ->setAddresses([
                (new AddressType())
                    ->setType(AddressType::ADDRESS_TYPE_BILLING)
                    ->setFirstName("Max")
                    ->setLastName("Mustermann")
                    ->setStreet("Musterstraße")
                    ->setStreetNumber("77")
                    ->setZipCode("12345")
                    ->setCity("Musterstadt")
                    ->setCountryCode('DE')
            ])
        )
        ->shoppingBasket(
            (new ShoppingBasketType())
                ->setAmount(100)
                ->setCurrency('EUR')
                ->setItems([
                    (new ShoppingBasketItemType())
                        ->setArticleNumber("123")
                        ->setQuantity("1")
                        ->setUnitPriceGross(100)
                        ->setItem("Artcile 1")
                ])
        )
        ->payment(
            (new PaymentType())
                ->setMethod(PaymentType::METHOD_INVOICE)
                ->setCurrency(PaymentType::CURRENCY_EUR)
                ->setAmount(100)
        )
        ->build();

    $res = $ratepayBroker->paymentRequest($transactionId, $paymentRequest);

    /** @var PaymentRequestResponseType $paymentRequestResponse */
    $paymentRequestResponse = $res->getContent();

    $descriptor = $paymentRequestResponse->getPayment()->getDescriptor();

    // save $descriptor for your reference

    $ratepayBroker->paymentConfirm($transactionId);

} catch (RatePAYException $e) {
    $message = ($e->getCustomerMessage() != "") ?
        $e->getCustomerMessage() : "The RatePAY transaction could not be processed";

    echo $message;
}
```

Triggering a payment change request
-----------------------------------

[](#triggering-a-payment-change-request)

```
    $paymentChange = $ratepayBroker->getRequestBuilder()
        ->shoppingBasket(
            (new ShoppingBasketType())
                ->setAmount(1000)
                ->setCurrency('EUR')
                ->setItems([
                    (new ShoppingBasketItemType())
                        ->setArticleNumber("123")
                        ->setQuantity("10")
                        ->setUnitPriceGross(100)
                        ->setItem("Article 1")
                ])
        )
        ->build();

    $res = $ratepayBroker->paymentChange($transactionId, OperationType::OPERATION_SUBTYPE_CHANGE_ORDER, $paymentChange);
```

Triggering a confirmation deliver request
-----------------------------------------

[](#triggering-a-confirmation-deliver-request)

```
    $confirmationDeliver = $ratepayBroker->getRequestBuilder()
        ->shoppingBasket(
            (new ShoppingBasketType())
                ->setAmount(1000)
                ->setCurrency('EUR')
                ->setItems([
                    (new ShoppingBasketItemType())
                        ->setArticleNumber("123")
                        ->setQuantity("10")
                        ->setUnitPriceGross(100)
                        ->setItem("Article 1")
                ])
        )
        ->build();

    $res = $ratepayBroker->confirmationDeliver($transactionId, $confirmationDeliver);
```

RatePAY Gateway Endpoints
-------------------------

[](#ratepay-gateway-endpoints)

The RatePAY Gateway system is implemented as a XML over HTTP webservice. It can be accessed via SSL:

- Test: [https://gateway-int.ratepay.com/api/xml/1\_0](https://gateway-int.ratepay.com/api/xml/1_0)
- Production: [https://gateway.ratepay.com/api/xml/1\_0](https://gateway.ratepay.com/api/xml/1_0)

RatePAY gateway operations
--------------------------

[](#ratepay-gateway-operations)

Gateway operationMandatory / OptionalPurposePAYMENT\_INITMInitialize the transaction and get a valid transaction-id.PAYMENT\_QUERY fullOCheck the customer and order details, perform a configurable risk scoring, retrieve the payment products permitted in the given context. The PAYMENT\_QUERY full can be booked with a guaranteed acceptance. This means that all products given back will be accepted by a following PAYMENT\_REQUEST.PAYMENT\_REQUESTMCheck the customer and order details, perform risk scoring, return either customer acceptance or rejection.PAYMENT\_CONFIRMM (if response of the PAYMENT\_REQUEST is positive)Finalize the payment process.CONFIRMATION\_DELIVER (“CD”)M (if order has not been cancelled)Immediately after the ordered goods have been delivered to the customer, the merchant must send a Confirmation Deliver message to the RatePAY Gateway.PAYMENT\_CHANGE cancellationOMerchant cancels some or all items of the orderPAYMENT\_CHANGE returnOMerchant returns some or all items of the orderPAYMENT\_CHANGE change-orderOMerchant or customer adds items to the orderPAYMENT\_CHANGE creditOMerchant adds a credit (discount) or debit (adjustment charge) to the orderCONFIGURATION\_REQUESTORetrieve the stored configuration parameters for a certain merchant profile.CALCULATION\_REQUESTOProvides an installment plan depending on the request parameters and stored parameters of the merchant profile.Please note: The gateway operations are exposed through the `RatepayBroker` object.

JMS Serializer Library Usage Note
---------------------------------

[](#jms-serializer-library-usage-note)

This library makes heavy use of the JMS-Serializer library which itself makes heavy ues of the doctrine annotation features.

To use the library in a standalone environment make sure to register the serializer source directory in the doctrine annotation registry.

```
AnnotationRegistry::registerAutoloadNamespace(
    'JMS\Serializer\Annotation',
    __DIR__ . "/vendor/jms/serializer/src");
```

Appendix: Result Codes
----------------------

[](#appendix-result-codes)

The following result codes are only for internal reference in the library and are exposed via the the `RejectionException`, `TechnicalException` and `WarningException` if you use the `RatepayBroker` object.

OperationSuccessRejectionTechnical ErrorWarningAdditional InformationPAYMENT\_INIT350-150--PAYMENT\_QUERY402401150405The PAYMENT\_QUERY needs a different evaluation. To determine if a following PAYMENT\_REQUEST will be successful, the corresponding product has to be available.PAYMENT\_REQUEST402401150405-PAYMENT\_CONFIRM400401150405-PAYMENT\_CHANGE403401150405-CONFIRMATION\_DELIVER404401150405-CALCULATION\_REQUEST502503150-Note when a 503 is triggered: Although sending the same CALCULATION\_REQUEST again is possible, the result will always be the same. This result indicates a request with wrong parameters.CONFIGURATION\_REQUEST500-150--

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 94.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

5

Last Release

3763d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4af6f0b1b8c50a7240ac8f6d3ebf33a94a5a9990f57fd28c8e1e2e1d50e3416c?d=identicon)[hauptmedia](/maintainers/hauptmedia)

---

Top Contributors

[![hauptmedia](https://avatars.githubusercontent.com/u/10770719?v=4)](https://github.com/hauptmedia "hauptmedia (75 commits)")[![MSeven](https://avatars.githubusercontent.com/u/31497?v=4)](https://github.com/MSeven "MSeven (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpcommerce-ratepay/health.svg)

```
[![Health](https://phpackages.com/badges/phpcommerce-ratepay/health.svg)](https://phpackages.com/packages/phpcommerce-ratepay)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.0k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M419](/packages/drupal-core-recommended)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
