GithubHelp home page GithubHelp logo

assemblypayments / promisepay-php Goto Github PK

View Code? Open in Web Editor NEW
8.0 28.0 18.0 487 KB

PHP package for invoking PromisePay RESTful API

Home Page: https://reference.assemblypayments.com/?php

PHP 100.00%
platforms

promisepay-php's Introduction

PHP SDK - PromisePay API

Build Status Latest Stable Version Total Downloads Code Climate

Note: The api only responds to the models which are included with the php package.

Installation

Composer

You can include this package via Composer.

{
  "require": {
    "promisepay/promisepay-php": "2.*"
  }
}

Install the package.

composer install

Require the package in the controller where you'll be using it.

use PromisePay\PromisePay;

Manual Installation

Download the latest release from GitHub, then require the package in the relevant controller.

use PromisePay\PromisePay;

Prerequisites

  • PHP 5.3 or above
  • curl and json extensions must be enabled

Configuration

Before interacting with PromisePay API, you'll need to create a prelive account and get an API token.

Afterwards, you need to declare environment, login (your email address) and password (API token), thus:

PromisePay::Configuration()->environment('prelive'); // Use 'production' for the production environment.
PromisePay::Configuration()->login('your_email_address');
PromisePay::Configuration()->password('your_token');

Examples

Tokens

Request session token

The below example shows the request for a marketplace configured to have the Item and User IDs generated automatically for them.

$token = PromisePay::Token()->requestSessionToken(array(
	'current_user'           => 'seller',
	'item_name'              => 'Test Item',
	'amount'                 => '2500',
	'seller_lastname'        => 'Seller',
	'seller_firstname'       => 'Sally',
	'buyer_lastname'         => 'Buyer',
	'buyer_firstname'        => 'Bobby',
	'buyer_country'          => 'AUS',
	'seller_country'         => 'USA',
	'seller_email'           => '[email protected]',
	'buyer_email'            => '[email protected]',
	'fee_ids'                => '',
	'payment_type_id'        => '2'
));

Items

Create an item

$item = PromisePay::Item()->create(array(
    "id"              => 'ITEM_ID',
    "name"            => 'Test Item #1',
    "amount"          => 1000,
    "payment_type_id" => 1,
    "buyer_id"        => 'BUYER_ID',
    "seller_id"       => 'SELLER_ID',
    "description"     => 'Description'
));

Get an item

$item = PromisePay::Item()->get('ITEM_ID');

Get a list of items

$items = PromisePay::Item()->getList(array(
	'limit' => 20,
	'offset' => 0
));

Update an item

$item = PromisePay::Item()->update('ITEM_ID', array(
    "id"              => 'ITEM_ID',
    "name"            => 'Test Item #1',
    "amount"          => 1000,
    "payment_type_id" => 1,
    "buyer_id"        => 'BUYER_ID',
    "seller_id"       => 'SELLER_ID',
    "description"     => 'Description'
));

Delete an item

$item = PromisePay::Item()->delete('ITEM_ID');

Get an item status

$item = PromisePay::Item()->getStatus('ITEM_ID');

Get an item's buyer

$user = PromisePay::Item()->getBuyer('ITEM_ID');

Get an item's seller

$user = PromisePay::Item()->getSeller('ITEM_ID');

Get an item's fees

$fees = PromisePay::Item()->getListOfFees('ITEM_ID');

Get an item's transactions

$transactions = PromisePay::Item()->getListOfTransactions('ITEM_ID');

Get an item's wire details

$wireDetails = PromisePay::Item()->getWireDetails('ITEM_ID');

Get an item's BPAY details

$bPayDetails = PromisePay::Item()->getBPayDetails('ITEM_ID');

Item Actions

Make payment

$item = PromisePay::Item()->makePayment('ITEM_ID', array(
	'account_id' => 'BUYER_ACCOUNT_ID'
));

Request payment

$item = PromisePay::Item()->requestPayment('ITEM_ID');

Release payment

$item = PromisePay::Item()->releasePayment('ITEM_ID');

Request release

$item = PromisePay::Item()->requestRelease('ITEM_ID');

Cancel

$item = PromisePay::Item()->cancelItem('ITEM_ID');

Acknowledge wire

$item = PromisePay::Item()->acknowledgeWire('ITEM_ID');

Acknowledge PayPal

$item = PromisePay::Item()->acknowledgePayPal('ITEM_ID');

Revert wire

$item = PromisePay::Item()->revertWire('ITEM_ID');

