Download the PHP package 2checkoutv2/2checkout-php-sdk without Composer
On this page you can find all versions of the php package 2checkoutv2/2checkout-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 2checkoutv2/2checkout-php-sdk
More information about 2checkoutv2/2checkout-php-sdk
Files in 2checkoutv2/2checkout-php-sdk
Package 2checkout-php-sdk
Short Description 2Checkout PHP SDK by Verifone
License
Homepage https://github.com/2Checkout/2checkout-php-sdk
Informations about the package 2checkout-php-sdk
2Checkout PHP SDK
This is the current 2Checkout PHP SDK providing developers with a simple set of bindings to the 2Checkout 6.0 REST API, IPN and Convert Plus Signature API.
To use, clone and require with composer or require the included autoloader.
All the features present in this library are used through TwocheckoutFacade instance which can be initialized with a configuration array.
- > All the required params in the $config can be found in CPanel in Integrations -> Webhooks & API section
Using the Api Core directly
Call any 2Checkout REST 6.0 endpoint like below:
Place order helper
You can also use the provided Order helper object.
Dynamic Product:
-
We can get Order object by calling TwocheckoutFacade "order()" method:
-
Order object has a method called "place" that generates a call to Api Core and returns a response:
- To validate the response you first need to check for "refno" key in response and then do a validation API call for that "refno". Example:
-
Then validate "$orderData['Status']". For successfully placed payments this value is "AUTHRECEIVED" or "COMPLETE".
2. Catalog Product
The rest of the flow is identical as for placing orders with dynamic products.
Subscriptions helper
- For a payment to be recurring (generate a subscription) one needs to add to "item" (product) array structure the "RecurringOptions" field set.
An example of how this option can be configured:
An example of an item having recurring option:
Retrieving the subscriptions of a payment order using an order number.
-
In the following example we will get an array of all the subscriptions on an item:
- We can pick a subscription reference using the index it has in the retrieved array and then retrieve subscription details as in the following example:
For more parameters by which subscriptions can be searched, check the API documentation Here, and also check the Subscription class Subscription
Buy link signature generation
- To generate a buy link signature, create an array with the following structure (Details Here)
Refunds
Full refunds can be initiated using the library. Details about 2Checkout refunds Here
Processing IPNs (Instant Payment Notification)
IPNs are webhooks from 2Checkout which can be used to update payment statuses asynchronously. Instant Payment Notification (IPN) works as a message service generating automatic order/transaction notifications for your 2Checkout account. Use the notifications to process order data into your own management systems by synchronizing it with 2Checkout account events.
More details Here
1. Validate Ipn Hash:
2. Generate Ipn response:
Exceptions
The library will throw a TcoException
if an error response is returned. Here are some of the most known & encountered exceptions:
When one has a curl exception
- 'Exception ApiCore response: ' + MESSAGE
When BuyLink signature generator does not return the signature.
- 'Api response is missing Signature parameter: ' + MESSAGE
The reason above + some reasons regarding configuration or JwtSignature generation
- 'Exception generating buy link signature: ' + MESSAGE
When retrieving a subscription by order reference number
- 'Exception getting subscriptions by order RefNo.'
When one or more subscription search parameter
- 'Exception! Some subscription search parameters are not accepted: ' + MESSAGE
When some search parameters for order search are not accepted
- Exception! Some order search parameters are not accepted: ' + MESSAGE
If refunds fail this exception is raised
- 'Error when placing refund request: ' + MESSAGE
Missing Secret word value for Buy Link signature generation
- 'Buy link Secret Word is not set in Tco Config! First set it and then use it.'
When TcoConfig receives not accepted parameters or sellerId && secretKey values are missing
- 'Some configuration keys are not accepted or not set!'
Something went wrong when generating buy link signature in facade
- 'Exception getting buy link signature! Details: ' + MESSAGE
When validating IPN request fails
- 'Cannot validate Ipn Request. Details:' + MESSAGE
When generating IPN response fails
- 'Cannot generate Ipn Response. Details:' + MESSAGE
All versions of 2checkout-php-sdk with dependencies
ext-curl Version *
ext-json Version *