protected function build_checkout_request($action, $options = array())
 {
     $request = array();
     if (isset($this->options['return_url'])) {
         $request['RETURNURL'] = $this->options['return_url'];
     }
     if (isset($this->options['cancel_url'])) {
         $request['CANCELURL'] = $this->options['cancel_url'];
     }
     $request += phpme_map($this->options, array('MAXAMT' => 'max_amount', 'ALLOWNOTE' => 'allow_note', 'ADDROVERRIDE' => 'address_override', 'TOKEN' => 'token', 'PAYERID' => 'payer_id'));
     if (!empty($this->options['shipping']) && !empty($this->options['address_override'])) {
         $request += $this->add_address();
     }
     $request += $this->add_payment($action);
     return $request;
 }
 public function __construct($response_str)
 {
     parent::__construct($response_str);
     $p =& $this->params;
     // more readable checkout status
     if (isset($p['CHECKOUTSTATUS'])) {
         switch ($p['CHECKOUTSTATUS']) {
             case 'PaymentActionNotInitiated':
                 $this->options['checkout_status'] = 'Not-Initiated';
                 break;
             case 'PaymentActionFailed':
                 $this->options['checkout_status'] = 'Failed';
                 break;
             case 'PaymentActionInProgress':
                 $this->options['checkout_status'] = 'In-Progress';
                 break;
             case 'PaymentCompleted':
                 $this->options['checkout_status'] = 'Completed';
                 break;
             default:
                 $this->options['checkout_status'] = $p['CHECKOUTSTATUS'];
                 break;
         }
     }
     if (isset($p['PAYMENTINFO_0_PAYMENTSTATUS'])) {
         $this->options['payment_status'] = $p['PAYMENTINFO_0_PAYMENTSTATUS'];
     }
     if (isset($p['PAYMENTINFO_0_TRANSACTIONID'])) {
         $this->options['transaction_id'] = $p['PAYMENTINFO_0_TRANSACTIONID'];
     }
     $this->options += phpme_map($p, array('currency' => 'PAYMENTREQUEST_0_CURRENCYCODE', 'total' => 'PAYMENTREQUEST_0_AMT', 'amount' => 'PAYMENTREQUEST_0_AMT', 'subtotal' => 'PAYMENTREQUEST_0_ITEMAMT', 'shipping' => 'PAYMENTREQUEST_0_SHIPPINGAMT', 'handling' => 'PAYMENTREQUEST_0_HANDLINGAMT', 'tax' => 'PAYMENTREQUEST_0_TAXAMT', 'description' => 'PAYMENTREQUEST_0_DESC', 'invoice' => 'PAYMENTREQUEST_0_INVNUM', 'notify_url' => 'PAYMENTREQUEST_0_NOTIFYURL', 'shipping_discount' => 'PAYMENTREQUEST_0_SHIPDISCAMT'));
     $items = array();
     $i = 0;
     while (isset($p["L_PAYMENTREQUEST_0_NAME{$i}"])) {
         $items[] = phpme_map($p, array('name' => "L_PAYMENTREQUEST_0_NAME{$i}", 'description' => "L_PAYMENTREQUEST_0_DESC{$i}", 'amount' => "L_PAYMENTREQUEST_0_AMT{$i}", 'quantity' => "L_PAYMENTREQUEST_0_QTY{$i}", 'tax' => "L_PAYMENTREQUEST_0_TAXAMT{$i}"), 'Object');
         $i++;
     }
     $this->options['items'] = $items;
     if (isset($p['PAYERID'])) {
         $this->options['payer'] = phpme_map($p, array('email' => 'EMAIL', 'id' => 'PAYERID', 'status' => 'PAYERSTATUS', 'shipping_status' => 'ADDRESSSTATUS', 'first_name' => 'FIRSTNAME', 'last_name' => 'LASTNAME', 'country' => 'COUNTRYCODE'), 'Object');
     }
     if (isset($p['SHIPTONAME'])) {
         $this->options['shipping_address'] = phpme_map($p, array('name' => 'SHIPTONAME', 'street' => 'SHIPTOSTREET', 'street2' => 'SHIPTOSTREET2', 'city' => 'SHIPTOCITY', 'state' => 'SHIPTOSTATE', 'zip' => 'SHIPTOZIP', 'country_code' => 'SHIPTOCOUNTRYCODE', 'country' => 'SHIPTOCOUNTRYNAME', 'phone' => 'SHIPTOPHONENUM'));
     }
 }
 public function __construct($response_str)
 {
     parent::__construct($response_str);
     $p =& $this->params;
     if (isset($p['PAYMENTSTATUS'])) {
         $this->options['payment_status'] = $p['PAYMENTSTATUS'];
     }
     if (isset($p['TRANSACTIONID'])) {
         $this->options['transaction_id'] = $p['TRANSACTIONID'];
     }
     $this->options += phpme_map($p, array('currency' => 'CURRENCYCODE', 'total' => 'AMT', 'amount' => 'AMT', 'subtotal' => 'ITEMAMT', 'shipping' => 'SHIPPINGAMT', 'handling' => 'HANDLINGAMT', 'tax' => 'TAXAMT', 'description' => 'DESC', 'invoice' => 'INVNUM', 'notify_url' => 'NOTIFYURL', 'shipping_discount' => 'SHIPDISCAMT'));
     if (isset($p['PAYERID'])) {
         $this->options['payer'] = phpme_map($p, array('email' => 'EMAIL', 'id' => 'PAYERID', 'status' => 'PAYERSTATUS', 'shipping_status' => 'ADDRESSSTATUS', 'first_name' => 'FIRSTNAME', 'last_name' => 'LASTNAME', 'country' => 'COUNTRYCODE'), 'Object');
     }
     if (isset($p['SHIPTONAME'])) {
         $this->options['shipping_address'] = phpme_map($p, array('name' => 'SHIPTONAME', 'street' => 'SHIPTOSTREET', 'street2' => 'SHIPTOSTREET2', 'city' => 'SHIPTOCITY', 'state' => 'SHIPTOSTATE', 'zip' => 'SHIPTOZIP', 'country_code' => 'SHIPTOCOUNTRYCODE', 'country' => 'SHIPTOCOUNTRYNAME', 'phone' => 'SHIPTOPHONENUM'));
     }
 }
 public function is_verified()
 {
     if (is_null($this->verified)) {
         $verifying_data = array('cmd' => '_notify-validate');
         $verifying_data += $this->params;
         $verifying_response = $this->http->post($this->url, $verifying_data);
         if ($verifying_response == 'VERIFIED') {
             $this->verified = true;
             /*
             There's some confusing stuff regarding payment information:
             				mc_gross = total amount = total tax + item subtotal + total shipping
             				mc_gross_$i = item amount * quantity + item shipping
             See: https://www.x.com/developers/paypal/forums/ipn/pdt/mcgross-does-not-include-tax-right
             IPN only returns the item gross amount, so the single item amount will need to be
             				calculated so that the $this->data array is consistent with other Paypal Response classes.
             */
             $this->data = phpme_map($this->params, array('transaction_id' => 'txn_id', 'transaction_type' => 'txn_type', 'handling' => 'mc_handling', 'shipping' => 'mc_shipping', 'exchange_rate' => 'exchange_rate', 'invoice' => 'invoice', 'currency' => 'mc_currency', 'fee' => 'mc_fee', 'total' => 'mc_gross', 'amount' => 'mc_gross', 'payment_status' => 'payment_status', 'tax' => 'tax'));
             // Strangely, Canceled_Reversal in IPN response is actually Canceled-Reversal in normal Paypal Express responses.
             // Need to change the underscore to hyphen to maintain consistency
             $this->data['payment_status'] = str_replace('_', '-', $this->data['payment_status']);
             $i = 1;
             $this->data['items'] = array();
             while (isset($this->params["item_name{$i}"])) {
                 $item = phpme_map($this->params, array('name' => "item_name{$i}", 'quantity' => "quantity{$i}"));
                 $item['shipping'] = $shipping = isset($this->params["mc_shipping{$i}"]) ? $this->params["mc_shipping{$i}"] : 0;
                 $item['handling'] = $handling = isset($this->params["mc_handling{$i}"]) ? $this->params["mc_handling{$i}"] : 0;
                 $item['amount'] = ($this->params["mc_gross_{$i}"] - $shipping - $handling) / $item['quantity'];
                 $this->data['items'][] = $item;
                 $i++;
             }
             $this->data['payer'] = phpme_map($this->params, array('first_name' => 'first_name', 'last_name' => 'last_name', 'business_name' => 'payer_business_name', 'status' => 'payer_status', 'id' => 'payer_id', 'email' => 'payer_email'));
             $this->data['address'] = phpme_map($this->params, array('street' => 'address_street', 'zip' => 'address_zip', 'city' => 'address_city', 'state' => 'address_state', 'country' => 'address_country', 'country_code' => 'address_country_code', 'name' => 'address_name', 'status' => 'address_status', 'phone' => 'contact_phone'));
         }
     }
     return $this->verified;
 }
 /**
  * Build the request array
  *
  * @param string $action
  * @param array $options
  * @return array
  * @since 3.9
  */
 protected function build_checkout_request($action, $options = array())
 {
     $request = array();
     if (isset($this->options['return_url'])) {
         $request['RETURNURL'] = $this->options['return_url'];
     }
     if (isset($this->options['cancel_url'])) {
         $request['CANCELURL'] = $this->options['cancel_url'];
     }
     // Common Fields
     $request += phpme_map($this->options, array('AMT' => 'amount', 'MAXAMT' => 'max_amount', 'SOLUTIONTYPE' => 'solution_type', 'ALLOWNOTE' => 'allow_note', 'ADDROVERRIDE' => 'address_override', 'TOKEN' => 'token', 'PAYERID' => 'payer_id', 'TRANSACTIONID' => 'transaction_id', 'AUTHORIZATIONID' => 'authorization_id', 'MSGSUBID' => 'message_id', 'INVOICEID' => 'invoice'));
     // Cart Customization Fields
     $request += phpme_map($this->options, array('LOGOIMG' => 'cart_logo', 'CARTBORDERCOLOR' => 'cart_border'));
     // RefundTransaction Fields
     $request += phpme_map($this->options, array('REFUNDTYPE' => 'refund_type', 'REFUNDSOURCE' => 'refund_source', 'REFUNDADVICE' => 'refund_advice'));
     // DoCapture Fields
     $request += phpme_map($this->options, array('COMPLETETYPE' => 'complete_type'));
     if (!empty($this->options['shipping_address'])) {
         $request += $this->add_address();
     }
     if (isset($this->options['no_shipping'])) {
         $request['NOSHIPPING'] = '1';
     }
     if ($action != false) {
         $request += $this->add_payment($action);
     }
     // BN Code
     $request['BUTTONSOURCE'] = 'WPECOM_ECM';
     return $request;
 }
 /**
  * Build the request array
  *
  * @param string $action
  * @param array $options
  * @return array
  * @since 3.9
  */
 function build_checkout_request($action, $options = array())
 {
     $request = array();
     // Common Fields
     $request += phpme_map($this->options, array('AMT' => 'amount', 'MAXAMT' => 'max_amount', 'SOLUTIONTYPE' => 'solution_type', 'ALLOWNOTE' => 'allow_note', 'ADDROVERRIDE' => 'address_override', 'TOKEN' => 'token', 'PAYERID' => 'payer_id', 'TRANSACTIONID' => 'transaction_id', 'AUTHORIZATIONID' => 'authorization_id', 'MSGSUBID' => 'message_id', 'INVOICEID' => 'invoice'));
     // RefundTransaction Fields
     $request += phpme_map($this->options, array('REFUNDTYPE' => 'refund_type', 'REFUNDSOURCE' => 'refund_source', 'REFUNDADVICE' => 'refund_advice'));
     // BN Code
     $request['BUTTONSOURCE'] = 'WPeC_Cart_HSS';
     return $request;
 }