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

Add support for pay & tokenize #148

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Controllers/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,45 @@
namespace Paytrail\WooCommercePaymentGateway\Controllers;

use Paytrail\WooCommercePaymentGateway\Gateway;
use Paytrail\SDK\Response\GetTokenResponse;

class Callback extends AbstractController {

protected function index() {
new Gateway(['callbackMode' => true]);
}

protected function payAddCard() {

$gateway = new Gateway();

$gateway->log('Recieved Callback for pay and add card method', 'debug');

$reference = filter_input(INPUT_GET, 'checkout-reference');

$token = filter_input(INPUT_GET, 'checkout-card-token');

//Extract Order ID from POST data
$order = wc_get_order($reference);

$allDetails = filter_input_array(INPUT_GET);

if (isset($order)) {

$user_id = $order->get_customer_id();

$billing_email = $order->get_billing_email();

$gateway->log('Start save token process for token :' . print_r($token, true), 'debug');

$gateway->save_pay_and_add_card_method_token($allDetails, $user_id);

//Log the order details
$gateway->log('Token Saved successfully', 'debug');

} else {
// Handle the case where the order ID is not present in the POST data
$gateway->log('Order ID not present in the POST data', 'debug');
}
}
}
Loading