当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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));
     }
 }
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:73,代码来源:amazon-payments.php


注:本文中的WPSC_Purchase_Log::get_log_by_meta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。