coliving/hyperwallet-sdk

A library to manage users, transfer methods and payments through the Hyperwallet API. This is fork from hyperwallet/sdk to upgrade the guzzlehttp package

2.1.1 2020-11-23 09:14 UTC

This package is not auto-updated.

Last update: 2024-04-16 22:21:51 UTC


README

Build Status Coverage Status Latest Stable Version

Hyperwallet REST SDK (Beta)

A library to manage users, transfer methods and payments through the Hyperwallet Rest V4 API To access V3 Rest APIs, please use SDK v1.5

Prerequisites

Hyperwallet's PHP server SDK requires at minimum PHP 5.6 and above.

Installation

  • Install from hyperwallet/sdk
$ composer require hyperwallet/sdk
  • Install from Coliving
$ composer require coliving/hyperwallet-sdk

Documentation

Documentation is available at http://hyperwallet.github.io/php-sdk.

API Overview

To write an app using the SDK

  • Register for a sandbox account and get your username, password and program token at the Hyperwallet Program Portal.

  • Add dependency hyperwallet/sdk to your composer.json.

  • Create a instance of the Hyperwallet Client (with username, password and program token)

    $client = new \Hyperwallet\Hyperwallet("restapiuser@4917301618", "mySecurePassword!", "prg-645fc30d-83ed-476c-a412-32c82738a20e");
  • Start making API calls (e.g. create a user)

    $user = new \Hyperwallet\Model\User();
    $user
      ->setClientUserId('test-client-id-1')
      ->setProfileType(\Hyperwallet\Model\User::PROFILE_TYPE_INDIVIDUAL)
      ->setFirstName('Daffyd')
      ->setLastName('y Goliath')
      ->setEmail('testmail-1@hyperwallet.com')
      ->setAddressLine1('123 Main Street')
      ->setCity('Austin')
      ->setStateProvince('TX')
      ->setCountry('US')
      ->setPostalCode('78701');
    
    try {
        $createdUser = $client->createUser($user);
    } catch (\Hyperwallet\Exception\HyperwalletException $e) {
        // Add error handling here
    }
  • Error Handling The HyperwalletException has an array of errors with code, message and fielName properties to represent a error.

      try {
        ...
      } catch (\Hyperwallet\Exception\HyperwalletException $e) {
        // var_dump($e->getErrorResponse());
        // var_dump($e->getErrorResponse()->getErrors());
        foreach ($e->getErrorResponse()->getErrors() as $error) {
            echo "\n------\n";
            echo $error->getFieldName()."\n";
            echo $error->getCode()."\n";
            echo $error->getMessage()."\n";
        }
      }

Development

Run the tests using phpunit:

$ composer install
$ ./vendor/bin/phpunit -v

Reference

REST API Reference

License

MIT