-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"name": "mollie/mollie-api-php", | ||
"version": "1.3.3", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
RickWong
Contributor
|
||
"description": "Mollie API client library for PHP", | ||
"homepage": "https://github.com/mollie/mollie-api-php", | ||
"license": "BSD-2-Clause", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/* | ||
* Example 11 - How to create a new customer in the Mollie API. | ||
*/ | ||
|
||
try | ||
{ | ||
/* | ||
* Initialize the Mollie API library with your API key or OAuth access token. | ||
*/ | ||
include "initialize.php"; | ||
|
||
/* | ||
* Customer creation parameters. | ||
* | ||
* See: https://www.mollie.com/en/docs/reference/customers/create | ||
*/ | ||
$customer = $mollie->customers->create(array( | ||
"name" => "Luke Skywalker", | ||
"email" => "[email protected]", | ||
"metadata" => array( | ||
"isJedi" => TRUE, | ||
), | ||
)); | ||
|
||
echo "<p>New customer created " . htmlspecialchars($customer->id) . " (" . htmlspecialchars($customer->name) . ").</p>"; | ||
} | ||
catch (Mollie_API_Exception $e) | ||
{ | ||
echo "API call failed: " . htmlspecialchars($e->getMessage()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/* | ||
* Example 12 - How to create a new customer in the Mollie API. | ||
*/ | ||
|
||
try | ||
{ | ||
/* | ||
* Initialize the Mollie API library with your API key or OAuth access token. | ||
*/ | ||
include "initialize.php"; | ||
|
||
/** | ||
* Retrieve the last created customer for this example. | ||
* If no customers are created yet, run example 11. | ||
*/ | ||
$customer = $mollie->customers->all(0, 1)->data[0]; | ||
|
||
/* | ||
* Generate a unique order id for this example. It is important to include this unique attribute | ||
* in the redirectUrl (below) so a proper return page can be shown to the customer. | ||
*/ | ||
$order_id = time(); | ||
|
||
/* | ||
* Determine the url parts to these example files. | ||
*/ | ||
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http"; | ||
$hostname = $_SERVER['HTTP_HOST']; | ||
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']); | ||
|
||
/* | ||
* Customer Payment creation parameters. | ||
* | ||
* See: https://www.mollie.com/en/docs/reference/customers/create-payment | ||
*/ | ||
$payment = $mollie->customers_payments->with($customer)->create(array( | ||
"amount" => 10.00, | ||
"description" => "My first Customer payment", | ||
"redirectUrl" => "{$protocol}://{$hostname}{$path}/03-return-page.php?order_id={$order_id}", | ||
"webhookUrl" => "{$protocol}://{$hostname}{$path}/02-webhook-verification.php" | ||
)); | ||
|
||
/* | ||
* In this example we store the order with its payment status in a database. | ||
*/ | ||
database_write($order_id, $payment->status); | ||
|
||
/* | ||
* Send the customer off to complete the payment. | ||
*/ | ||
header("Location: " . $payment->getPaymentUrl()); | ||
} | ||
catch (Mollie_API_Exception $e) | ||
{ | ||
echo "API call failed: " . htmlspecialchars($e->getMessage()); | ||
} | ||
|
||
|
||
/* | ||
* NOTE: This example uses a text file as a database. Please use a real database like MySQL in production code. | ||
*/ | ||
function database_write ($order_id, $status) | ||
{ | ||
$order_id = intval($order_id); | ||
$database = dirname(__FILE__) . "/orders/order-{$order_id}.txt"; | ||
|
||
file_put_contents($database, $status); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/* | ||
* Example 13 - How to retrieve your customers' payments history. | ||
*/ | ||
|
||
try | ||
{ | ||
/* | ||
* Initialize the Mollie API library with your API key. | ||
* | ||
* See: https://www.mollie.com/beheer/account/profielen/ | ||
*/ | ||
include "initialize.php"; | ||
|
||
/** | ||
* Retrieve the last created customer for this example. | ||
* If no customers are created yet, run example 11. | ||
*/ | ||
$customer = $mollie->customers->all(0, 1)->data[0]; | ||
|
||
// Pagination | ||
$offset = 0; | ||
$limit = 25; | ||
|
||
/* | ||
* Get the all payments for this API key ordered by newest. | ||
*/ | ||
$payments = $mollie->customers_payments->with($customer)->all($offset, $limit); | ||
|
||
foreach ($payments as $payment) | ||
{ | ||
echo "€ " . htmlspecialchars($payment->amount) . ", status: " . htmlspecialchars($payment->status) . "<br>"; | ||
} | ||
} | ||
catch (Mollie_API_Exception $e) | ||
{ | ||
echo "API call failed: " . htmlspecialchars($e->getMessage()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2015, Mollie B.V. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* - Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY | ||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
* DAMAGE. | ||
* | ||
* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php | ||
* @author Mollie B.V. <[email protected]> | ||
* @copyright Mollie B.V. | ||
* @link https://www.mollie.com | ||
*/ | ||
class Mollie_API_Object_Customer | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $resource; | ||
|
||
/** | ||
* Id of the customer. | ||
* | ||
* @var string | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* Either "live" or "test". Indicates this being a test or a live (verified) customer. | ||
* | ||
* @var string | ||
*/ | ||
public $mode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $email; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $locale; | ||
|
||
/** | ||
* @var object|mixed|null | ||
*/ | ||
public $metadata; | ||
|
||
/** | ||
* @var string[]|array | ||
*/ | ||
public $recentlyUsedMethods; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $createdDatetime; | ||
} |
Dear @RickWong,
Is there a reason that the version number was removed here?
This causes trouble with the Drupal mollie_payment module...