Request refund

$item = PromisePay::Item()->requestRefund('ITEM_ID', array(
	'refund_amount' => 1000,
	'refund_message' => 'Frame already constructed.'
));

Refund

$item = PromisePay::Item()->refund('ITEM_ID', array(
	'refund_amount' => 1000,
	'refund_message' => 'Stable deck refund.'
));

Decline refund

$declineRefund = PromisePay::Item()->declineRefund(
    'ITEM_ID'
);

Raise Dispute

$raiseDispute = PromisePay::Item()->raiseDispute(
    'ITEM_ID',
    'BUYER_ID'
);

Request Dispute Resolution

$requestDisputeResolution = PromisePay::Item()->requestDisputeResolution(
    'ITEM_ID'
);

Resolve Dispute

$resolveDispute = PromisePay::Item()->resolveDispute(
    'ITEM_ID'
);

Escalate Dispute

$resolveDispute = PromisePay::Item()->escalateDispute(
    'ITEM_ID'
);

Request Tax Invoice

$requestTaxInvoice = PromisePay::Item()->requestTaxInvoice(
    'ITEM_ID'
);

List Item Batch Transactions

$batchTransactions = PromisePay::Item()->listBatchTransactions('ITEM_ID');

Send Tax Invoice

$sendTaxInvoice = PromisePay::Item()->sendTaxInvoice(
    'ITEM_ID'
);

Users

Create a user

$user = PromisePay::User()->create(array(
    'id'            => 'USER_ID',
    'first_name'    => 'UserCreateTest',
    'last_name'     => 'UserLastname',
    'email'         => '[email protected]',
    'mobile'        => '5455400012',
    'address_line1' => 'a_line1',
    'address_line2' => 'a_line2',
    'state'         => 'state',
    'city'          => 'city',
    'zip'           => '90210',
    'country'       => 'AUS'
));

Get a user

$user = PromisePay::User()->get('USER_ID');

Get a list of users

$users = PromisePay::User()->getList(array(
	'limit' => 20,
	'offset' => 0
));

Update a user

$user = PromisePay::User()->update('USER_ID', array(
    'id'            => 'USER_ID',
    'first_name'    => 'UserCreateTest',
    'last_name'     => 'UserLastname',
    'email'         => '[email protected]',
    'mobile'        => '5455400012',
    'address_line1' => 'a_line1',
    'address_line2' => 'a_line2',
    'state'         => 'state',
    'city'          => 'city',
    'zip'           => '90210',
    'country'       => 'AUS'
));

Get a user's card accounts

$accounts = PromisePay::User()->getListOfCardAccounts('USER_ID');

Get a user's PayPal accounts

$accounts = PromisePay::User()->getListOfPayPalAccounts('USER_ID');

Get a user's bank accounts

$accounts = PromisePay::User()->getListOfBankAccounts('USER_ID');

Get a user's items

$items = PromisePay::User()->getListOfItems('USER_ID');

Show User Wallet Account

$accounts = PromisePay::User()->getListOfWalletAccounts('USER_ID');

Set a user's disbursement account

$account = PromisePay::User()->setDisbursementAccount('USER_ID', array(
    'account_id' => 'ACCOUNT_ID'
));

Wallet Accounts

Show Wallet Account

$wallet = PromisePay::WalletAccounts()->show('WALLET_ID');

Withdraw Funds

// Withdraw to PayPal

// Authorize bank account to be used as a funding source
$authority = PromisePay::DirectDebitAuthority()->create(
    array(
        'account_id' => 'SOURCE_BANK_ID',
        'amount'     => 100
    )
);

$withdrawal = PromisePay::WalletAccounts()->withdraw(
    'SOURCE_BANK_ID',
    array(
        'account_id' => 'PAYPAY_ACCOUNT_ID',
        'amount'     => 100
    )
);

// Withdraw to Bank Account

// Authorize bank account to be used as a funding source
$authority = PromisePay::DirectDebitAuthority()->create(
    array(
        'account_id' => 'SOURCE_BANK_ID',
        'amount'     => 100
    )
);

$withdrawal = PromisePay::WalletAccounts()->withdraw(
    'SOURCE_BANK_ID',
    array(
        'account_id' => 'TARGET_BANK_ID',
        'amount'     => 100
    )
);

Deposit Funds

// Authorize bank account to be used as a funding source
$authority = PromisePay::DirectDebitAuthority()->create(
    array(
        'account_id' => 'SOURCE_BANK_ID',
        'amount'     => 100
    )
);

