Skip to content

Commit

Permalink
add PartnerAttributionId to API-Calls��* update
Browse files Browse the repository at this point in the history
* confirm
* (re-)authorize
* capture
* refund
  • Loading branch information
mariolorenz committed Nov 10, 2023
1 parent c253fe4 commit 7c131e1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
40 changes: 32 additions & 8 deletions generated/Service/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,21 @@ public function showOrderDetails($id, $fields): Order
*
* @param $patchRequest mixed
*
* @throws ApiException
* @param $payPalPartnerAttributionId string
*
* @return void
*@throws ApiException
*/
public function updateOrder($id, array $patchRequest): void
public function updateOrder($id, array $patchRequest, string $payPalPartnerAttributionId = ''): void
{
$path = "/orders/{$id}";

$headers = [];
$headers['Content-Type'] = 'application/json';

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($patchRequest, true);
$response = $this->send('PATCH', $path, [], $headers, $body);
Expand All @@ -146,7 +151,6 @@ public function validatePaymentMethod($payPalClientMetadataId, $id, OrderValidat
$headers['PayPal-Client-Metadata-Id'] = $payPalClientMetadataId;
$headers['Content-Type'] = 'application/json';


$body = json_encode($orderValidateRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
$jsonData = json_decode($response->getBody(), true);
Expand All @@ -162,16 +166,18 @@ public function validatePaymentMethod($payPalClientMetadataId, $id, OrderValidat
*
* @param $confirmOrderRequest mixed
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
* and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource
* representation, including the current state of the resource.</li></ul>
*
* @throws ApiException
* @return Order
*@throws ApiException
*/
public function confirmTheOrder($payPalClientMetadataId, $id, ConfirmOrderRequest $confirmOrderRequest, $prefer = 'return=minimal'): Order
public function confirmTheOrder($payPalClientMetadataId, $id, ConfirmOrderRequest $confirmOrderRequest, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal',): Order
{
$path = "/orders/{$id}/confirm-payment-source";

Expand All @@ -180,6 +186,9 @@ public function confirmTheOrder($payPalClientMetadataId, $id, ConfirmOrderReques
$headers['Content-Type'] = 'application/json';
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($confirmOrderRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand All @@ -204,6 +213,8 @@ public function confirmTheOrder($payPalClientMetadataId, $id, ConfirmOrderReques
* merchant. For details, see <a
* href="/docs/api/reference/api-requests/#paypal-auth-assertion">PayPal-Auth-Assertion</a>.
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -213,7 +224,7 @@ public function confirmTheOrder($payPalClientMetadataId, $id, ConfirmOrderReques
* @throws ApiException
* @return Order
*/
public function authorizePaymentForOrder($payPalClientMetadataId, $id, OrderAuthorizeRequest $authorizeRequest, $payPalAuthAssertion, $prefer = 'return=minimal'): Order
public function authorizePaymentForOrder($payPalClientMetadataId, $id, OrderAuthorizeRequest $authorizeRequest, $payPalAuthAssertion, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Order
{
$path = "/orders/{$id}/authorize";

Expand All @@ -223,6 +234,9 @@ public function authorizePaymentForOrder($payPalClientMetadataId, $id, OrderAuth
$headers['PayPal-Auth-Assertion'] = $payPalAuthAssertion;
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($authorizeRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand All @@ -247,6 +261,8 @@ public function authorizePaymentForOrder($payPalClientMetadataId, $id, OrderAuth
* merchant. For details, see <a
* href="/docs/api/reference/api-requests/#paypal-auth-assertion">PayPal-Auth-Assertion</a>.
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -256,7 +272,7 @@ public function authorizePaymentForOrder($payPalClientMetadataId, $id, OrderAuth
* @throws ApiException
* @return Order
*/
public function capturePaymentForOrder($payPalClientMetadataId, $id, OrderCaptureRequest $orderCaptureRequest, $payPalAuthAssertion, $prefer = 'return=minimal'): Order
public function capturePaymentForOrder($payPalClientMetadataId, $id, OrderCaptureRequest $orderCaptureRequest, $payPalAuthAssertion, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Order
{
$path = "/orders/{$id}/capture";

Expand All @@ -266,6 +282,9 @@ public function capturePaymentForOrder($payPalClientMetadataId, $id, OrderCaptur
$headers['PayPal-Auth-Assertion'] = $payPalAuthAssertion;
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($orderCaptureRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand All @@ -280,6 +299,8 @@ public function capturePaymentForOrder($payPalClientMetadataId, $id, OrderCaptur
*
* @param $id string The ID of the order to save.
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -289,14 +310,17 @@ public function capturePaymentForOrder($payPalClientMetadataId, $id, OrderCaptur
* @throws ApiException
* @return Order
*/
public function saveOrder($payPalClientMetadataId, $id, $prefer = 'return=minimal'): Order
public function saveOrder($payPalClientMetadataId, $id, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Order
{
$path = "/orders/{$id}/save";

$headers = [];
$headers['PayPal-Client-Metadata-Id'] = $payPalClientMetadataId;
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = null;
$response = $this->send('POST', $path, [], $headers, $body);
Expand Down
37 changes: 31 additions & 6 deletions generated/Service/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Payments extends BaseService
*
* @param $authorizeRequest mixed
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -34,14 +36,17 @@ class Payments extends BaseService
* @throws ApiException
* @return Authorization
*/
public function authorizePayment(AuthorizationRequest $authorizeRequest, $prefer = 'return=minimal'): Authorization
public function authorizePayment(AuthorizationRequest $authorizeRequest, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Authorization
{
$path = "/authorizations";

$headers = [];
$headers['Content-Type'] = 'application/json';
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($authorizeRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand Down Expand Up @@ -76,6 +81,8 @@ public function showDetailsForAuthorizedPayment($authorizationId): Authorization
*
* @param $capture mixed
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -85,14 +92,17 @@ public function showDetailsForAuthorizedPayment($authorizationId): Authorization
* @throws ApiException
* @return Capture
*/
public function captureAuthorizedPayment($authorizationId, CaptureRequest $capture, $prefer = 'return=minimal'): Capture
public function captureAuthorizedPayment($authorizationId, CaptureRequest $capture, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Capture
{
$path = "/authorizations/{$authorizationId}/capture";

$headers = [];
$headers['Content-Type'] = 'application/json';
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($capture, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand All @@ -115,23 +125,28 @@ public function captureAuthorizedPayment($authorizationId, CaptureRequest $captu
*
* @param $reauthorizeRequest mixed
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
* and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource
* representation, including the current state of the resource.</li></ul>
*
* @throws ApiException
* @return Authorization
*@throws ApiException
*/
public function reauthorizeAuthorizedPayment($authorizationId, ReauthorizeRequest $reauthorizeRequest, $prefer = 'return=minimal'): Authorization
public function reauthorizeAuthorizedPayment($authorizationId, ReauthorizeRequest $reauthorizeRequest, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Authorization
{
$path = "/authorizations/{$authorizationId}/reauthorize";

$headers = [];
$headers['Content-Type'] = 'application/json';
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($reauthorizeRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand Down Expand Up @@ -172,6 +187,8 @@ public function voidAuthorizedPayment($authorizationId, $payPalAuthAssertion): v
*
* @param $capture mixed
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -181,14 +198,17 @@ public function voidAuthorizedPayment($authorizationId, $payPalAuthAssertion): v
* @throws ApiException
* @return Capture
*/
public function captureSavedOrderDirectly(OrderCaptureRequest $capture, $prefer = 'return=minimal'): Capture
public function captureSavedOrderDirectly(OrderCaptureRequest $capture, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Capture
{
$path = "/captures";

$headers = [];
$headers['Content-Type'] = 'application/json';
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($capture, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand Down Expand Up @@ -231,6 +251,8 @@ public function showCapturedPaymentDetails($captureId): Capture
* must identify the merchant using either a PayPal-Auth-Assertion header or an access token with
* target_subject.</blockquote>
*
* @param $payPalPartnerAttributionId string
*
* @param $prefer string The preferred server response upon successful completion of the request. Value
* is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication
* between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code>
Expand All @@ -240,7 +262,7 @@ public function showCapturedPaymentDetails($captureId): Capture
* @throws ApiException
* @return Refund
*/
public function refundCapturedPayment($captureId, RefundRequest $refundRequest, $payPalAuthAssertion, $prefer = 'return=minimal'): Refund
public function refundCapturedPayment($captureId, RefundRequest $refundRequest, $payPalAuthAssertion, string $payPalPartnerAttributionId = '', $prefer = 'return=minimal'): Refund
{
$path = "/captures/{$captureId}/refund";

Expand All @@ -249,6 +271,9 @@ public function refundCapturedPayment($captureId, RefundRequest $refundRequest,
$headers['PayPal-Auth-Assertion'] = $payPalAuthAssertion;
$headers['Prefer'] = $prefer;

if ($payPalPartnerAttributionId) {
$headers['PayPal-Partner-Attribution-Id'] = $payPalPartnerAttributionId;
}

$body = json_encode($refundRequest, true);
$response = $this->send('POST', $path, [], $headers, $body);
Expand Down
5 changes: 0 additions & 5 deletions src/Onboarding.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace OxidSolutionCatalysts\PayPalApi;

use OxidSolutionCatalysts\PayPalApi\Model\Partner\Operation;
use OxidSolutionCatalysts\PayPalApi\Model\Partner\ReferralData;
use OxidSolutionCatalysts\PayPalApi\Model\Partner\RestApiIntegration;
use OxidSolutionCatalysts\PayPalApi\Model\Partner\RestApiIntegrationFirstPartyDetails;
use OxidSolutionCatalysts\PayPalApi\Service\Partner;
use Psr\Log\LoggerInterface;

class Onboarding extends Client
Expand Down

0 comments on commit 7c131e1

Please sign in to comment.