2017 © Pedro Peláez
 

library my-promisepay-php

PHP SDK for the PromisePay API

image

gjorgic/my-promisepay-php

PHP SDK for the PromisePay API

  • Thursday, August 6, 2015
  • by gjorgic
  • Repository
  • 1 Watchers
  • 0 Stars
  • 356 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP SDK - PromisePay API

Join the chat at https://gitter.im/PromisePay/promisepay-php, (*1)

Build Status Latest Stable Version Total Downloads Code Climate, (*2)

1. Installation

Composer

You can include this package via Composer., (*3)

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

Install the package., (*4)

composer install

Require the package., (*5)

require init.php

Manual Installation

Download the latest release from GitHub, then include the init.php file - see below., (*6)

require init.php

2. Configuration

Before interacting with PromisePay API, you need to generate an API token. See http://docs.promisepay.com/v2.2/docs/request_token for more information., (*7)

Once you have recorded your API token, configure the PHP package - see below., (*8)

Open the file libs/promisepay-credentials.xml and replace the existing credentials with the following:, (*9)

    <?xml version='1.0'?>
        <ApiCredentials>
            <ApiUrl>https://test.api.promisepay.com/</ApiUrl>
            <ApiLogin>user.name@yourdomain.com</ApiLogin>
            <ApiPassword>Password</ApiPassword>
            <ApiKey>APIToken</ApiKey>
    </ApiCredentials>

3. Examples

Tokens

Example 1 - Request session token

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

$repo = new TokenRepository();
$sessionToken = new Token($arr = 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'           => 'sally.seller@promisepay.com',
               'buyer_email'            => 'bobby.buyer@promisepay.com',
               'fee_ids'                => '',
               'payment_type_id'        => '2'))
$repo->requestSessionToken($sessionToken)
Example 2 - Request session token

The below example shows the request for a marketplace that passes the Item and User IDs., (*11)

$repo = new TokenRepository();
$sessionToken = new Token($arr = array(
               'current_user_id'        => 'seller1234',
               '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'           => 'sally.seller@promisepay.com',
               'buyer_email'            => 'bobby.buyer@promisepay.com',
               'external_item_id'       => 'TestItemId1234',
               'external_seller_id'     => 'seller1234',
               'external_buyer_id'      => 'buyer1234',
               'fee_ids'                => '',
               'payment_type_id'        => '2'))
$repo->requestSessionToken($sessionToken)

Items

Create an item
$repo = new ItemRepository();
$user = new Item($arr = array(
           'id'            => 'External_id',
           'name'          => 'Item Name',
           'amount'        => '2000',
           'payment_type'  => '1',
           'buyer_id'      => 'External_buyer_id',
           'seller_id'     => 'External_seller_id',
           'fee_ids'       => 'fee_id_1,fee_id_2',
           'description'   => 'Item Description'));
$repo->createItem($user)
Get an item
$repo = new ItemRepository();
$item = $repo->getItemById('item_id');
Get a list of items
$repo = new ItemRepository();
$listOfItems = $repo->getListOfItems;
Update an item
$repo = new ItemRepository();
$item = new Item($arr = array(
           'id'            => 'External_id',
           'name'          => 'Item Name',
           'amount'        => '2000',
           'payment_type'  => '1',
           'buyer_id'      => 'External_buyer_id',
           'seller_id'     => 'External_seller_id',
           'fee_ids'       => 'fee_id_1,fee_id_2',
           'description'   => 'Item Description'));
$repo->updateItem($item, 'user', 'account', 'release_amount');
Delete an item
$repo = new ItemRepository();
$repo->deleteItem('item_id');
Get an item status
$repo = new ItemRepository();
$repo->getItemStatus('item_id');
Get an item's buyer
$repo = new ItemRepository();
$buyer = $repo->getBuyerOfItem('item_id');
Get an item's seller
$repo = new ItemRepository();
$seller = $repo->getSellerForItem('item_id');
Get an item's fees
$repo = new ItemRepository();
$fees = $repo->getListFeesForItems('item_id');
Get an item's transactions
$repo = new ItemRepository();
$transactions = $repo->getListOfTransactionsForItem('item_id');
Get an item's wire details
$repo = new ItemRepository();
$wireDetails = $repo->getWireDetailsForItem('item_id');
Get an item's BPAY details
$repo = new ItemRepository();
$bpayDetails = $repo->getBPayDetailsForItem('item_id');

Users