$deposit = PromisePay::WalletAccounts()->deposit(
    'TARGET_WALLET_ID',
    array(
        'account_id' => 'SOURCE_BANK_ID',
        'amount'     => 100
    )
);

Show Wallet Account User

$walletUser = PromisePay::WalletAccounts()->getUser('WALLET_ID');

Card Accounts

Create a card account

$account = PromisePay::CardAccount()->create(array(
   'user_id'      => 'USER_ID',
   'full_name'    => 'Bobby Buyer',
   'number'       => '4111111111111111',
   "expiry_month" => '06',
   "expiry_year"  => '2020',
   "cvv"          => '123'
));

Get a card account

$account = PromisePay::CardAccount()->get('CARD_ACCOUNT_ID');

Delete a card account

$account = PromisePay::CardAccount()->delete('CARD_ACCOUNT_ID');

Get a card account's users

$user = PromisePay::CardAccount()->getUser('CARD_ACCOUNT_ID');

Bank Accounts

Create a bank account

$account = PromisePay::BankAccount()->create(array(
    "user_id"        => 'USER_ID',
    "active"         => 'true',
    "bank_name"      => 'bank for test',
    "account_name"   => 'test acc',
    "routing_number" => '12344455512',
    "account_number" => '123334242134',
    "account_type"   => 'savings',
    "holder_type"    => 'personal',
    "country"        => 'USA',
));

Get a bank account

$account = PromisePay::BankAccount()->get('BANK_ACCOUNT_ID');

Delete a bank account

$account = PromisePay::BankAccount()->delete('BANK_ACCOUNT_ID');

Get a bank account's users

$user = PromisePay::BankAccount()->getUser('BANK_ACCOUNT_ID');

Validate Routing Number

$validateRoutingNumber = PromisePay::BankAccount()->validateRoutingNumber(
    'ROUTING_NUMBER'
);

PayPal Accounts

Create a PayPal account

$account = PromisePay::PayPalAccount()->create(array(
    'user_id'      => 'USER_ID',
    'paypal_email' => '[email protected]'
));

Get a PayPal account

$account = PromisePay::PayPalAccount()->get('PAYPAL_ACCOUNT_ID');

Delete a PayPal account

$account = PromisePay::PayPalAccount()->delete('PAYPAL_ACCOUNT_ID');

Get a PayPal account's users

$user = PromisePay::PayPalAccount()->getUser('PAYPAL_ACCOUNT_ID');

Batch Transactions

List Batch Transactions

$batches = PromisePay::BatchTransactions()->listTransactions();

Show Batch Transaction

$batch = PromisePay::BatchTransactions()->showTransaction(
    'BATCH_TRANSACTION_ID'
);

Charges

Create Charge

$createCharge = PromisePay::Charges()->create(
    array
    (
        'account_id' => 'CARD_OR_BANK_ACCOUNT_ID',
        'amount' => 100,
        'email' => '[email protected]',
        'zip' => 90210,
        'country' => 'AUS',
        'device_id' => 'DEVICE_ID',
        'ip_address' => '49.229.186.182'
    )
);

List Charges

$getList = PromisePay::Charges()->getList();

Show Charge

$charge = PromisePay::Charges()->show('CHARGE_ID');

Show Charge Buyer

$buyer = PromisePay::Charges()->showBuyer('CHARGE_ID');

Show Charge Status

$status = PromisePay::Charges()->showStatus('CHARGE_ID');

Marketplaces

Show Marketplace

$marketplaces = PromisePay::Marketplaces()->show();

Token Auth

Generate Card Token

$cardToken = PromisePay::Token()->generateCardToken(
    array
    (
        'token_type' => 'card',
        'user_id' => 'USER_ID'
    )
);

Direct Debit Authority

Create Direct Debit Authority

$directDebitAuthority = PromisePay::DirectDebitAuthority()->create(
    array
    (
        'account_id' => 'ACCOUNT_ID',
        'amount'     => 100
    )
);

List Direct Debit Authority

$getList = PromisePay::DirectDebitAuthority()->getList(
    array
    (
        'account_id' => 'BANK_ACCOUNT_ID'
    )
);

Show Direct Debit Authority

$directDebitAuthority = PromisePay::DirectDebitAuthority()->show(
    'DIRECT_DEBIT_AUTHORITY_ID'
);

Delete Direct Debit Authority

