我正在尝试为SetExpressCheckout实现PayPal API函数。下面我将我用于调用PayPal端支付流程的部分代码。一切都很好看。在结账的最后一步,我按下“立即付款”按钮,处理付款。在该用户返回我的原始站点之后,我获得了交易ID,成功消息和令牌。看起来evrything很好,但在我的PayPal账户中,我没有看到任何交易,我根本没有得到任何钱。
$returnUrl = home_url("/wp-login.php?checkemail=registered&ppayment=done&price=".$package_price."&code=".$paypal_price_unit."&package=".$package_name."&pid=".$incomingpost);
$requestParams = array(
'RETURNURL' => $returnUrl,
'CANCELURL' => home_url('/wp-login.php?checkemail=registered&ppayment=cancel')
);
// Sent item info
$orderParams = array(
'PAYMENTREQUEST_0_AMT' => $package_price,
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0',
'PAYMENTREQUEST_0_CURRENCYCODE' => $paypal_price_unit,
'PAYMENTREQUEST_0_ITEMAMT' => $package_price
);
//send package info
$item = array(
'L_PAYMENTREQUEST_0_NAME0' => $paymentName,
'L_PAYMENTREQUEST_0_DESC0' => $package_name,
'L_PAYMENTREQUEST_0_AMT0' => $package_price,
'L_PAYMENTREQUEST_0_QTY0' => '1'
);
//Call payment process
$infos = array();
$infos['USER'] = $paypal_api_user;
$infos['PWD'] = $paypal_api_pwd;
$infos['SIGNATURE'] = $paypal_api_signature;
if($paypal_sandbox == 1){$sandstatus = true;}else{$sandstatus = false;}
$paypal = new Paypal($infos,$sandstatus);
$response = $paypal -> request('SetExpressCheckout',$requestParams + $orderParams + $item);
if(is_array($response) && $response['ACK'] == 'Success') {
// We will redirecting now.
$token = $response['TOKEN'];
//Save DB before redirect.
$trans_post = array(
'post_status' => 'pending',
'post_type' => 'retransactions',
'post_title' => $token,
);
$new_post_id = wp_insert_post( $trans_post );
add_post_meta($new_post_id, 'webburemap_payment_user', $user_id);
add_post_meta($new_post_id, 'webburemap_payment_amount', $package_price);
add_post_meta($new_post_id, 'webburemap_payment_package_id', $package_IDNO);
add_post_meta($new_post_id, 'webburemap_payment_package_transtype', 'NewPackage');
if($paypal_sandbox == 0){
$commit = '&useraction=commit';
header( 'Location: https://www.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token) . $commit ); //PayPal Pay Now
}else{
header( 'Location: https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token) );
}
die();
}
答案 0 :(得分:0)
您能否提供快速结账令牌和您要回复的交易ID,我将在我身边看一下,看看会发生什么。还要确保指向正确的端点。如果您要处理实时付款,请确保您指向的是实时网站,而不是沙箱。