Skip to content

Commit

Permalink
Updated docs and added support for filtering payments list
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Fraser committed Aug 24, 2016
1 parent d37d265 commit 0f086b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,42 @@ require 'vendor/autoload.php';

All the Afterpay API calls should be available via similar names in the main API factory.

### Fetch Configuration
### Get Configuration

[Get Configuration Docs](http://docs.afterpay.com.au/merchant-api-v1.html#get-configuration)

```php
$authorization = new \CultureKings\Afterpay\Authorization(
\CultureKings\Afterpay\Model\Authorization::SANDBOX_URI,
'1234',
'soSecret'
YOUR_MERCHANT_ID,
YOUR_SECRET_KEY
);

$configuration = \CultureKings\Afterpay\Factory\Api::configuration($authorization)->get()
```

### Fetch Payments List
### List Payments

[List Payments Docs](http://docs.afterpay.com.au/merchant-api-v1.html#list-payments)

```php
$authorization = new \CultureKings\Afterpay\Authorization(
\CultureKings\Afterpay\Model\Authorization::SANDBOX_URI,
'1234',
'soSecret'
YOUR_MERCHANT_ID,
YOUR_SECRET_KEY
);

$payments = \CultureKings\Afterpay\Factory\Api::payments($authorization)->listPayments()
$payments = \CultureKings\Afterpay\Factory\Api::payments($auth)->listPayments(
[
'fromCreatedDate' => '2016-01-01T00:00:00.000Z',
'limit' => 1
]
);
```

### Create an order
### Create Order

[Create Order Docs](http://docs.afterpay.com.au/merchant-api-v1.html#create-order)

```
$consumer = new \CultureKings\Afterpay\Model\Consumer();
Expand All @@ -77,7 +88,9 @@ $orderDetails->setTotalAmount($totalAmount);
$orderToken = \CultureKings\Afterpay\Factory\Api::orders($auth)->create($orderDetails);
```

### Fetch an order
### Get Order

[Get Order Docs](http://docs.afterpay.com.au/merchant-api-v1.html#get-order)

```$order = \CultureKings\Afterpay\Factory\Api::orders($auth)->get($orderToken->getToken());```

Expand Down
6 changes: 4 additions & 2 deletions src/CultureKings/Afterpay/Service/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public function __construct(
}

/**
* @return array|\JMS\Serializer\scalar|object
* @param array $filters
* @return array|object
*
* I would of liked to call this list() but it's a reserved keyword in < php7
*/
public function listPayments()
public function listPayments(array $filters = [])
{
$result = $this->getClient()->get(
'payments',
Expand All @@ -50,6 +51,7 @@ public function listPayments()
$this->getAuthorization()->getMerchantId(),
$this->getAuthorization()->getSecret(),
],
'query' => $filters
]
);

Expand Down

0 comments on commit 0f086b4

Please sign in to comment.