$deleteDirectDebitAuthority = PromisePay::DirectDebitAuthority()->delete(
    'DIRECT_DEBIT_AUTHORITY_ID'
);

Companies

Create a company

$company = PromisePay::Company()->create(array(
    'user_id'    => 'USER_ID',
    'legal_name' => 'Test edit company',
    'name'       => 'test company name edit',
    'country'    => 'AUS'
));

Get a company

$company = PromisePay::Company()->get('COMPANY_ID');

Get a list of companies

$companys = PromisePay::Company()->getList(array(
	'limit' => 20,
	'offset' => 0
));

Update a company

$company = PromisePay::Company()->update('COMPANY_ID', array(
    'id' => "e466dfb4-f05c-4c7f-92a3-09a0a28c7af5",
    'user_id' => "1",
    'name' => "Acme Co",
    'legal_name' => "Acme Co Pty Ltd",
    'tax_number' => "1231231",
    'charge_tax' => true,
    'address_line1' => "123 Test St",
    'address_line2' => "",
    'city' => "Melbourne",
    'state' => "VIC",
    'zip' => "3000",
    'country' => "AUS"
));

Fees

Get a list of fees

$fees = PromisePay::Fee()->getList(array(
	'limit' => 20,
	'offset' => 0
));

Get a fee

$fee = PromisePay::Fee()->get('FEE_ID');

Create a fee

$fee = PromisePay::Fee()->create(array(
    'amount'      => 1000,
    'name'        => 'fee test',
    'fee_type_id' => '1',
    'cap'         => '1',
    'max'         => '3',
    'min'         => '2',
    'to'          => 'buyer'
));

Transactions

Get a list of transactions

$transactions = PromisePay::Transaction()->getList(array(
	'limit' => 20,
	'offset' => 0
));

Get a transaction

$transaction = PromisePay::Transaction()->get('TRANSACTION_ID');

Get a transaction's user

$user = PromisePay::Transaction()->getUser('TRANSACTION_ID');

Get a transaction's fee

$fee = PromisePay::Transaction()->getFee('TRANSACTION_ID');

Show Transaction Wallet Account

$walletAccount = PromisePay::Transaction()->getWalletAccount(
    'TRANSACTION_ID'
);

Show Transaction Card Account

$cardAccount = PromisePay::Transaction()->getCardAccount(
    'TRANSACTION_ID'
);

Addresses

Show Address

$address = PromisePay::Address()->get('ADDRESS_ID');

Tools

Health check

$healthStatus = PromisePay::Tools()->getHealth();

Configurations

Create Configuration

$configuration = PromisePay::Configurations()->create(array(
    'name' => 'partial_refunds',
    'enabled' => true
));

Show Configuration

$configuration = PromisePay::Configurations()->get('CONFIGURATION_ID');

List Configurations

$configurations = PromisePay::Configurations()->getList();

Update Configuration

$configuration = PromisePay::Configurations()->update(array(
    'id' => 'CONFIGURATION_ID',
    'max' => 12345,
    'name' => 'partial_refunds',
    'enabled' => true
));

Delete Configuration

PromisePay::Configurations()->delete('CONFIGURATION_ID');

Payment Restrictions

List Payment Restrictions

$list = PromisePay::PaymentRestrictions()->getList();

Show Payment Restriction

$paymentRestriction = PromisePay::PaymentRestrictions()->get('PAYMENT_RESTRICTION_ID');

Callbacks

Create Callback

$callback = PromisePay::Callbacks()->create(array(
    'description' => 'Users Callback',
    'url' => 'https://domain.tld/your/post/endpoint',
    'object_type' => 'users',
    'enabled' => true
));

List Callbacks

$getList = PromisePay::Callbacks()->getList();

Show Callback

$getCallback = PromisePay::Callbacks()->get('f92d4ca1-4ee5-43f3-9e34-ca5f759c5e76');

Update Callback

$update = PromisePay::Callbacks()->update('f92d4ca1-4ee5-43f3-9e34-ca5f759c5e76', array(
    'description' => 'Users Callback',
    'url' => 'https://domain.tld/your/post/endpoint',
    'object_type' => 'users',
    'enabled' => false
));

Delete Callback

$delete = PromisePay::Callbacks()->delete('f92d4ca1-4ee5-43f3-9e34-ca5f759c5e76');

List Callback Responses

$callbackResponsesList = PromisePay::Callbacks()->getListResponses('f92d4ca1-4ee5-43f3-9e34-ca5f759c5e76');

Show Callback Response

