本文整理汇总了PHP中PayPal::request方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::request方法的具体用法?PHP PayPal::request怎么用?PHP PayPal::request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal
的用法示例。
在下文中一共展示了PayPal::request方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
if (isset($_GET['action']) && $_GET['action'] == 'continue' && !empty($_GET['msorder']) && !empty($_GET['mscode'])) {
if ($order = $modx->getObject('msOrder', $_GET['msorder'])) {
if ($_GET['mscode'] == $handler->getOrderHash($order)) {
$response = $handler->send($order);
if ($response['success'] && !empty($response['data']['redirect'])) {
$modx->sendRedirect($response['data']['redirect']);
} else {
exit($response['message']);
}
}
}
exit('Error when continuing order');
} elseif (empty($_GET['token'])) {
exit('Access denied');
}
$response = $handler->request(array('METHOD' => 'GetExpressCheckoutDetails', 'TOKEN' => $_GET['token']));
$context = '';
$params = array();
if (!is_array($response)) {
$modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Error on receive details of PayPal operation: ' . $response . '; ' . print_r($_GET, 1));
} else {
if (!empty($response['PAYMENTREQUEST_0_INVNUM'])) {
if ($order = $modx->getObject('msOrder', $response['PAYMENTREQUEST_0_INVNUM'])) {
$handler->receive($order, $response);
$context = $order->get('context');
$params['msorder'] = $order->get('id');
} else {
$modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Could not retrieve order with id ' . $response['PAYMENTREQUEST_0_INVNUM']);
}
} else {
$modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Error on receive details of PayPal operation: ' . print_r($response, 1) . '; ' . print_r($_GET, 1));
示例2: jxCompletePayment
public function jxCompletePayment()
{
$this->validate(__FUNCTION__);
$json = array();
if (!isset($this->request->post['selected'])) {
$json['error'] = $this->language->get('ms_error_withdraw_norequests');
$this->response->setOutput(json_encode($json));
return;
}
require_once DIR_SYSTEM . 'library/ms-paypal.php';
$requestParams = array('RECEIVERTYPE' => 'EmailAddress', 'CURRENCYCODE' => $this->config->get('config_currency'));
$paymentParams = array();
$i = 0;
foreach ($this->request->post['selected'] as $payment_id) {
$result = $this->MsLoader->MsPayment->getPayments(array('payment_id' => $payment_id, 'payment_status' => array(MsPayment::STATUS_UNPAID), 'payment_type' => array(MsPayment::TYPE_PAYOUT, MsPayment::TYPE_PAYOUT_REQUEST), 'single' => 1));
if (!empty($result)) {
$paymentParams['L_EMAIL' . $i] = $result['ms.paypal'];
$paymentParams['L_AMT' . $i] = abs($result['mw.amount']);
$i++;
}
}
if (empty($paymentParams)) {
$json['error'] = $this->language->get('ms_error_withdraw_norequests');
$this->response->setOutput(json_encode($json));
return;
}
$paypal = new PayPal($this->config->get('msconf_paypal_api_username'), $this->config->get('msconf_paypal_api_password'), $this->config->get('msconf_paypal_api_signature'), $this->config->get('msconf_paypal_sandbox'));
$response = $paypal->request('MassPay', $requestParams + $paymentParams);
if (!$response) {
$json['error'] = $this->language->get('ms_error_withdraw_response');
$json['response'] = print_r($paypal->getErrors(), true);
} else {
if ($response['ACK'] != 'Success') {
$json['error'] = $this->language->get('ms_error_withdraw_status');
$json['response'] = print_r($response, true);
} else {
$json['success'] = $this->language->get('ms_success_transactions');
$json['response'] = print_r($response, true);
//$mails = array();
foreach ($this->request->post['selected'] as $payment_id) {
$result = array_shift($this->MsLoader->MsPayment->getPayments(array('payment_id' => $payment_id, 'payment_status' => array(MsPayment::STATUS_UNPAID), 'payment_type' => array(MsPayment::TYPE_PAYOUT, MsPayment::TYPE_PAYOUT_REQUEST), 'single' => 1)));
$this->MsLoader->MsPayment->updatePayment($payment_id, array('payment_status' => MsPayment::STATUS_PAID, 'description' => 'Paid', 'date_paid' => 1));
$this->MsLoader->MsBalance->addBalanceEntry($result['seller_id'], array('payment_id' => $payment_id, 'balance_type' => MsBalance::MS_BALANCE_TYPE_WITHDRAWAL, 'amount' => -$result['amount'], 'description' => 'Payout'));
}
}
}
return $this->response->setOutput(json_encode($json));
}