PHPackages                             juspay/expresscheckout-php-sdk - 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. [API Development](/categories/api)
4. /
5. juspay/expresscheckout-php-sdk

ActiveLibrary[API Development](/categories/api)

juspay/expresscheckout-php-sdk
==============================

Express Checkout SDK for PHP allows easy integration with Juspay's EC payments as a service platform

v2.0.4(1y ago)223.6k↑105.6%2AGPL-3.0-onlyPHPPHP &gt;=5.6.0CI failing

Since Aug 30Pushed 1y ago5 watchersCompare

[ Source](https://github.com/juspay/expresscheckout-php-sdk)[ Packagist](https://packagist.org/packages/juspay/expresscheckout-php-sdk)[ Docs](https://www.juspay.in)[ RSS](/packages/juspay-expresscheckout-php-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (19)Used By (0)

Juspay PHP Client Library
=========================

[](#juspay-php-client-library)

---

The Juspay ExpressCheckout PHP SDK makes it easier for merchants to integrate the express-checkout APIs in their product. This SDK is distributed using `composer`. To add the SDK to your project, add the following code to your **composer.json**:

```
#!python

"require" : {
	"juspay/expresscheckout-php-sdk" : "1.0.4"
}

```

This package requires a `minimum-stability` of `stable`. Set the `minimum-stability` in your **composer.json** accordingly.

Setting up the SDK for use.
---------------------------

[](#setting-up-the-sdk-for-use)

By default SDK is initialised for Juspay production account.

**To setup PHP SDK for production account with default timeouts, use following code:**

```
JuspayEnvironment::init()
->withApiKey("your_api_key")
```

**To setup PHP SDK for sandbox account with default timeouts, use following code:**

```
JuspayEnvironment::init()
->withApiKey("yourApiKey")
->withBaseUrl(JuspayEnvironment::SANDBOX_BASE_URL)
```

**To setup PHP SDK for production account with custom timeouts, use following code:**

```
JuspayEnvironment::init()
->withApiKey("yourApiKey")
->withConnectTimeout(connectTimeout)
->withReadTimeout(readTimeout);
```

**To setup PHP SDK for sandbox account with custom timeouts, use following code:**

```
JuspayEnvironment::init()
->withApiKey("yourApiKey")
->withBaseUrl(JuspayEnvironment::SANDBOX_BASE_URL)
->withConnectTimeout(connectTimeout)
->withReadTimeout(readTimeout);
```

**To setup PHP SDK with custom CA Certificate, use following code:**

```
JuspayEnvironment::init()
->withApiKey("yourApiKey")
->withBaseUrl(JuspayEnvironment::SANDBOX_BASE_URL)
->withCACertificatePath("file path to ca certificate");
```

Using SDK
---------

[](#using-sdk)

The input to all methods in SDK is an associative array and most of the methods will return the object of the corresponding class.

### Example:

[](#example)

**Adding a card to Juspay Locker:**

```
$params = array ();
$params ['merchant_id'] = "merchantId";
$params ['customer_id'] = "customerId";
$params ['customer_email'] = "support@juspay.in";
$params ['card_number'] = "4111111111111111";
$params ['card_exp_year'] = "2018";
$params ['card_exp_month'] = "07";
$params ['name_on_card'] = "Juspay Technologies";
$params ['nickname'] = "ICICI VISA";
$card = Card::create ( $params );
```

**Getting order status using JWT**

Pass JuspayJWT in request option. JuspayJWT implements IJuspayJWT interface. IJuspayJWT has three methods consumePayload, preparePayload and Initialize (a factory method to initialize ISign and IEnc objects) along with three attributes array of keys, Sign of type ISign and Enc of type IEnc. JuspayJWT currently uses SignRSA5 which is a implementation of ISign interface and EncRSAOEAP which is a implementation of IEnc interface. Currently JuspayJWT class comes with the SDK. Implement IJuspayJWT to create custom JWT classes. JuspayJWT constructor accepts $keys and two kid as arguments.

**With RequestOptions**

```
$params = array ();
$params ['order_id'] = $this->order->orderId;
$keys = [];
$privateKey = file_get_contents("./tests/privateKey.pem");
$publicKey = file_get_contents("./tests/publicKey.pem");
$order = Order::encryptedOrderStatus($params, new RequestOptions(new JuspayJWT("testJwe", $publicKey, $privateKey)));
```

**With JuspayEnvironment**

```
$params = array ();
$params ['order_id'] = $this->order->orderId;
$keys = [];
$privateKey = file_get_contents("./tests/privateKey.pem");
$publicKey = file_get_contents("./tests/publicKey.pem");
JuspayEnvironment::init()->withJuspayJWT(new JuspayJWT("testJwe", $publicKey, $privateKey));
$order = Order::status($params, null);
```

**Error Handling**

```