$callbackResponse = PromisePay::Callbacks()->getResponse(
    'f92d4ca1-4ee5-43f3-9e34-ca5f759c5e76', // callback ID
    '4476b384-fa48-4473-98ec-8fcdda4a1e84' // response ID
);

Async and Wrappers

Async

Asynchronous execution provides a significant speed improvement, as compared to synchronous execution.

PromisePay::AsyncClient(
    function() {
        PromisePay::Token()->generateCardToken('CARD_TOKEN_ID');
    },
    function() {
        PromisePay::Transaction()->get('TRANSACTION_ID');
    },
    function() {
        PromisePay::Transaction()->getUser('USER_ID');
    },
    function() {
        PromisePay::BatchTransactions()->listTransactions();
    }
)->done(
    $cardToken,
    $transaction,
    $transactionUser,
    $batchTransactions
);

Response variables are placed inside done() method; they can be used both as arrays and objects, but using them as objects provides finer grained control. For example, the following will return equivalent data: $cardToken['user_id'] and $cardToken->getJson('user_id').

Response variables contain the following methods/getters:

  • getJson() -> full response JSON
  • getMeta() -> meta array extracted from response JSON, if present
  • getLinks() -> links array extracted from response JSON, if present
  • getDebug() -> response headers

Wrappers

Two wrappers are available: PromisePay::getAllResults() and PromisePay::getAllResultsAsync(). They can be used to get all results from sets of result pages, instead of up to 200 per request. For example, they can be used to fetch all batch transactions at once. Note that these requests may take some time depending on amount requested. If getting all results is mandatory, no matter how big the size, use the synchronous version. For a faster version, use async version, but not all requests are guaranteed to be returned. Generally, asynchronous execution is fine for up to 20 pages, each containing up to 200 results, yielding 4000 results within a few seconds.

Synchronous execution

$batchedTransactionsList = PromisePay::getAllResults(function($limit, $offset) {
    PromisePay::BatchTransactions()->listTransactions(
        array(
            'limit' => $limit,
            'offset' => $offset
        )
    );
});

Asynchronous execution

$batchedTransactionsList = PromisePay::getAllResultsAsync(function($limit, $offset) {
    PromisePay::BatchTransactions()->listTransactions(
        array(
            'limit' => $limit,
            'offset' => $offset
        )
    );
});

Contributing

