Skip to content

Griffinz/promisepay-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#PHP SDK - PromisePay API

Join the chat at https://gitter.im/PromisePay/promisepay-php

Build Status Latest Stable Version Total Downloads Code Climate

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

#1. 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;

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

use PromisePay;

Prerequisites

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

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

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

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

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

$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'           => 'sally.seller@promisepay.com',
	'buyer_email'            => 'bobby.buyer@promisepay.com',
	'fee_ids'                => '',
	'payment_type_id'        => '2'
));

#####Example 2 - Request session token The below example shows the request for a marketplace that passes the Item and User IDs.

$token = PromisePay::Token()->requestSessionToken(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'
));

##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');

##Users

#####Create a user

$user = PromisePay::User()->create(array(
    'id'            => 'USER_ID',
    'first_name'    => 'UserCreateTest',
    'last_name'     => 'UserLastname',
    'email'         => 'email@google.com',
    '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@google.com',
    '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');

#####Set a user's disbursement account

$account = PromisePay::User()->getListOfBankAccounts('USER_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' => 'Refund please.'
));

#####Refund

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

##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');

##PayPal Accounts #####Create a PayPal account

$account = PromisePay::PayPalAccount()->create(array(
    'user_id'      => 'USER_ID',
    'paypal_email' => 'test@paypalname.com'
));

#####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');

##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');

#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

About

PHP package for invoking PromisePay RESTful API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%