Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the RefundTransaction method for express checkout #13

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/OpenBuildings/PayPal/Payment/ExpressCheckout.php
Expand Up @@ -51,6 +51,32 @@ public function do_express_checkout_payment($token, $payer_id)
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale'
));
}

/**
* Make a RefundTransaction call.
*
* @param string $transaction_id the paypal transaction id
* @param string $type type of refund "Full" or "Partial"
* @param null $amount amount of refund (only for partial type)
* @param null $currency_code currency code of refund (only for partial type)
* @param null $note memo description
*/
public function refund_transaction($transaction_id, $type, $amount = null, $currency_code = null, $note = '')
{

$params = array(
'TRANSACTIONID' => $transaction_id,
'REFUNDTYPE' => $type
);

if (strtolower($type) == 'partial') {
$params['AMT'] = $amount;
$params['CURRENCYCODE'] = $currency_code ? $currency_code : $this->config('currency');
$params['NOTE'] = $note;
}

return $this->_request('RefundTransaction', $params);
}

protected function _set_params(array $params = array())
{
Expand Down