Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Nov 26, 2024
1 parent e249f3e commit f2f9fcf
Show file tree
Hide file tree
Showing 93 changed files with 253 additions and 402 deletions.
1 change: 1 addition & 0 deletions examples/captures/create-capture.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/captures/get-capture.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Retrieve a payment capture using the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/captures/list-captures.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* List captures for a payment using the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/client-links/create-client-link.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a new client link in the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/create-customer-first-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a first payment to allow recurring payments later.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/create-customer-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a new customer in the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/create-customer-recurring-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create an on-demand recurring payment.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/create-customer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a new customer in the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/delete-customer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Delete a customer from the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/list-customer-payments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to retrieve your customers' payments history.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/customers/update-customer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Updating an existing customer via the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* NOTE: The examples are using a text file as a database.
* Please use a real database like MySQL in production code.
Expand Down
1 change: 1 addition & 0 deletions examples/initialize.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Make sure to disable the display of errors in production code!
*/
Expand Down
1 change: 1 addition & 0 deletions examples/invoices/list-invoices.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* List the Mollie invoices.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/mandates/create-mandate.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Create a customer mandate via the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/mandates/list-mandates.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* List all customer mandates
*/
Expand Down
1 change: 1 addition & 0 deletions examples/mandates/revoke-mandate.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Revoke a customer mandate
*/
Expand Down
1 change: 1 addition & 0 deletions examples/pagination/backwards.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to use pagination with the Mollie API.
*
Expand Down
1 change: 1 addition & 0 deletions examples/pagination/basic_usage.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to use pagination with the Mollie API.
*
Expand Down
1 change: 1 addition & 0 deletions examples/payment-links/create-payment-link.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payment-links/list-payment-links.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to list your payments.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/create-capturable-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/create-ideal-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare an iDEAL payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/create-payment-oauth.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Example 10 - Using OAuth access token to prepare a new payment.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/create-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/create-routed-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/list-methods.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to get the currently activated payment methods for the Payments API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/list-payments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to list your payments.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/refund-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to refund a payment programmatically
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/return.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to show a return page to the customer.
*
Expand Down
1 change: 1 addition & 0 deletions examples/payments/update-payment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to prepare a new payment with the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/payments/webhook.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to verify Mollie API Payments in a webhook.
*
Expand Down
1 change: 1 addition & 0 deletions examples/profiles/create-profile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Create a profile via the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/profiles/delete-profile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Delete a profile via the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/profiles/list-profiles.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Using OAuth access token to list profiles of an account.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/profiles/update-profile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Updating an existing profile via the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/sessions/cancel-session.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Cancel an session using the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/sessions/create-session.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a new session in the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/sessions/list-sessions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* List sessions using the Mollie API.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/sessions/update-session.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to update an session with the Mollie API
*/
Expand Down
1 change: 1 addition & 0 deletions examples/settlements/list-settlements.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Using OAuth access token to list settlements of an account.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/subscriptions/cancel-subscription.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to cancel a subscription.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/subscriptions/create-subscription.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* How to create a regular subscription.
*/
Expand Down
1 change: 1 addition & 0 deletions examples/subscriptions/update-subscription.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Updating an existing subscription via the Mollie API.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/Contracts/SingleResourceEndpointContract.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/EndpointCollection/CustomerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\CustomerCollection;
use Mollie\Api\Resources\LazyCollection;
use Symfony\Component\Console\Helper\Helper;

class CustomerEndpointCollection extends EndpointCollection
{
Expand All @@ -26,6 +25,7 @@ class CustomerEndpointCollection extends EndpointCollection
*
* @param array|CreateCustomerPayload $data An array containing details on the customer.
* @param array|bool|null $testmode
*
* @throws ApiException
*/
public function create($data = [], $testmode = []): Customer
Expand Down
30 changes: 20 additions & 10 deletions src/EndpointCollection/CustomerPaymentsEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace Mollie\Api\EndpointCollection;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\CreatePaymentPayloadFactory;
use Mollie\Api\Factories\GetPaginatedCustomerPaymentsQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Helpers\Arr;
use Mollie\Api\Http\Payload\CreatePaymentPayload;
use Mollie\Api\Http\Query\CreatePaymentQuery;
use Mollie\Api\Http\Requests\CreateCustomerPaymentRequest;
use Mollie\Api\Http\Requests\GetPaginatedCustomerPaymentsRequest;
use Mollie\Api\Resources\Customer;
Expand All @@ -18,40 +21,47 @@ class CustomerPaymentsEndpointCollection extends EndpointCollection
/**
* Create a subscription for a Customer
*
* @param array $payload
*
* @throws ApiException
*/
public function createFor(Customer $customer, array $payload = []): Payment
public function createFor(Customer $customer, array $payload = [], array $query = [], bool $testmode = false): Payment
{
return $this->createForId($customer->id, $payload, $testmode);
return $this->createForId($customer->id, $payload, $query, $testmode);
}

/**
* Create a subscription for a Customer ID
*
* @param string $customerId
* @param array| $payload
* @param array|CreatePaymentPayload $payload
* @param array|CreatePaymentQuery $query
*
* @throws ApiException
*/
public function createForId($customerId, array $payload = []): Payment
public function createForId($customerId, $payload = [], $query = [], bool $testmode = false): Payment
{
$testmode = Helpers::extractBool($payload, 'testmode', false);
$profileId = Arr::get($payload, 'profileId');
if (! $payload instanceof CreatePaymentPayload) {
$testmode = Helpers::extractBool($payload, 'testmode', $testmode);
$payload = CreatePaymentPayloadFactory::new($payload)
->create();
}

if (! $query instanceof CreatePaymentQuery) {
$query = CreatePaymentQuery::fromArray(Arr::wrap($query));
}

/** @var Payment */
return $this->send((new CreateCustomerPaymentRequest($customerId, $profileId))->test($testmode));
return $this->send((new CreateCustomerPaymentRequest($customerId, $payload, $query))->test($testmode));
}

/**
* @param string $from The first resource ID you want to include in your list.
*
* @throws ApiException
*/
public function pageFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = []): PaymentCollection
public function pageFor(Customer $customer, ?string $from = null, ?int $limit = null, array $filters = []): PaymentCollection
{
return $this->pageForId($customer->id, $from, $limit, $parameters);
return $this->pageForId($customer->id, $from, $limit, $filters);
}

/**
Expand Down
Loading

0 comments on commit f2f9fcf

Please sign in to comment.