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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@ node_modules

# Vendor
vendor

# unit tests
tests
55 changes: 55 additions & 0 deletions tests/mock/PaymentInputDTOMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace PayPlug\tests\mock;

class PaymentInputDTOMock
{
public static function get()
{
$paymentInputDTO = new \stdClass();

$paymentInputDTO->api_bearer = 'token_bearer';
$paymentInputDTO->payment_method = 'payment method';
$paymentInputDTO->amount = 4242;
$paymentInputDTO->currency_iso_code = 'EUR';
$paymentInputDTO->customer = [
'identifier' => 42,
'billing' => [
'title' => 'mr',
'first_name' => 'John',
'last_name' => 'Watson',
'mobile_phone_number' => '+33612345678',
'email' => 'john.watson@example.net',
'address1' => '221B Baker Street',
'postcode' => 'NW16XE',
'city' => 'London',
'country' => 'GB',
'language' => 'en'
],
'shipping' => [
'title' => 'mr',
'first_name' => 'John',
'last_name' => 'Watson',
'mobile_phone_number' => '+33612345678',
'email' => 'john.watson@example.net',
'address1' => '221B Baker Street',
'postcode' => 'NW16XE',
'city' => 'London',
'country' => 'GB',
'language' => 'en'
]
];
$paymentInputDTO->urls = [
'return' => 'https://example.net/success?id=42',
'cancel' => 'https://example.net/cancel?id=42',
'notification' => 'https://example.net/notifications?id=42',
];
$paymentInputDTO->metadata = [
'cart ID' => '42',
'custom data' => 'lorem ipsum',
];
$paymentInputDTO->context = [];

return $paymentInputDTO;
}
}
99 changes: 99 additions & 0 deletions tests/mock/PaymentOutputDTOMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace PayPlug\tests\mock;

use Payplug\Resource\Payment;

class PaymentOutputDTOMock
{
/** @var boolean */
public $result;
/** @var string */
public $code;
/** @var string */
public $message;
/** @var object */
public $resource;

public static function get()
{
$paymentOutputDTO = new \stdClass();

$paymentOutputDTO->result = true;
$paymentOutputDTO->code = 200;
$paymentOutputDTO->message = '';

$payment_attributes = [
'id' => 'pay_id',
'object' => 'payment',
'is_live' => true,
'amount' => 4200,
'amount_refunded' => 0,
'currency' => 'EUR',
'created_at' => time(),
'description' => null,
'is_paid' => false,
'paid_at' => null,
'is_refunded' => false,
'is_3ds' => null,
'save_card' => false,
'card' => [
'last4' => null,
'country' => null,
'exp_year' => null,
'exp_month' => null,
'brand' => null,
'id' => null,
'metadata' => null,
],
'hosted_payment' => [
'return_url' => 'https://example.net/success?id=42',
'cancel_url' => 'https://example.net/cancel?id=42',
'paid_at' => null,
'sent_by' => null,
],
'notification' => [
'url' => 'https://example.net/notifications?id=42',
'response_code' => null,
],
'metadata' => [
'ID Client' => 1,
'ID Cart' => 1,
'Website' => 'website.com',
],
'failure' => null,
'installment_plan_id' => null,
'authorization' => null,
'refundable_after' => null,
'refundable_until' => null,
'billing' => [
'title' => 'mr',
'first_name' => 'John',
'last_name' => 'Watson',
'mobile_phone_number' => '+33612345678',
'email' => 'john.watson@example.net',
'address1' => '221B Baker Street',
'postcode' => 'NW16XE',
'city' => 'London',
'country' => 'GB',
'language' => 'en'
],
'shipping' => [
'title' => 'mr',
'first_name' => 'John',
'last_name' => 'Watson',
'mobile_phone_number' => '+33612345678',
'email' => 'john.watson@example.net',
'address1' => '221B Baker Street',
'postcode' => 'NW16XE',
'city' => 'London',
'country' => 'GB',
'language' => 'en',
'delivery_type' => 'BILLING',
],
];
$paymentOutputDTO->resource = Payment::fromAttributes($payment_attributes);

return $paymentOutputDTO;
}
}