Create a user
$repo = new UserRepository();
$user = new User($arr = array(
           'id'            => id,
           'first_name'    => 'First Name',
           'last_name'     => 'Last Name',
           'email'         => 'email'
           'mobile'        => 'mobile phone'
           'address_line1' => 'a line 1',
           'address_line2' => 'a line 2',
           'state'         => 'state',
           'city'          => 'city',
           'zip'           => '90210',
           'country'       => 'AUS'//country code,));
$repo->createUser($user)
Get a user
$repo = new UserRepository();
$user = $repo->getUserById('User id');
Get a list of users
$repo = new UserRepository();
$users = $repo->getListOfUsers();
Delete a User
$repo = new UserRepository();
$repo->deleteUser('User_id');
Get a user's card accounts
$repo = new UserRepository();
$usersCardAccounts = $repo->getListOfCardAccountsForUser('User_id');
Get a user's PayPal accounts
$repo = new UserRepository();
$usersPayPalAccounts = $repo->getListOfPayPalAccountsForUser('User_id');
Get a user's bank accounts
$repo = new UserRepository();
$usersBankAccounts = $repo->getListOfBankAccountsForUser('User_id');
Get a user's items
$repo = new UserRepository();
$items = $repo->getListOfItemsForUser('User_id');
Set a user's disbursement account
$repo = new UserRepository();
$repo->setDisbursementAccount('user_id', 'account_id');

Item Actions

Make payment
$repo = new ItemRepository();
$repo->makePayment('External_item_id', 'Card_account_id', 'User_id')
Request payment
$repo = new ItemRepository();
$requestPayment = $repo->requestPayment('Item_id', 'Seller_id');
Release payment
$repo = new ItemRepository();
$releasePayment = $repo->releasePayment('Item_id', 'buyer_id', 'Release amount');
Request release
$repo = new ItemRepository();
$requestRelease = $repo->requestRelease('Item_id', 'Seller_id', 'Release amount');
Cancel
$repo = new ItemRepository();
$repo->cancelItem('Item_id');
Acknowledge wire
$repo = new ItemRepository();
$acknowledgeWire = $repo->acknowledgeWire('Item_id', 'Buyer_id');
Acknowledge PayPal
$repo = new ItemRepository();
$acknowledgePayPal = $repo->acknowledgePayPal('Item_id', 'Buyer_id');
Revert wire
$repo = new ItemRepository();
$repo->revertWire('Item_id', 'Buyer_id');
Request refund
$repo = new ItemRepository();
$repo->requestRefund('Item_id',  'Buyer_id',  'Refund amount',  'Refund message');
Refund
$repo = new ItemRepository();
$repo = refund( 'Item id',  'Seller id',  'Refund Amount',  'Refund message')

Card Accounts

Create a card account
$repo = new CardAccountRepository();
$user = new CardAccount($arr = array(
           'user_id'       => id,
           'full_name'     => 'Bobby Buyer',
           'number'        => '4111111111111111',
           'expiry_month'  => '06'
           'expiry_year'   => '2016'
           'cvv'            => '123'));
$repo->createCardAccount($user)
Get a card account
$repo = new CardAccountRepository();
$card = $repo->getCardAccountById('Account_id')
Delete a card account
$repo = new CardAccountRepository();
$repo->deleteCardAccount('Account_id')
Get a card account's users
$repo = new CardAccountRepository();
$users = $repo->getUserForCardAccount('Card Account');

Bank Accounts

Create a bank account
$repo = new BankAccountRepository();
$bankAccount = new BankAccount($arr = array(
               'user_id'            => 'External_seller_id',
               'bank_name'          => 'Test Bank',
               'account_name'       => 'Sally Seller',
               'routing_number'     => '123456',
               'account_number'     => '12345678',
               'account_type'       => 'checking',
               'holder_type'        => 'personal',
               'bank_country'       => 'AUS'))
$repo->createBankAccount($bankAccount)
Get a bank account
$repo = new BankAccountRepository();
$bankAccount = $repo->getBankAccountById('Account_id');
Delete a bank account
$repo = new BankAccountRepository();
$repo->deleteBankAccount('Account_id');
Get a bank account's users
$repo = new BankAccountRepository();
$user = $repo->getUserForBankAccount('Account_id');

PayPal Accounts

Create a PayPal account
$repo  = new PayPalAccountRepository();
$params  = array(
    'user_id'=> 'User id',
    'active'=>'true',
    'paypal'=>array(
        'email'=>'User email'
        )
    );
$ppalAccount = new PayPalAccount($params);
$repo->createPayPalAccount($ppalAccount);
Get a PayPal account
$repo = new PayPalAccountRepository();
$paypalAccount = $repo->getPayPalAccountById('account_id');
Delete a PayPal account
$repo = new PayPalAccountRepository();
$repo->deletePayPalAccount('Account id')
Get a PayPal account's users
$repo = new PayPalAccountRepository();
$users = $repo->getUserForPayPalAccount('Account id')

Fees

Get a list of fees
$repo = new FeeRepository();
$fees = $repo->getListOfFees();
Get a fee
$repo = new FeeRepository();
$fee = $repo->getFeeById('Fee id');
Create a fee
$enum = new FeeType();
$repo = new FeeRepository();
$data = array(
    'id'=>'fee id',
    'amount'=>1000,
    'name'=>'fee name',
    'fee_type'=>$enum->Fixed,
    'cap'=>'1',
    'max'=>'3',
    'min'=>'2',
    'to'=>'buyer'
    );
$fee = new Fee($data);
$repo->createFee($fee);

Transactions

Get a list of transactions
$repo = new TransactionRepository();
$trans = $repo->getListOfTransactions();
Get a transaction
$repo = new TransactionRepository();
$transaction = $repo->getTransaction('transaction_id');
Get a transaction's users
$repo = new TransactionRepository();
$users = $repo->getUserForTransaction('transaction id');
Get a transaction's fees
$repo = new TransactionRepository();
$fees = $repo->getFeeForTransaction('transaction id');

4. 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

The Versions

06/08 2015

dev-master

9999999-dev

PHP SDK for the PromisePay API

  Sources   Download

The Requires

 

The Development Requires