Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "buckaroo/sdk",
"description": "Buckaroo payment SDK",
"license": "MIT",
"version": "1.20.0",
"version": "1.21.0",
"type": "library",
"require": {
"php": ">=7.4|^8.0",
Expand Down
23 changes: 23 additions & 0 deletions example/transactions/googlepay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

require_once '../bootstrap.php';

use Buckaroo\BuckarooClient;

$buckaroo = new BuckarooClient($_ENV['BPE_WEBSITE_KEY'], $_ENV['BPE_SECRET_KEY']);

//Pay
// Note: paymentData should be the base64 encoded token from Google Pay API
$response = $buckaroo->method('googlepay')->pay([
'amountDebit' => 10,
'invoice' => uniqid(),
'paymentData' => 'BASE64_ENCODED_GOOGLE_PAY_TOKEN',
'customerCardName' => 'John Doe',
]);

//Refund
$response = $buckaroo->method('googlepay')->refund([
'amountCredit' => 10,
'invoice' => '10000480',
'originalTransactionKey' => '9AA4C81A08A84FA7B68E6A6A6291XXXX',
]);
25 changes: 25 additions & 0 deletions src/PaymentMethods/GooglePay/GooglePay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Buckaroo\PaymentMethods\GooglePay;

use Buckaroo\Models\Model;
use Buckaroo\PaymentMethods\GooglePay\Models\Pay;
use Buckaroo\PaymentMethods\PayablePaymentMethod;
use Buckaroo\Transaction\Response\TransactionResponse;

class GooglePay extends PayablePaymentMethod
{
/**
* @var string
*/
protected string $paymentName = 'googlepay';

/**
* @param Model|null $model
* @return TransactionResponse
*/
public function pay(?Model $model = null): TransactionResponse
{
return parent::pay($model ?? new Pay($this->payload));
}
}
29 changes: 29 additions & 0 deletions src/PaymentMethods/GooglePay/Models/Pay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\PaymentMethods\GooglePay\Models;

use Buckaroo\Models\ServiceParameter;

class Pay extends ServiceParameter
{
protected string $paymentData;
protected string $customerCardName;
}
2 changes: 2 additions & 0 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use Buckaroo\PaymentMethods\Trustly\Trustly;
use Buckaroo\PaymentMethods\Afterpay\Afterpay;
use Buckaroo\PaymentMethods\ApplePay\ApplePay;
use Buckaroo\PaymentMethods\GooglePay\GooglePay;
use Buckaroo\PaymentMethods\GiftCard\GiftCard;
use Buckaroo\PaymentMethods\KlarnaKP\KlarnaKP;
use Buckaroo\PaymentMethods\KnakenPay\KnakenPay;
Expand Down Expand Up @@ -78,6 +79,7 @@ class PaymentMethodFactory
*/
private static array $payments = [
ApplePay::class => ['applepay'],
GooglePay::class => ['googlepay'],
Alipay::class => ['alipay'],
Afterpay::class => ['afterpay'],
AfterpayDigiAccept::class => ['afterpaydigiaccept'],
Expand Down
10 changes: 10 additions & 0 deletions src/PaymentMethods/Subscriptions/Models/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class Subscription extends ServiceParameter
*/
protected string $allowedServices;

/**
* @var string
*/
protected string $tokenPaymentMethod;

/**
* @var Debtor
*/
Expand Down Expand Up @@ -134,6 +139,11 @@ class Subscription extends ServiceParameter
*/
protected RatePlanCharge $addRatePlanCharge;

/**
* @var RatePlanCharge
*/
protected RatePlanCharge $updateRatePlanCharge;

/**
* @var string
*/
Expand Down
51 changes: 51 additions & 0 deletions tests/Buckaroo/Payments/GooglepayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Tests\Buckaroo\Payments;

use Tests\Buckaroo\BuckarooTestCase;

class GooglepayTest extends BuckarooTestCase
{
/**
* @test
*/
public function it_creates_a_googlepay_payment()
{
$response = $this->buckaroo->payment('googlepay')->pay($this->getBasePayPayload([], [
'paymentData' => 'XXXXXXXXXXXXX',
'customerCardName' => 'XXXXXXXXXXXXX'
]));

$this->assertTrue($response->isPendingProcessing());
}

/**
* @test
*/
public function it_creates_a_googlepay_refund()
{
$response = $this->buckaroo->method('googlepay')->refund($this->getRefundPayload([
'originalTransactionKey' => '77FDD0E0CF9C4AF1B85CEA2942DE27DC',
]));

$this->assertTrue($response->isFailed());
}
}