Skip to content

Commit

Permalink
Amazon Pay API SDK PHP 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
akshitaWaldia committed Mar 17, 2023
1 parent 5b38287 commit 5d5c6a4
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 2 deletions.
54 changes: 53 additions & 1 deletion Amazon/Pay/API/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Client implements ClientInterface
{
const SDK_VERSION = '2.5.2';
const SDK_VERSION = '2.6.0';
const HASH_ALGORITHM = 'sha256';
const API_VERSION = 'v2';

Expand Down Expand Up @@ -645,4 +645,56 @@ public function getRefund($refundId, $headers = null)
return $this->apiCall('GET', self::API_VERSION . '/refunds/' . $refundId, null, $headers);
}

// ----------------------------------- CV2 REPORTING APIS -----------------------------------


public function getReports($queryParameters = null, $headers = null)

This comment has been minimized.

Copy link
@alies-dev

alies-dev Mar 17, 2023

@akshitaWaldia
BTW:
Doc block from interfaces allows passing a string as the first param:

* @optional queryParameters - [String in JSON format] or [array] *

But \Amazon\Pay\API\Client::apiCall doesn't support $queryParams of string type:

if (isset($queryParams)) {
if (!is_array($queryParams)) {
throw new \Exception('queryParameters must be a key-value array; e.g. array(\'accountId\' => \'ABCD1234XYZIJK\')');
}
$url = $url . '?' . $this->createCanonicalQuery($queryParams);
$requestParameters = $queryParams;
} else {
$requestParameters = array();
}

This comment has been minimized.

Copy link
@Dexterzprotege

Dexterzprotege Mar 17, 2023

Contributor

Will correct this, thanks for letting us know

{
return $this->apiCall('GET', self::API_VERSION . '/reports', null, $headers, $queryParameters);
}


public function getReportById($reportId, $headers = null)
{
return $this->apiCall('GET', self::API_VERSION . '/reports/' . $reportId, null, $headers);
}


public function getReportDocument($reportDocumentId, $headers = null)
{
return $this->apiCall('GET', self::API_VERSION . '/report-documents/' . $reportDocumentId, null, $headers);
}


public function getReportSchedules($reportTypes = null, $headers = null)
{
$queryParameters = array('reportTypes' => $reportTypes);
return $this->apiCall('GET', self::API_VERSION . '/report-schedules', null, $headers, $queryParameters);
}


public function getReportScheduleById($reportScheduleId, $headers = null)
{
return $this->apiCall('GET', self::API_VERSION . '/report-schedules/' . $reportScheduleId, null, $headers);
}


public function createReport($requestPayload, $headers = null)
{
return $this->apiCall('POST', self::API_VERSION . '/reports' , $requestPayload, $headers);
}


public function createReportSchedule($requestPayload, $headers = null)
{
return $this->apiCall('POST', self::API_VERSION . '/report-schedules' , $requestPayload, $headers);
}


public function cancelReportSchedule($reportScheduleId, $headers = null)
{
return $this->apiCall('DELETE', self::API_VERSION . '/report-schedules/' . $reportScheduleId, null, $headers);
}


}
85 changes: 85 additions & 0 deletions Amazon/Pay/API/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,89 @@ public function createSignature($http_request_method, $request_uri, $request_par
*/
public function apiCall($method, $urlFragment, $payload, $headers = null);


// ----------------------------------- Reporting v2 APIs -----------------------------------


/* Amazon Checkout v2 Reporting APIs - Get Reports
*
* Returns report details for the reports that match the filters that you specify.
*
* @optional queryParameters - [String in JSON format] or [array]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function getReports($queryParameters = null, $headers = null);


/* Amazon Checkout v2 Reporting APIs - Get Report By Id
*
* Returns report details for the given reportId.
*
* @param $reportId [String]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function getReportById($reportId, $headers = null);


/* Amazon Checkout v2 Reporting APIs - Get Report Document
*
* Returns the pre-signed S3 URL for the report. The report can be downloaded using this URL.
*
* @param $reportDocumentId [String]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function getReportDocument($reportDocumentId, $headers = null);


/* Amazon Checkout v2 Reporting APIs - Get Report Schedules
*
* Returns report schedule details that match the filters criteria specified.
*
* @optional reportTypes - [String]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function getReportSchedules($reportTypes = null, $headers = null);



/* Amazon Checkout v2 Reporting APIs - Get Report Schedules By Id
*
* Returns the report schedule details that match the given ID.
*
* @param $reportScheduleId [String]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function getReportScheduleById($reportScheduleId, $headers = null);


/* Amazon Checkout v2 Reporting APIs - Create Report
*
* Submits a request to generate a report based on the reportType and date range specified.
*
* @param $requestPayload [String in JSON format] or [array]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function createReport($requestPayload, $headers);


/* Amazon Checkout v2 Reporting APIs - Create Report Schedule
*
* Creates a report schedule for the given reportType. Only one schedule per report type allowed.
*
* @param $requestPayload [String in JSON format] or [array]
* @param headers - [array] - requires x-amz-pay-Idempotency-Key header; optional x-amz-pay-authtoken
*/
public function createReportSchedule($requestPayload, $headers);


/* Amazon Checkout v2 Reporting APIs - Cancel Report Schedule
*
* Cancels the report schedule with the given reportScheduleId.
*
* @param $reportScheduleId [String]
* @optional headers - [array] - optional x-amz-pay-authtoken
*/
public function cancelReportSchedule($reportScheduleId, $headers = null);


}
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Version 2.6.0 - March 2023
* Introducing new v2 Reporting APIs. Reports allow you to retrieve consolidated data about Amazon Pay transactions and settlements. In addition to managing and downloading reports using Seller Central, Amazon Pay offers APIs to manage and retrieve your reports.

### Version 2.5.2 - March 2023
* Added Error Code 408 to API retry logic
* Corrected Typos & refactored codes
Expand Down
Loading

2 comments on commit 5d5c6a4

@alies-dev
Copy link

@alies-dev alies-dev commented on 5d5c6a4 Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @akshitaWaldia

it actually should be BC breaks release as now developers need to implement new methods for the public interface Amazon/Pay/API/ClientInterface.php. Or the package doesn't use SemVer 2.0?

@Dexterzprotege
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @akshitaWaldia

it actually should be BC breaks release as now developers need to implement new methods for the public interface Amazon/Pay/API/ClientInterface.php. Or the package doesn't use SemVer 2.0?

Yes, it makes sense. We are changing this

Please sign in to comment.