我正在使用PayPal API制作支付处理系统,问题是,当我将用户重定向到PayPal时,我会存储一个' paypal_hash'在会话内部,在将信息输入PayPal系统之后,然后将用户重定向到网页,并且' paypal_hash'不再存在。
process_payment.php:
for row in list:
print row[4]
if row[4] > 10:
print("is greater than")
执行此代码后,用户将被重定向到pay.php:
session_start();
$payment->create($api);
//Generate hash
$hash = md5($payment->getId()); // Will encrypt better at a later point
$_SESSION['paypal_hash'] = $hash;
//Prepare and execute transacting storage
$store = $db->prepare("
INSERT INTO transactions_paypal (user_id, payment_id, hash, complete) VALUES (:user_id, :payment_id, :hash, 0)
");
$store->execute([
'user_id' => $_SESSION['user_id'],
'payment_id' => $payment->getId(),
'hash' => $hash
]);
header('Location: ' . $paypal_url); // the url where the user pays via a paypal.com site
Hash正确存储在数据库中,但在从PayPal重定向后不会保留在会话中。