Download the PHP package consilience/starling-payments-objects without Composer
On this page you can find all versions of the php package consilience/starling-payments-objects. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download consilience/starling-payments-objects
More information about consilience/starling-payments-objects
Files in consilience/starling-payments-objects
Package starling-payments-objects
Short Description Starling Bank Payments Service data objects
License MIT
Homepage https://github.com/consilience
Informations about the package starling-payments-objects
Starling Bank Payments API Objects
This is a package for PHP 8.1 to stuff the response body messages from requests to the Starling Payments API
This package is in development, and has initially covered just the response messages I am particularly interested in. Objects to generate the request message bodies are being added now. The intention is to extend that to include the full PSR-7 message (body, headers, relative path). To support path generation, the contextual UUIDs (e.g. account ID when creating an account address) may need to be added, so the constructors will change.
Additional objects can be submitted by Pull Request if they are something you would like to see.
The request messages are not included in this package for the moment, but they may be in due course. Again, I am happy to accept PRs to hurry this along.
The Approach
The Starling Payments API uses JSON request and response bodies. The JSON responses will decode to nested arrays of scalar values. This package provides classes that instantiate objects from that data.
To start with, the classes are just dumb value objects that take the data in properties. Over time, more logic will be added to the classes to interpret the property values in a higher business sense. In addition, the values will be parsed into more common objects such as Money and Carbon to provide further leverage with the tools and support those libraries come with.
Simple Example
The Previous Payments API can be used to fetch a single payment from an account address through this endpoint:
/api/v1/{paymentBusinessUid}/account/{accountUid}/address/{addressUid}/payment/{paymentUid}
This returns a data structure similar to this example:
Given that data structure as $data
, the value object can be instantiated like this:
Each property can then be referenced in a number of ways:
The nested data will in turn be instantiated as value objects:
The instructedAmount
will be a CurrencyAndAmount
value object.
That object supports conversion to Money\Money
:
Other objects will have similar conversions.
For example, the date and datetime properties can be fetched by appending
the name with Carbon
to return a Carbon
object for the date.
For example:
Datetime objects (i.e. timestamps) will be in the timezone they were supplied in. Date objects (without a time) will be returned in the UTC timezone.
That's kind of the wqay it's going, and progress will be documented here as it happens.
Supported Messages
All request messages have namespace Consilience\Starling\Payments\Request
.
All response messages have namespace Consilience\Starling\Payments\Response
.
The following table lists the requests you can send, and the object to hold the response.
Request | Response |
---|---|
CreatePaymentAccount | CreatePaymentAccountResponse |
CreatePaymentAccountAddress | CreatePaymentAccountAddressResponse |
CreatePaymentDomestic | DomesticPaymentInstructionResponse |
CreatePaymentReturn | PaymentReturnResponse |
GetPayment | PaymentDetails |
GetPaymentAccount | PaymentAccount |
GetPaymentAccountAddress | PaymentAccountAddress |
GetPaymentAccountAddresses | PaymentAccountAddressCollection |
GetPaymentAccounts | PaymentAccountCollection |
GetPaymentServiceBusiness | BusinessInformation |
GetPayments | PaymentDetailsCollection |
GetSettlementCycle | SettlementCycle |
GetSettlementCycleCurrent | SettlementCycle |
GetSettlementCycleLast | SettlementCycle |
GetSettlementCyclePayments | PaymentDetailsCollection |
UpdatePaymentAccountAddressStatus | ChangeStatusPaymentAccountAddressResponse |
GetDirectDebitMandate | DirectDebitMandate |
GetDirectDebitMandates | DirectDebitMandateCollection |
ActivateMandateRequest | ActivateMandateResponse |
CancelMandateRequest | CancelMandateResponse |
TBC | PaymentOriginatingOverseasInstructionResponse |
To create a response object, you can instantiate it with either the response body data, or the reponse PSR-7 message. For example:
Building the request objects may include any of the following classes
in Consilience\Starling\Payments\Request\Models
:
- CreatePaymentAccountAddressRequest
- CreatePaymentAccountRequest
- CurrencyAndAmount
- DomesticInstructionAccount
- DomesticPaymentInstructionRequest
- Endpoint
- PaymentReturnRequest
The response messages may contain the following lower-level models:
- Response\Models\AccountNumberAndSortCode
- Response\Models\CurrencyAndAmount
- Response\Models\PaymentDetailsAccount
- Response\Models\PaymentReturnDetails
- Response\Models\Balance
- Response\Models\ErrorDetail
- Response\Models\PaymentRejectionReason
Webhooks are supported:
- ServerRequest\FpsSchemeNotification
- ServerRequest\FpsInboundNotification
- ServerRequest\FpsRedirectionNotification
-
ServerRequest\FpsReversalNotification (no tests yet)
-
ServerRequest\AccountTransactionNotification (no tests yet)
- ServerRequest\MandateCreatedNotification
- ServerRequest\MandateCancelledNotification
- ServerRequest\MandateOriginatorChangedNotification
- ServerRequest\DirectCreditPaymentReceivedNotification
- ServerRequest\DirectDebitPaymentPaidNotification
- ServerRequest\DirectDebitPaymentRejectedNotification
All versions of starling-payments-objects with dependencies
nesbot/carbon Version ~1.18|^2.0
psr/http-message Version ^1.0
moneyphp/money Version ^4.0.4
guzzlehttp/psr7 Version ^1.5|^2.2