Download the PHP package gridonic/swisscom-easypay without Composer
On this page you can find all versions of the php package gridonic/swisscom-easypay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gridonic/swisscom-easypay
More information about gridonic/swisscom-easypay
Files in gridonic/swisscom-easypay
Package swisscom-easypay
Short Description PHP library to handle payments with Swisscom EasyPay
License MIT
Homepage https://github.com/gridonic/swisscom-easypay
Informations about the package swisscom-easypay
Swisscom Easypay
A PHP library to manage payments with Swisscom Easypay.
Installation
Install the library with composer:
Basic Usage
Note: This guide only covers the basics on how to use this library. More details about Easypay can be found in the official documentations.
Environment
Create a new STAGING
or PROD
environment based on your credentials:
Checkout page
Redirect the user to the Easypay checkout page where the purchase must be confirmed.
- Map the user's shopping cart to a
CheckoutPageItem
. Note that you must provide the success/error/cancel urls for the redirect back to your shop. - In case of a recurrent service, make sure to pass the duration and duration unit to
the checkout page item via
setDuration()
andsetDurationUnit()
. - Call
CheckoutPageService::getCheckoutPageUrl()
to obtain the redirect url.
Handling the checkout page response
After confirming the purchase on the checkout page, the user is redirected back to the shop.
In order to complete the purchase, the payment must be committed via Easypay's REST API. Use
the CheckoutPageResponseService
to get the payment-ID
or subscription-ID
required to
commit the payment:
Commit payments
One-time (direct) payments need to be committed via Easypay's REST API.
Use the RestApiService
to do so:
In case of a service subscription, the procedure is similar:
Easypay REST API
The RestApiService
class offers an abstraction of Easypay's REST API to manage payments.
directPayment(string $paymentId, $operation = 'COMMIT') : DirectPaymentResponse
Commit/Reject or Refund a direct payment.
- Available operations:
COMMIT
,REJECT
, orREFUND
.
getDirectPayment(string $paymentId) : DirectPaymentResponse
Get all information about a direct payment.
authorizeSubscription(string $authSubscriptionId, $operation = 'COMMIT') : AuthSubscriptionResponse
Commit/Reject/Refund/Renew or Cancel an authorized subscription.
- Available operations:
COMMIT
,REJECT
,REFUND
,RENEW
orCANCEL
.
getAuthorizeSubscription(string $authSubscriptionId) : AuthSubscriptionResponse
Get all information about an authorized subscription.
Run tests
Make sure that the dev-dependencies
are installed, then execute phpunit from the vendor
directory: