PHPackages                             darwinpricing/darwinpricing-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. darwinpricing/darwinpricing-client

ActiveLibrary[API Development](/categories/api)

darwinpricing/darwinpricing-client
==================================

PHP Client for the dynamic geo-pricing engine Darwin Pricing

5.2.0(9y ago)21.9kLGPL-3.0PHPPHP &gt;=5.0.0

Since Oct 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/darwinpricing/darwinpricing-client-php)[ Packagist](https://packagist.org/packages/darwinpricing/darwinpricing-client)[ Docs](https://www.darwinpricing.com)[ RSS](/packages/darwinpricing-darwinpricing-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (13)Used By (0)

Darwin Pricing
==============

[](#darwin-pricing)

PHP Client for the dynamic geo-pricing engine [Darwin Pricing](https://www.darwinpricing.com) by [SPOSEA](https://www.sposea.com)

[![Build Status](https://camo.githubusercontent.com/d29487619c4d368b299600243b510f0c9a0ce9c56d52c083ec43c119d9b53ef9/68747470733a2f2f7472617669732d63692e6f72672f64617277696e70726963696e672f64617277696e70726963696e672d636c69656e742d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/darwinpricing/darwinpricing-client-php)[ ![Codeship Status for darwinpricing/darwinpricing-client-php](https://camo.githubusercontent.com/11f0a65ca661601eaf36d0d6408ba0b39d5aa9e925c5d6bf727ef5c5c1bc1b76/68747470733a2f2f6170702e636f6465736869702e636f6d2f70726f6a656374732f39336463636136302d313738632d303133352d333961612d3265643264646263326533392f7374617475733f6272616e63683d6d6173746572)](https://app.codeship.com/projects/218577)

Basic Usage
-----------

[](#basic-usage)

Create a free account on [Darwin Pricing](https://admin.darwinpricing.com).

Instantiate the Darwin Pricing client with your API credentials:

```
$serverUrl = 'https://api2.darwinpricing.com'; // Use the URL of your API server
$clientId = 50000; // Use the client ID of your Darwin Pricing account
$clientSecret = 'abcdef'; // Use the client secret of your Darwin Pricing account
$darwinPricing = new \DarwinPricing_Client($serverUrl, $clientId, $clientSecret);
```

In order to add our geo-targeted coupon box to your storefront, retrieve the URL of the front-end script:

```
$widgetUrl = $darwinPricing->getWidgetUrl();
```

Then load this script asynchronously on your website:

```
(function(d,t,s,f){s=d.createElement(t);s.src=;s.async=1;f=d.getElementsByTagName(t)[0];f.parentNode.insertBefore(s,f)})(document,'script')
```

To track payments and payment reversals, use:

```
$customerIp = '134.3.197.187'; // Use the IP address of your customer
$customer = new \DarwinPricing_Client_Visitor($customerIp);
$darwinPricing->setVisitor($customer);

$profitAmount = 12.34; // Compute your actual net profit for this payment
$profitCurrencyCode = 'USD'; // Use the 3 letters code according to ISO 4217
$profit = new \DarwinPricing_Client_Price($profitAmount, $profitCurrencyCode);
$darwinPricing->addPayment($profit);
```

Darwin Pricing optimizes automatically your geo-pricing strategy in order to maximize your total net profit. But you can also maximize any other KPI of your choice, depending on your current business goals. Just send us the appropriate metric instead of your net profit, and your geo-pricing strategy will be optimized accordingly.

Order Details
-------------

[](#order-details)

Instead of computing your net profits, you can also send directly the full order details to your Darwin Pricing account. Net profits will then be computed on your behalf. This will also unlock enhanced reporting capabilities in your Darwin Pricing account, like profit margins and coupon code usage.

In order to track new orders, use:

```
$order = new DarwinPricing_Client_Order();
$order->setCustomerIp('134.3.197.187'); // The IP address of your customer
$order->setCustomerId('#12321'); // Your reference for this customer (optional)
$order->setEmail('customer@example.com'); // The e-mail address of this customer (optional)

$order->setOrderId('12345'); // The internal ID of this order in your eCommerce system
$order->setOrderReference('#201612345'); // Your reference for this order (optional)
$order->setCurrency('USD'); // The currency code for this order (3 letters code according to ISO 4217)
// For each item sold:
//  - The unit price of this item (including VAT when applicable)
//  - The number of items sold for this order
//  - Your SKU for this item (optional)
//  - The item's internal product ID in your eCommerce system (optional)
//  - The item's internal variant ID in your eCommerce system (optional)
//  - Your average unit costs to purchase or produce this item (optional)
//  - The Value Added Tax rate in percent for this item (when applicable)
$order->addItem(120.90, 3, 'A1234', '123', '456', 89.95, 19.5);
$order->addCoupon('HAPPY10'); // The coupon code redeemed for this order (optional)
$order->setShippingAmount(9.99); // The shipping costs billed to your customer (optional, including VAT when applicable)
$order->setShippingVatRate(12.8); // The Value Added Tax rate in percent for the shipping costs (when applicable)
$order->setTaxes(38.85); // The amount of sales tax (not VAT) for this order (when applicable)
$order->setTotal(375.54); // The total amount billed to your customer (including taxes)

$darwinPricing->trackOrder($order);
```

The customer's e-mail address is only being used to serve geo-targeted newsletter banners in case they are being loaded through an image proxy, like in Google Mail.

Custom integration
------------------

[](#custom-integration)

Instead of adding our geo-targeted coupon box to your storefront, you can also retrieve the geo-targeted coupon code from the backend of your store with:

```
$visitorIp = '134.3.197.187'; // Use the IP address of your visitor
$visitor = new \DarwinPricing_Client_Visitor($visitorIp);
$darwinPricing->setVisitor($visitor);

$discountPercent = $darwinPricing->getDiscountPercent();
$discountCode = $darwinPricing->getDiscountCode();
```

This is especially useful if you want to adjust directly your prices to the local market without using a coupon code for this purpose. If you are selling a subscription-based product, you can also retrieve a pricing plan identifier instead of a discount code. Contact us at  to find out the best solution to fit your needs!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Recently: every ~130 days

Total

12

Last Release

3643d ago

Major Versions

2.0.1 → 3.0.02013-11-17

3.2.2 → 4.0.02014-12-19

4.0.0 → 5.0.02015-12-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/290f93f6bb0d434f88866d1aa15c2cccb74111729f2771d6639d0f400d24239d?d=identicon)[sebastien-fauvel](/maintainers/sebastien-fauvel)

---

Top Contributors

[![sebastien-fauvel](https://avatars.githubusercontent.com/u/4215521?v=4)](https://github.com/sebastien-fauvel "sebastien-fauvel (71 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darwinpricing-darwinpricing-client/health.svg)

```
[![Health](https://phpackages.com/badges/darwinpricing-darwinpricing-client/health.svg)](https://phpackages.com/packages/darwinpricing-darwinpricing-client)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
