Skip to content

Commit

Permalink
Added destination object inside refund payment request (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Jun 5, 2024
1 parent 16d432d commit 2946028
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lib/Checkout/Common/Destination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Checkout\Common;

class Destination
{
/**
* @var string values of AccountType
*/
public $account_type;

/**
* @var string
*/
public $account_number;

/**
* @var string
*/
public $bank_code;

/**
* @var string
*/
public $branch_code;

/**
* @var string
*/
public $iban;

/**
* @var string
*/
public $bban;

/**
* @var string
*/
public $swift_bic;

/**
* @var string values of Country
*/
public $country;

/**
* @var AccountHolder
*/
public $account_holder;

/**
* @var BankDetails
*/
public $bank;
}
17 changes: 17 additions & 0 deletions lib/Checkout/Payments/RefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Checkout\Payments;

use Checkout\Common\Destination;

class RefundRequest
{
/**
Expand All @@ -25,4 +27,19 @@ class RefundRequest
* @var array values of AmountAllocations
*/
public $amount_allocations;

/**
* @var string
*/
public $capture_action_id;

/**
* @var Destination
*/
public $destination;

/**
* @var array values of Order
*/
public $items;
}
76 changes: 76 additions & 0 deletions lib/Checkout/Payments/Request/Order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Checkout\Payments\Request;

class Order
{
/**
* @var string
*/
public $name;

/**
* @var int
*/
public $quantity;

/**
* @var int
*/
public $unit_price;

/**
* @var string
*/
public $reference;

/**
* @var string
*/
public $commodity_code;

/**
* @var string
*/
public $unit_of_measure;

/**
* @var int
*/
public $total_amount;

/**
* @var int
*/
public $tax_amount;

/**
* @var int
*/
public $discount_amount;

/**
* @var string
*/
public $wxpay_goods_id;

/**
* @var string
*/
public $image_url;

/**
* @var string
*/
public $url;

/**
* @var string
*/
public $type;

/**
* @var DateTime
*/
public $service_ends_on;
}
30 changes: 30 additions & 0 deletions test/Checkout/Tests/Payments/RefundPaymentsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
namespace Checkout\Tests\Payments;

use Checkout\CheckoutApiException;
use Checkout\Common\AccountType;
use Checkout\Common\BankDetails;
use Checkout\Common\Country;
use Checkout\Common\Destination;
use Checkout\Payments\RefundRequest;
use Checkout\Payments\Request\Order;

class RefundPaymentsIntegrationTest extends AbstractPaymentsIntegrationTest
{
Expand All @@ -16,9 +21,34 @@ public function shouldRefundCardPayment()
$paymentResponse = $this->makeCardPayment(true);

$amount = $paymentResponse["amount"];

$order = new Order();
$order->name = "OrderTest";
$order->total_amount = 99;
$order->quantity = 88;

$bank = new BankDetails();
$bank->name = "Lloyds TSB";
$bank->branch = "Bournemouth";
$bank->address = $this->getAddress();

$destination = new Destination();
$destination->account_type = AccountType::$savings;
$destination->account_number = "13654567455";
$destination->bank_code = "23-456";
$destination->branch_code = "6443";
$destination->iban = "HU93116000060000000012345676";
$destination->bban = "3704 0044 0532 0130 00";
$destination->swift_bic = "37040044";
$destination->country = Country::$GB;
$destination->account_holder = $this->getAccountHolder();
$destination->bank = $bank;

$refundRequest = new RefundRequest();
$refundRequest->reference = uniqid();
$refundRequest->amount = $amount;
$refundRequest->items = [$order];
$refundRequest->destination = $destination;

$response = $this->retriable(
function () use (&$paymentResponse, &$refundRequest) {
Expand Down

0 comments on commit 2946028

Please sign in to comment.