Skip to content

Commit

Permalink
The txn_id parameter can also be the refund transaction ID?
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jun 18, 2021
1 parent bacf720 commit cf7de68
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/NotificationsController.php
Expand Up @@ -63,6 +63,11 @@ public function rest_api_init() {
'description' => \__( 'The merchant\'s original transaction identification number for the payment from the buyer, against which the case was registered.', 'pronamic_ideal' ),
'type' => 'string',
),
'parent_txn_id' => array(
'description' => \__( 'In the case of a refund, reversal, or canceled reversal, this variable contains the `txn_id` of the original transaction.', 'pronamic_ideal' ),
'type' => 'string',

),
'mc_currency' => array(
'description' => \__( 'For payment IPN notifications, this is the currency of the payment.', 'pronamic_ideal' ),
'type' => 'string',
Expand Down Expand Up @@ -170,13 +175,12 @@ public function rest_api_paypal_ipn( WP_REST_Request $request ) {
/**
* Payment.
*/
$payment->set_transaction_id( $request->get_param( 'txn_id' ) );

switch ( $request->get_param( 'payment_status' ) ) {
case 'Canceled_Reversal':

break;
case 'Completed':
$payment->set_transaction_id( $request->get_param( 'txn_id' ) );
$payment->set_status( PaymentStatus::SUCCESS );

break;
Expand Down Expand Up @@ -206,6 +210,7 @@ public function rest_api_paypal_ipn( WP_REST_Request $request ) {

$refunded_amount = $gross->absolute();

$payment->set_transaction_id( $request->get_param( 'parent_txn_id' ) );
$payment->set_refunded_amount( $refunded_amount );

break;
Expand Down

0 comments on commit cf7de68

Please sign in to comment.