本文整理汇总了PHP中WPSC_Purchase_Log::get_log_by_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSC_Purchase_Log::get_log_by_meta方法的具体用法?PHP WPSC_Purchase_Log::get_log_by_meta怎么用?PHP WPSC_Purchase_Log::get_log_by_meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSC_Purchase_Log
的用法示例。
在下文中一共展示了WPSC_Purchase_Log::get_log_by_meta方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_ipn
/**
* Process IPN messages from Amazon
*
* @access public
* @since 4.0
* @return void
*/
public function process_ipn()
{
if (!isset($_GET['wpsc-listener']) || $_GET['wpsc-listener'] !== 'amazon') {
return;
}
if (isset($_GET['state'])) {
return;
}
// Get the IPN headers and Message body
$headers = getallheaders();
$body = file_get_contents('php://input');
$this->doing_ipn = true;
if (!class_exists('PayWithAmazon\\IpnHandler')) {
require_once WPSC_MERCHANT_V3_SDKS_PATH . '/amazon-payments/sdk/IpnHandler.php';
}
try {
$ipn = new PayWithAmazon\IpnHandler($headers, $body);
$data = $ipn->toArray();
$seller_id = $data['SellerId'];
if ($seller_id != $this->gateway->seller_id) {
wp_die(__('Invalid Amazon seller ID', 'wpsc'), __('IPN Error', 'wpsc'), array('response' => 401));
}
switch ($data['NotificationType']) {
case 'OrderReferenceNotification':
break;
case 'PaymentAuthorize':
break;
case 'PaymentCapture':
$status = $data['CaptureDetails']['CaptureStatus']['State'];
if ('Declined' === $status) {
$value = $data['CaptureDetails']['CaptureReferenceId'];
$reason = $data['CaptureDetails']['CaptureStatus']['ReasonCode'];
// Get Order ID by reference
$order = WPSC_Purchase_Log::get_log_by_meta('amazon_capture_id', $value);
if (!$order) {
break;
}
// Update status to declined
$order->set('processed', WPSC_Purchase_Log::PAYMENT_DECLINED)->save();
// Update Amazon note
$order->set('amazon-status', __('Could not authorize Amazon payment.', 'wpsc'))->save();
// Email user
$hard = 'InvalidPaymentMethod' == $reason;
$this->send_decline_email($hard, $order);
}
break;
case 'PaymentRefund':
$refund_id = $data['RefundDetails']['AmazonRefundId'];
$status = $data['RefundDetails']['RefundStatus']['State'];
$amount = $data['RefundDetails']['RefundAmount'];
if ('Completed' === $status) {
// get payment ID based on refund ID
$order = WPSC_Purchase_Log::get_log_by_meta('amazon_refund_id', $refund_id);
// Update status to refunded
$order->set('processed', WPSC_Purchase_Log::REFUNDED)->save();
// Add payment note for refund.
$order->set('amazon-status', sprintf(__('Refunded %s', 'wpsc'), wpsc_currency_display($amount)))->save();
// Update refund ID
wpsc_add_purchase_meta($order->get('id'), 'amazon_refund_id', $refund_id);
}
break;
}
} catch (Exception $e) {
wp_die($e->getErrorMessage(), __('IPN Error', 'wpsc'), array('response' => 401));
}
}