-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from checkout/dev
Release 1.0.3
- Loading branch information
Showing
16 changed files
with
543 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/** | ||
* Checkout.com 2010 - 2018. | ||
* Authorised and regulated as an electronic money institution by the UK Financial Conduct Authority (FCA) under number 900816. | ||
* | ||
* Example: Create a SEPA source. | ||
*/ | ||
|
||
|
||
/** | ||
* Include SDK | ||
*/ | ||
require_once "../../checkout.php"; | ||
|
||
|
||
/** | ||
* Use namespaces. | ||
*/ | ||
|
||
use Checkout\CheckoutApi; | ||
use Checkout\Models\Address; | ||
use Checkout\Models\Product; | ||
use Checkout\Models\Sources\Klarna; | ||
use Checkout\Models\Payments\Payment; | ||
use Checkout\Models\Payments\KlarnaSource; | ||
|
||
/** | ||
* Create new instance of Checkout | ||
*/ | ||
$checkout = new CheckoutApi('secret_key_goes_here'); // Klarna enabled sandbox account: sk_test_1dde8193-51d5-457a-8af5-1930200cd8cb | ||
|
||
|
||
/** | ||
* Add new Klarna source. | ||
*/ | ||
|
||
/* Get source */ | ||
$product = new Product(); | ||
$product->name = ''; | ||
$product->quantity = 1; | ||
$product->unit_price = 999; | ||
$product->tax_rate = 1; | ||
$product->total_amount = 999; | ||
$product->total_tax_amount = 1; | ||
|
||
$klarna = new Klarna('GB', 'GBP', 'en-GB', 999, 1, array($product)); | ||
$source = $checkout->sources()->add($klarna); | ||
|
||
|
||
/* | ||
* [Authorize Klarna]: Pass $source->getTokenId() to Klarna JS SDK. | ||
* Learn more at https://docs.checkout.com/docs/klarna. | ||
*/ | ||
|
||
|
||
/* Billing/Shipping */ | ||
$address = new Address(); | ||
$address->given_name = ''; | ||
$address->family_name = ''; | ||
$address->email = ''; | ||
$address->title = ''; | ||
$address->street_address = ''; | ||
$address->street_address2 = ''; | ||
$address->postal_code = ''; | ||
$address->city = ''; | ||
$add->region = ''; | ||
$address->phone = ''; | ||
$address->country = ''; | ||
|
||
|
||
|
||
|
||
$source = new KlarnaSource(/* `authorization_token` from Klarna JS SDK*/, 'GB', 'en-GB', $address, 1, array($product)); | ||
$payment = new Payment($source, 'GBP'); | ||
$payment->amount = 999; | ||
|
||
$res = $checkout->payments()->request($payment); | ||
|
||
|
||
|
||
var_dump($details); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Checkout.com | ||
* Authorised and regulated as an electronic money institution | ||
* by the UK Financial Conduct Authority (FCA) under number 900816. | ||
* | ||
* PHP version 7 | ||
* | ||
* @category SDK | ||
* @package Checkout.com | ||
* @author Platforms Development Team <platforms@checkout.com> | ||
* @copyright 2010-2019 Checkout.com | ||
* @license https://opensource.org/licenses/mit-license.html MIT License | ||
* @link https://docs.checkout.com/ | ||
*/ | ||
|
||
namespace Checkout\Models\Payments; | ||
|
||
use Checkout\Models\Address; | ||
|
||
/** | ||
* Payment method EPS. | ||
* | ||
* @category SDK | ||
* @package Checkout.com | ||
* @author Platforms Development Team <platforms@checkout.com> | ||
* @license https://opensource.org/licenses/mit-license.html MIT License | ||
* @link https://docs.checkout.com/ | ||
*/ | ||
class EpsSource extends IdSource | ||
{ | ||
|
||
/** | ||
* Qualified name of the class. | ||
* | ||
* @var string | ||
*/ | ||
const QUALIFIED_NAME = __CLASS__; | ||
|
||
/** | ||
* Qualified namespace of the class. | ||
* | ||
* @var string | ||
*/ | ||
const QUALIFIED_NAMESPACE = __NAMESPACE__; | ||
|
||
/** | ||
* Name of the model. | ||
* | ||
* @var string | ||
*/ | ||
const MODEL_NAME = 'eps'; | ||
|
||
|
||
/** | ||
* Magic Methods | ||
*/ | ||
|
||
/** | ||
* Initialise payment | ||
* | ||
* @param string $token A description of the payment. | ||
*/ | ||
public function __construct($purpose) | ||
{ | ||
$this->type = static::MODEL_NAME; | ||
$this->purpose = $purpose; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* Checkout.com | ||
* Authorised and regulated as an electronic money institution | ||
* by the UK Financial Conduct Authority (FCA) under number 900816. | ||
* | ||
* PHP version 7 | ||
* | ||
* @category SDK | ||
* @package Checkout.com | ||
* @author Platforms Development Team <platforms@checkout.com> | ||
* @copyright 2010-2019 Checkout.com | ||
* @license https://opensource.org/licenses/mit-license.html MIT License | ||
* @link https://docs.checkout.com/ | ||
*/ | ||
|
||
namespace Checkout\Models\Payments; | ||
|
||
use Checkout\Models\Address; | ||
|
||
/** | ||
* Payment method Klarna. | ||
* | ||
* @category SDK | ||
* @package Checkout.com | ||
* @author Platforms Development Team <platforms@checkout.com> | ||
* @license https://opensource.org/licenses/mit-license.html MIT License | ||
* @link https://docs.checkout.com/ | ||
*/ | ||
class KlarnaSource extends IdSource | ||
{ | ||
|
||
/** | ||
* Qualified name of the class. | ||
* | ||
* @var string | ||
*/ | ||
const QUALIFIED_NAME = __CLASS__; | ||
|
||
/** | ||
* Qualified namespace of the class. | ||
* | ||
* @var string | ||
*/ | ||
const QUALIFIED_NAMESPACE = __NAMESPACE__; | ||
|
||
/** | ||
* Name of the model. | ||
* | ||
* @var string | ||
*/ | ||
const MODEL_NAME = 'klarna'; | ||
|
||
|
||
/** | ||
* Magic Methods | ||
*/ | ||
|
||
/** | ||
* Initialise payment | ||
* | ||
* @param string $token Klarna authentication token, obtained by the merchant during client transaction authorization. | ||
* @param string $currency The currency in which the payment is being made (three-letter ISO 4217 code) | ||
* @param string $locale The customer's locale (RFC 1766 code). | ||
* @param Address $billing Customer's billing address. | ||
* @param integer $tax Total tax amount of the order. | ||
* @param Product[] $products This object is passed directly to Klarna as order_lines. | ||
*/ | ||
public function __construct($token, $country, $locale, Address $billing, $tax, array $products) | ||
{ | ||
$this->type = static::MODEL_NAME; | ||
$this->authorization_token = $token; | ||
$this->billing_address = $billing; | ||
$this->purchase_country = $country; | ||
$this->locale = $locale; | ||
$this->tax_amount = $tax; | ||
$this->products = $products; | ||
} | ||
} |
Oops, something went wrong.