1. Fork it ( https://github.com/PromisePay/promisepay-php/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

promisepay-php's People

Contributors

dannyshafer avatar gitter-badger avatar gjorgic avatar jeandee avatar mvmironov avatar ninoskopac avatar webden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

promisepay-php's Issues

v3.0

Feature list

  • Standardized error reporting using an interface like Monolog (#57)
  • Mockery instead of live tests (#55)
  • Each call param should be a function argument, as opposed to having one argument for all params (#52)
  • Return type for PromisePay::RestClient() should be PSR7|null (#51)
  • Discrepancy between singular and plural class names and endpoints (#50)
  • Move from custom async implementation to Guzzle (#47)
  • Timeout setting (#42)
  • Stop storing copies of vendor files inside the lib, rely on Composer instead (#58)

and more

Bug: Fetching ID that contains upper-case characters

Upon updating to v2.4 the ability to search for Items or Users that contain any uppercase characters is now broken.

The cause is due to this commit: 1beffa6#diff-dc345e6a9c1276b4ed44a9e2c376fa35

I have left a comment on the particular line at fault: https://github.com/PromisePay/promisepay-php/commit/1beffa6f0138d2b32da2e83cb31e193cffd21ff7##commitcomment-23711665

This happened to break our system, as we supplied our own IDs during the creation of a User and Items, which did contain uppercase letters. I'm not sure what the best resolution for this is, but since the Assembly site does allow you to provider your own IDs, in whatever case format you require, it perhaps isn't best practice to force the IDs to lower-case, which will result in an "Invalid ID" response.

Error Message: principal.email: already exists

I'm using the API and created a user for promisepay. how do I delete that user? since I'm getting Response Code: 422 Error Message: principal.email: already exists principal: is invalid when I try to create another user with the same email account.

Raise dispute

Hi guys,

First thanks for this lib, you're doing a great job.

My problem is that I wasn't able to find the "raiseDispute" function. I ran again "composer install" in case I hadn't the lastest release, but it seems it's not there anymore.

Is it something PromisePay removed?

Thanks,

Each call param should be a function argument, as opposed to having one argument for all params

This is a huge BC break and will require a lot of changes in userland for people migration from 2.x to 3.0.

Let's start a discussion about whether or not we actually want to do this. cc @jeandee

What does this mean?

Right now, a call to creating or updating objects is done by passing parameters in an array, like this:

$user = PromisePay::User()->create(array(
    'id'            => 'USER_ID',
    'first_name'    => 'UserCreateTest',
    'last_name'     => 'UserLastname',
    'email'         => '[email protected]',
    'mobile'        => '5455400012',
    'address_line1' => 'a_line1',
    'address_line2' => 'a_line2',
    'state'         => 'state',
    'city'          => 'city',
    'zip'           => '90210',
    'country'       => 'AUS'
));

A better way would be to do this:

$user = PromisePay::User()->create(
    int $id,
    string $firstName,
    string $lastName,
    string $email,
    int $mobile,
    string $addressLine
    // ... and so on
);

Pros of the latter approach are:

  • typehinting: users' IDEs can immediately perform static type checking and warn them about improper implementation
  • it's immediately obvious which parameters are expected, and in which format

GET requests and those alike wouldn't be affected by this, for example:

$item = PromisePay::Item()->revertWire('ITEM_ID');
$resolveDispute = PromisePay::Item()->escalateDispute(
    'ITEM_ID'
);

Constant promisepay\API_URL already defined

im using promisepay in laravel . when i setup promisepay in constructor and use more than one methods i got the exception Constant promisepay\API_URL already defined . i solved using laravel service container but same issue occurring in unit testing

Fatal error: Class 'PromisePay' not found

In our environment, using

use PromisePay

results in an error and a warning:

Fatal error: Class 'PromisePay' not found
Warning: The use statement with non-compound name 'PromisePay' has no effect

This is solved by using instead:

use PromisePay\PromisePay as PromisePay

Submitting an empty Bank Account (createBankAccountForm) shows error

ERROR TypeError: Cannot read property 'BANK_NAME' of undefined
at Object.validateBankForm (https://js.prelive.promisepay.com/PromisePay.js:1:77489)
at HTMLFormElement.submitBankEventListener (https://js.prelive.promisepay.com/PromisePay.js:1:75867)
at ZoneDelegate.invokeTask (eval at (http://localhost:8082/polyfills.js:3045:1), :421:31)
at Object.onInvokeTask (eval at (http://localhost:8082/vendor.js:14:1), :4085:33)
at ZoneDelegate.invokeTask (eval at (http://localhost:8082/polyfills.js:3045:1), :420:36)
at Zone.runTask (eval at (http://localhost:8082/polyfills.js:3045:1), :188:47)
at ZoneTask.invokeTask [as invoke] (eval at (http://localhost:8082/polyfills.js:3045:1), :495:34)
at invokeTask (eval at (http://localhost:8082/polyfills.js:3045:1), :1536:14)
at HTMLFormElement.globalZoneAwareCallback (eval at (http://localhost:8082/polyfills.js:3045:1), :1573:21)
at .....

New release

When are you going to release new version?

Missing Disbursements endpoints

As discovered in #66 (comment), the SDK is missing two endpoints:

Implement endpoints

  • GET /disbursements/:id/users
  • GET disbursements/:id/items

Tests

  • /users
  • /items

README

  • Add examples to README (note: there aren't any examples for Disbursements right now)
  • Update TOC (doctoc README.md)

Magic async functions

Create magic *Async functions, ร  la AWS SDK.

"Magical" ?

  • shan't be hard coded into the source
  • accessed through __call()

Specs

Examples

  • synchronous (blocking): $item = PromisePay::Item()->get('ITEM_ID');
  • asynchronous (non-blocking): $item = PromisePay::Item()->getAsync('ITEM_ID');

PHP Notice: Undefined index

PHP Notice: Undefined index: items in promisepay/promisepay-php/lib/ItemRepository.php on line 15

I believe the API returns empty array when the offset yields no items.
Is this a bug or a feature?

It's probably not safe to do $arr['key'] when 'key' is not guaranteed to be there at all scenarios...

v3.0 spec

Hierarchy

  • Sample hierarchy: /src/<ENDPOINT>/<ENDPOINT FILE>.php
  • Each endpoint has its own Exception class: /src/<ENDPOINT>/Exception/<ENDPOINT>Exception.php
  • Example: /src/Items/Items.php

Utilities

see #71

  • Endpoint-specific traits (example: getCount for Users and Items)

Logging

see #74

  • Disabled by default, enabled with a call to instance (e.g. $items->enableLogging())

Abolishing singletons in favor of dependancy injection

Configuration

Right now, this is how we do it:

use PromisePay\PromisePay;
PromisePay::Configuration()->environment('prelive');
PromisePay::Configuration()->login('your_email_address');
PromisePay::Configuration()->password('your_token');

A new approach would be this:

use PromisePay\Configuration;
$configuration = new Configuration('prelive', 'your_email_address', 'your_token');

Endpoint-specific instances

Right now, we're using a PromisePay singleton to access all methods:

use PromisePay\PromisePay;
$items = PromisePay::Item()->getList(array(/* args */));

Using endpoint-specific instances:

use PromisePay\Items;
$items = new Items($configuration); // $configuration as set above
$itemsList = $items->getList(/* args */);

Disbursements endpoint

Jean, please shed some light on this.

In June 2016, I was tasked with adding Disbursements endpoints to the SDK.

However, I don't see those endpoints in either pre-live or live reference.
Could you please explain?

The tests work, so the endpoints definitely exist.

Dumping this

$disbursements = PromisePay::Disbursement()->get();

returns

  [0]=>
  array(8) {
    ["id"]=>
    string(36) "d9fa5f7f-17f5-4b49-a61c-25305d63e6d0"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(23984)
    ["created_at"]=>
    string(24) "2017-08-10T20:37:36.094Z"
    ["updated_at"]=>
    string(24) "2017-08-10T20:42:32.561Z"
    ["state"]=>
    string(10) "successful"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/items"
      ["users"]=>
      string(57) "/disbursements/d9fa5f7f-17f5-4b49-a61c-25305d63e6d0/users"
    }
  }
  [1]=>
  array(8) {
    ["id"]=>
    string(36) "a17012a7-2b83-405c-b954-6ae26c8af471"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(23984)
    ["created_at"]=>
    string(24) "2017-08-10T20:37:43.451Z"
    ["updated_at"]=>
    string(24) "2017-08-10T20:42:33.823Z"
    ["state"]=>
    string(10) "successful"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/items"
      ["users"]=>
      string(57) "/disbursements/a17012a7-2b83-405c-b954-6ae26c8af471/users"
    }
  }
  [2]=>
  array(13) {
    ["id"]=>
    string(36) "fe09769c-20bd-4048-a963-9b124a96b1a3"
    ["amount"]=>
    int(1000)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(466)
    ["created_at"]=>
    string(24) "2016-07-20T05:39:41.730Z"
    ["updated_at"]=>
    string(24) "2016-07-20T06:01:13.021Z"
    ["state"]=>
    string(7) "batched"
    ["to"]=>
    string(12) "Bank Account"
    ["bank_name"]=>
    string(13) "bank for test"
    ["bank_account_name"]=>
    string(8) "test acc"
    ["bank_account_number"]=>
    string(6) "XXX134"
    ["bank_routing_number"]=>
    string(6) "XXXXX1"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/items"
      ["users"]=>
      string(57) "/disbursements/fe09769c-20bd-4048-a963-9b124a96b1a3/users"
    }
  }
  [3]=>
  array(8) {
    ["id"]=>
    string(36) "07aa6675-34d1-43ce-9fd7-67ac8588b3a0"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(23984)
    ["created_at"]=>
    string(24) "2017-08-10T20:37:52.253Z"
    ["updated_at"]=>
    string(24) "2017-08-10T20:42:34.979Z"
    ["state"]=>
    string(10) "successful"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/items"
      ["users"]=>
      string(57) "/disbursements/07aa6675-34d1-43ce-9fd7-67ac8588b3a0/users"
    }
  }
  [4]=>
  array(8) {
    ["id"]=>
    string(36) "31e3eb60-fbd6-46fd-a247-73414cc33b7a"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(23984)
    ["created_at"]=>
    string(24) "2017-08-10T20:38:00.360Z"
    ["updated_at"]=>
    string(24) "2017-08-10T20:42:36.220Z"
    ["state"]=>
    string(10) "successful"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/items"
      ["users"]=>
      string(57) "/disbursements/31e3eb60-fbd6-46fd-a247-73414cc33b7a/users"
    }
  }
  [5]=>
  array(13) {
    ["id"]=>
    string(36) "658ee18c-1a06-4f9d-82e8-7ca6d9f18975"
    ["amount"]=>
    int(1000)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(467)
    ["created_at"]=>
    string(24) "2016-07-20T06:29:51.095Z"
    ["updated_at"]=>
    string(24) "2016-07-20T22:01:26.191Z"
    ["state"]=>
    string(7) "batched"
    ["to"]=>
    string(12) "Bank Account"
    ["bank_name"]=>
    string(13) "bank for test"
    ["bank_account_name"]=>
    string(8) "test acc"
    ["bank_account_number"]=>
    string(6) "XXX134"
    ["bank_routing_number"]=>
    string(6) "XXXXX1"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/items"
      ["users"]=>
      string(57) "/disbursements/658ee18c-1a06-4f9d-82e8-7ca6d9f18975/users"
    }
  }
  [6]=>
  array(13) {
    ["id"]=>
    string(36) "82544f72-fe75-409c-beee-77f4f23b3dda"
    ["amount"]=>
    int(1000)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(479)
    ["created_at"]=>
    string(24) "2016-07-26T21:43:32.215Z"
    ["updated_at"]=>
    string(24) "2016-07-26T22:01:07.016Z"
    ["state"]=>
    string(7) "batched"
    ["to"]=>
    string(12) "Bank Account"
    ["bank_name"]=>
    string(13) "bank for test"
    ["bank_account_name"]=>
    string(8) "test acc"
    ["bank_account_number"]=>
    string(6) "XXX134"
    ["bank_routing_number"]=>
    string(6) "XXXXX1"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/items"
      ["users"]=>
      string(57) "/disbursements/82544f72-fe75-409c-beee-77f4f23b3dda/users"
    }
  }
  [7]=>
  array(8) {
    ["id"]=>
    string(36) "d61cb0c5-9c50-485b-8d28-10c2ed72baa6"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(23984)
    ["created_at"]=>
    string(24) "2017-08-10T20:38:10.619Z"
    ["updated_at"]=>
    string(24) "2017-08-10T20:42:37.593Z"
    ["state"]=>
    string(10) "successful"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/items"
      ["users"]=>
      string(57) "/disbursements/d61cb0c5-9c50-485b-8d28-10c2ed72baa6/users"
    }
  }
  [8]=>
  array(10) {
    ["id"]=>
    string(36) "4bf3b3ec-f2f2-423d-91cb-e8f419397a20"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(479)
    ["created_at"]=>
    string(24) "2016-07-26T21:43:43.743Z"
    ["updated_at"]=>
    string(24) "2016-07-26T22:01:07.030Z"
    ["state"]=>
    string(7) "batched"
    ["to"]=>
    string(20) "PayPal Disbursement "
    ["paypal_email"]=>
    string(47) "[email protected]"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/items"
      ["users"]=>
      string(57) "/disbursements/4bf3b3ec-f2f2-423d-91cb-e8f419397a20/users"
    }
  }
  [9]=>
  array(10) {
    ["id"]=>
    string(36) "290a6c0d-a328-465f-afd8-2ea46cc9525d"
    ["amount"]=>
    int(100)
    ["currency"]=>
    string(3) "AUD"
    ["batch_id"]=>
    int(393)
    ["created_at"]=>
    string(24) "2016-06-09T13:26:24.150Z"
    ["updated_at"]=>
    string(24) "2016-06-09T22:01:34.938Z"
    ["state"]=>
    string(7) "batched"
    ["to"]=>
    string(20) "PayPal Disbursement "
    ["paypal_email"]=>
    string(47) "[email protected]"
    ["links"]=>
    array(6) {
      ["transactions"]=>
      string(64) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/transactions"
      ["wallet_accounts"]=>
      string(67) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/wallet_accounts"
      ["bank_accounts"]=>
      string(65) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/bank_accounts"
      ["paypal_accounts"]=>
      string(67) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/paypal_accounts"
      ["items"]=>
      string(57) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/items"
      ["users"]=>
      string(57) "/disbursements/290a6c0d-a328-465f-afd8-2ea46cc9525d/users"
    }
  }
}

No timeout set for requests

There does not seem to be any connection timeout set for \Httpful\Request. It would be nice to have the ability to set connection timeout in PromisePay configuration like this:

PromisePay::Configuration()->timeout(10);

At minimum, some finite timeout should be set as default. Thanks!

Composer.json

"autoload": {
        "psr-4": {
            "Promisepay\\":"/lib"
        }
    }

should be

"autoload": {
        "psr-4": {
            "PromisePay\\":"/lib"
        }
    }

Autoload is case-sensitive, case doesn't match namespace within repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.