Skip to content

Commit

Permalink
Merge pull request #100 from piotrpyznarski/make-refund-for-marketplace
Browse files Browse the repository at this point in the history
make OpenPayU_Refund compatible with marketplace
  • Loading branch information
regdos authored Jan 30, 2019
2 parents 069d25b + 1058cda commit 4fe658d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ Remember: All keys in "order array" must be in lowercase.
$refund = OpenPayU_Refund::create(
'Z963D5JQR2230925GUEST000P01', //as a value use ORDER_ID
'Money refund', //Description - required
'100' //Amount - If not provided, returns whole transaction, optional
'100', //Amount - If not provided, returns whole transaction, optional
'ext-customer-id', // External submerchant ID, required only for marketplace
'ext-refund-id' // External refund ID, required only for marketplace
);
```

Expand Down
16 changes: 13 additions & 3 deletions lib/OpenPayU/v2/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class OpenPayU_Refund extends OpenPayU
* Function make refund for order
* @param $orderId
* @param $description
* @param int $amount Amount of refund in pennies
* @param null|int $amount Amount of refund in pennies
* @param null|string $extCustomerId Marketplace external customer ID
* @param null|string $extRefundId Marketplace external refund ID
* @return null|OpenPayU_Result
* @throws OpenPayU_Exception
*/
public static function create($orderId, $description, $amount = null)
public static function create($orderId, $description, $amount = null, $extCustomerId = null, $extRefundId = null)
{
if (empty($orderId)) {
throw new OpenPayU_Exception('Invalid orderId value for refund');
Expand All @@ -34,7 +36,15 @@ public static function create($orderId, $description, $amount = null)
);

if (!empty($amount)) {
$refund['refund']['amount'] = (int)$amount;
$refund['refund']['amount'] = (int) $amount;
}

if (!empty($extCustomerId)) {
$refund['refund']['extCustomerId'] = $extCustomerId;
}

if (!empty($extRefundId)) {
$refund['refund']['extRefundId'] = $extRefundId;
}

try {
Expand Down

0 comments on commit 4fe658d

Please sign in to comment.