在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:mollie/mollie-api-php开源软件地址:https://github.com/mollie/mollie-api-php开源编程语言:PHP 100.0%开源软件介绍:Mollie API client for PHPAccepting iDEAL, Apple Pay, Bancontact, SOFORT Banking, Creditcard, SEPA Bank transfer, SEPA Direct debit, PayPal, Belfius Direct Net, KBC/CBC, paysafecard, ING Home'Pay, Giftcards, Giropay, EPS and Przelewy24 online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers. RequirementsTo use the Mollie API client, the following things are required:
For leveraging Mollie Connect (advanced use cases only), we recommend also installing our OAuth2 client. Composer InstallationBy far the easiest way to install the Mollie API client is to require it with Composer.
The version of the API client corresponds to the version of the API it implements. Check the notes on migration to see what changes you need to make if you want to start using a newer API version. Manual InstallationIf you're not familiar with using composer we've added a ZIP file to the releases containing the API client and all the packages normally installed by composer.
Download the Include the How to receive paymentsTo successfully receive a payment, these steps should be implemented:
Find our full documentation online on docs.mollie.com. Getting startedInitializing the Mollie API client, and setting your API key. $mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"); Creating a new payment. $payment = $mollie->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "10.00"
],
"description" => "My first API payment",
"redirectUrl" => "https://webshop.example.org/order/12345/",
"webhookUrl" => "https://webshop.example.org/mollie-webhook/",
]); After creation, the payment id is available in the After storing the payment id you can send the customer to the checkout using the header("Location: " . $payment->getCheckoutUrl(), true, 303); This header location should always be a GET, thus we enforce 303 http response code For a payment create example, see Example - New Payment. Retrieving paymentsWe can use the $payment = $mollie->payments->get($payment->id);
if ($payment->isPaid())
{
echo "Payment received.";
} Or retrieve a collection of payments. $payments = $mollie->payments->page(); For an extensive example of listing payments with the details and status, see Example - List Payments. Payment webhookWhen the status of a payment changes the MulticurrencySince 2.0 it is now possible to create non-EUR payments for your customers. A full list of available currencies can be found in our documentation. $payment = $mollie->payments->create([
"amount" => [
"currency" => "USD",
"value" => "10.00"
],
"description" => "Order #12345",
"redirectUrl" => "https://webshop.example.org/order/12345/",
"webhookUrl" => "https://webshop.example.org/mollie-webhook/",
]); After creation, the Fully integrated iDEAL paymentsIf you want to fully integrate iDEAL payments in your web site, some additional steps are required. First, you need to retrieve the list of issuers (banks) that support iDEAL and have your customer pick the issuer he/she wants to use for the payment. Retrieve the iDEAL method and include the issuers $method = $mollie->methods->get(\Mollie\Api\Types\PaymentMethod::IDEAL, ["include" => "issuers"]);
Create a payment with the selected issuer: $payment = $mollie->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "10.00"
],
"description" => "My first API payment",
"redirectUrl" => "https://webshop.example.org/order/12345/",
"webhookUrl" => "https://webshop.example.org/mollie-webhook/",
"method" => \Mollie\Api\Types\PaymentMethod::IDEAL,
"issuer" => $selectedIssuerId, // e.g. "ideal_INGBNL2A"
]); The Refunding paymentsThe API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and definitive. refunds are supported for all methods except for paysafecard and gift cards. $payment = $mollie->payments->get($payment->id);
// Refund € 2 of this payment
$refund = $payment->refund([
"amount" => [
"currency" => "EUR",
"value" => "2.00"
]
]); For a working example, see Example - Refund payment. Enabling debug modeWhen debugging it can be convenient to have the submitted request available on the In order to prevent leaking sensitive request data into your local application logs, debugging is disabled by default. To enable debugging and inspect the request: /** @var $mollie \Mollie\Api\MollieApiClient */
$mollie->enableDebugging();
try {
$mollie->payments->get('tr_12345678');
} catch (\Mollie\Api\Exceptions\ApiException $exception) {
$request = $exception->getRequest();
} If you're logging the To disable debugging again: /** @var $mollie \Mollie\Api\MollieApiClient */
$mollie->disableDebugging(); Note that debugging is only available when using the default Guzzle http adapter ( API documentationIf you wish to learn more about our API, please visit the Mollie Developer Portal. API Documentation is available in English. Want to help us make our API client even better?Want to help us make our API client even better? We take pull requests, sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. Check out our vacancies or get in touch. LicenseBSD (Berkeley Software Distribution) License. Copyright (c) 2013-2018, Mollie B.V. SupportContact: www.mollie.com — [email protected] — +31 20 820 20 70 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论