Permalink
Browse files

Improved the handling of iDEAL Basic payment status return.

  • Loading branch information...
1 parent 2d01d6a commit d09a2c683efec8846a57fb374a3839d2ef08999b @remcotolsma remcotolsma committed Feb 8, 2013
@@ -45,9 +45,18 @@ public function start( Pronamic_IDeal_IDealDataProxy $data ) {
$this->client->setPurchaseId( $data->getOrderId() );
$this->client->setDescription( $data->getDescription() );
$this->client->setItems( $data->getItems() );
- $this->client->setCancelUrl( add_query_arg( 'gateway', 'ideal_basic', $data->getCancelUrl() ) );
- $this->client->setSuccessUrl( add_query_arg( 'gateway', 'ideal_basic', $data->getSuccessUrl() ) );
- $this->client->setErrorUrl( add_query_arg( 'gateway', 'ideal_basic', $data->getErrorUrl() ) );
+
+ $url = add_query_arg(
+ array(
+ 'gateway' => 'ideal_basic',
+ 'transaction_id' => $this->get_transaction_id()
+ ),
+ site_url( '/' )
+ );
+
+ $this->client->setCancelUrl( add_query_arg( 'status', Pronamic_Gateways_IDealAdvancedV3_Status::CANCELLED, $url ) );
+ $this->client->setSuccessUrl( add_query_arg( 'status', Pronamic_Gateways_IDealAdvancedV3_Status::SUCCESS, $url ) );
+ $this->client->setErrorUrl( add_query_arg( 'status', Pronamic_Gateways_IDealAdvancedV3_Status::FAILURE, $url ) );
}
/////////////////////////////////////////////////
@@ -651,8 +651,8 @@ public function getHtmlFields() {
$serial_number++;
}
- $fields['urlCancel'] = $this->getCancelUrl();
- $fields['urlSuccess'] = $this->getSuccessUrl();
+ $fields['urlCancel'] = $this->getCancelUrl();
+ $fields['urlSuccess'] = $this->getSuccessUrl();
$fields['urlError'] = $this->getErrorUrl();
return Pronamic_IDeal_IDeal::htmlHiddenFields( $fields );
@@ -12,7 +12,7 @@ class Pronamic_Gateways_IDealBasic_ReturnHandler extends Pronamic_Gateways_Retur
public function listen() {
if ( isset( $_GET['gateway'] ) ) {
$gateway = filter_input( INPUT_GET, 'gateway', FILTER_SANITIZE_STRING );
-
+
if ( $gateway == 'ideal_basic' ) {
if ( isset( $_GET['transaction_id'] ) && isset( $_GET['status'] ) ) {
$transaction_id = filter_input( INPUT_GET, 'transaction_id', FILTER_SANITIZE_STRING );
@@ -34,7 +34,13 @@ public function listen() {
}
}
- public function returns( $data ) {
-
+ public function returns( $transaction_id, $status ) {
+ $payment = Pronamic_WordPress_IDeal_PaymentsRepository::getPaymentByIdAndEc( $transaction_id );
+
+ if ( $payment != null ) {
+ $can_redirect = true;
+
+ do_action( 'pronamic_ideal_basic_return', $payment, $status, $can_redirect );
+ }
}
}
@@ -85,13 +85,16 @@ public static function bootstrap( $file ) {
add_action( 'pronamic_ideal_advanced_return_raw', array( 'Pronamic_Gateways_IDealAdvanced_ReturnHandler', 'returns' ), 10, 2 );
add_action( 'pronamic_ideal_advanced_v3_return_raw', array( 'Pronamic_Gateways_IDealAdvancedV3_ReturnHandler', 'returns' ), 10, 2 );
+ add_action( 'pronamic_ideal_basic_return_raw', array( 'Pronamic_Gateways_IDealBasic_ReturnHandler', 'returns' ), 10, 2 );
add_action( 'pronamic_ideal_internetkassa_return_raw', array( 'Pronamic_Gateways_IDealInternetKassa_ReturnHandler', 'returns' ), 10, 2 );
add_action( 'pronamic_ideal_mollie_return_raw', array( 'Pronamic_Gateways_Mollie_ReturnHandler', 'returns' ) );
add_action( 'pronamic_ideal_omnikassa_return_raw', array( 'Pronamic_Gateways_OmniKassa_ReturnHandler', 'returns' ), 10, 2 );
add_action( 'pronamic_ideal_targetpay_return_raw', array( 'Pronamic_Gateways_TargetPay_ReturnHandler', 'returns' ), 10, 2 );
// Check the payment status on an iDEAL return
add_action( 'pronamic_ideal_advanced_return', array( __CLASS__, 'checkPaymentStatus' ), 10, 2 );
+ add_action( 'pronamic_ideal_advanced_v3_return', array( __CLASS__, 'checkPaymentStatus' ), 10, 2 );
+ add_action( 'pronamic_ideal_basic_return', array( __CLASS__, 'update_ideal_basic_payment_status' ), 10, 3 );
add_action( 'pronamic_ideal_internetkassa_return', array( __CLASS__, 'update_internetkassa_payment_status' ), 10, 2 );
add_action( 'pronamic_ideal_omnikassa_return', array( __CLASS__, 'update_omnikassa_payment_status' ), 10, 2 );
add_action( 'pronamic_ideal_mollie_return', array( __CLASS__, 'update_mollie_payment_status' ), 10, 2 );
@@ -176,6 +179,7 @@ public static function checkPaymentStatus( Pronamic_WordPress_IDeal_Payment $pay
public static function handle_returns() {
Pronamic_Gateways_IDealAdvanced_ReturnHandler::listen();
Pronamic_Gateways_IDealAdvancedV3_ReturnHandler::listen();
+ Pronamic_Gateways_IDealBasic_ReturnHandler::listen();
Pronamic_Gateways_IDealInternetKassa_ReturnHandler::listen();
Pronamic_Gateways_Mollie_ReturnHandler::listen();
Pronamic_Gateways_OmniKassa_ReturnHandler::listen();
@@ -326,6 +330,20 @@ public static function update_targetpay_payment_status( $payment, $can_redirect
do_action( 'pronamic_ideal_status_update', $payment, $can_redirect );
}
+ /**
+ * Update TargetPay payment status
+ *
+ * @param array $result
+ * @param boolean $canRedirect
+ */
+ public static function update_ideal_basic_payment_status( $payment, $status, $can_redirect = false ) {
+ $payment->status = $status;
+
+ $updated = Pronamic_WordPress_IDeal_PaymentsRepository::updateStatus( $payment );
+
+ do_action( 'pronamic_ideal_status_update', $payment, $can_redirect );
+ }
+
//////////////////////////////////////////////////
/**

0 comments on commit d09a2c6

Please sign in to comment.