/**
  * Build the NVP data array for submitting the current checkout to PayPal as an Authorization request
  *
  * @param SI_Checkouts $checkout
  * @return array
  */
 private function nvp_data(SI_Checkouts $checkout, SI_Invoice $invoice)
 {
     $client = $invoice->get_client();
     $user = si_who_is_paying($invoice);
     // User email or none
     $user_email = $user ? $user->user_email : '';
     $nvpData['USER'] = self::$api_username;
     $nvpData['PWD'] = self::$api_password;
     $nvpData['SIGNATURE'] = self::$api_signature;
     $nvpData['VERSION'] = '56.0';
     $nvpData['METHOD'] = 'DoDirectPayment';
     $nvpData['PAYMENTACTION'] = 'Authorization';
     $nvpData['IPADDRESS'] = $_SERVER['REMOTE_ADDR'];
     $nvpData['CREDITCARDTYPE'] = self::get_card_type($this->cc_cache['cc_number']);
     $nvpData['ACCT'] = $this->cc_cache['cc_number'];
     $nvpData['EXPDATE'] = self::expiration_date($this->cc_cache['cc_expiration_month'], $this->cc_cache['cc_expiration_year']);
     $nvpData['CVV2'] = $this->cc_cache['cc_cvv'];
     $nvpData['FIRSTNAME'] = $checkout->cache['billing']['first_name'];
     $nvpData['LASTNAME'] = $checkout->cache['billing']['last_name'];
     $nvpData['EMAIL'] = $user->user_email;
     $nvpData['STREET'] = $checkout->cache['billing']['street'];
     $nvpData['CITY'] = $checkout->cache['billing']['city'];
     $nvpData['STATE'] = $checkout->cache['billing']['zone'];
     $nvpData['COUNTRYCODE'] = self::country_code($checkout->cache['billing']['country']);
     $nvpData['ZIP'] = $checkout->cache['billing']['postal_code'];
     $payment_amount = si_has_invoice_deposit($invoice->get_id()) ? $invoice->get_deposit() : $invoice->get_balance();
     $nvpData['AMT'] = si_get_number_format($payment_amount);
     $nvpData['CURRENCYCODE'] = $this->get_currency_code($invoice->get_id());
     $item_amount = si_has_invoice_deposit($invoice->get_id()) ? $invoice->get_deposit() : $invoice->get_balance() - ($invoice->get_tax_total() + $invoice->get_tax2_total());
     $nvpData['ITEMAMT'] = si_get_number_format($item_amount);
     //$nvpData['SHIPPINGAMT'] = si_get_number_format( $purchase->get_shipping_total( $this->get_payment_method() ) );
     $tax_amount = si_has_invoice_deposit($invoice->get_id()) ? 0 : $invoice->get_tax_total() + $invoice->get_tax2_total();
     $nvpData['TAXAMT'] = si_get_number_format($tax_amount);
     $nvpData['INVNUM'] = $invoice->get_id() . '#' . time();
     $nvpData['BUTTONSOURCE'] = self::PLUGIN_NAME;
     $nvpData += self::payment_request_line_items($invoice);
     // Recurring billing agreement
     if (si_is_invoice_recurring($invoice)) {
         $nvpData['L_BILLINGTYPE0'] = 'RecurringPayments';
         $nvpData['L_BILLINGAGREEMENTDESCRIPTION0'] = $this->recurring_desc($invoice);
     }
     $nvpData = apply_filters('si_paypal_wpp_nvp_data', $nvpData, $checkout, $i, $invoice);
     return $nvpData;
 }
Ejemplo n.º 2
0
 public static function sender_submission_fields(SI_Invoice $invoice)
 {
     $fields = array();
     $from_name = SI_Notifications_Control::from_name(array('invoice_id' => $invoice->get_id()));
     $from_email = SI_Notifications_Control::from_email(array('invoice_id' => $invoice->get_id()));
     $fields['send_as'] = array('weight' => 1, 'label' => self::__('Sender'), 'type' => 'text', 'placeholder' => '', 'attributes' => array('readonly' => 'readonly'), 'default' => $from_name . ' <' . $from_email . '>');
     // options for recipients
     $client = $invoice->get_client();
     $recipient_options = '<div class="form-group"><div class="input_wrap">';
     // client users
     if (is_a($client, 'SI_Client')) {
         $client_users = $client->get_associated_users();
         foreach ($client_users as $user_id) {
             if (!is_wp_error($user_id)) {
                 $recipient_options .= sprintf('<label class="clearfix"><input type="checkbox" name="sa_metabox_recipients[]" value="%1$s"> %2$s</label>', $user_id, esc_attr(SI_Notifications::get_user_email($user_id)));
             }
         }
     }
     $recipient_options .= sprintf('<label class="clearfix"><input type="checkbox" name="sa_metabox_custom_recipient_check" disabled="disabled"><input type="text" name="sa_metabox_custom_recipient" placeholder="%1$s"><span class="helptip" title="%2$s"></span></label>', self::__('*****@*****.**'), self::__('Entering an email will prevent some notification shortcodes from working since there is no client.'));
     // Send to me.
     $recipient_options .= sprintf('<label class="clearfix"><input type="checkbox" name="sa_metabox_recipients[]" value="%1$s"> %2$s</label>', get_current_user_id(), si__('Send me a copy'));
     $recipient_options .= '</div></div>';
     $fields['recipients'] = array('weight' => 5, 'label' => sprintf('%s <span class="helptip" title="%s"></span>', si__('Recipients'), si__('A notification will be sent if recipients are selected and this invoice is saved.')), 'type' => 'bypass', 'output' => $recipient_options);
     $fields['sender_note'] = array('weight' => 10, 'label' => self::__('Note'), 'type' => 'textarea', 'default' => $invoice->get_sender_note(), 'description' => si__('This note will be added to the Invoice Notification via the [admin_note] shortcode.'));
     $fields['doc_id'] = array('type' => 'hidden', 'value' => $invoice->get_id(), 'weight' => 10000);
     $fields['notification_nonce'] = array('type' => 'hidden', 'value' => wp_create_nonce(SI_Controller::NONCE), 'weight' => 10001);
     $fields = apply_filters('si_sender_submission_fields', $fields);
     uasort($fields, array(__CLASS__, 'sort_by_weight'));
     return $fields;
 }
 /**
  * Build the NVP data array for submitting the current checkout to PayPal as an Authorization request
  *
  * @param SI_Checkouts $checkout
  * @param SI_Invoice $invoice
  * @return array
  */
 private function process_nvp_data(SI_Checkouts $checkout, SI_Invoice $invoice)
 {
     $client = $invoice->get_client();
     $payments = $invoice->get_payments();
     $user = si_who_is_paying($invoice);
     // User email or none
     $user_email = $user ? $user->user_email : '';
     $nvpData = array();
     $nvpData['USER'] = self::$api_username;
     $nvpData['PWD'] = self::$api_password;
     $nvpData['SIGNATURE'] = self::$api_signature;
     $nvpData['VERSION'] = self::$version;
     $nvpData['TOKEN'] = self::get_token();
     $nvpData['PAYERID'] = self::get_payerid();
     $nvpData['METHOD'] = 'DoExpressCheckoutPayment';
     $nvpData['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Authorization';
     $nvpData['IPADDRESS'] = $_SERVER['REMOTE_ADDR'];
     $payment_amount = si_has_invoice_deposit($invoice->get_id()) ? $invoice->get_deposit() : $invoice->get_balance();
     $nvpData['PAYMENTREQUEST_0_AMT'] = si_get_number_format($payment_amount);
     $nvpData['PAYMENTREQUEST_0_CURRENCYCODE'] = self::get_currency_code($invoice->get_id());
     $item_amount = si_has_invoice_deposit($invoice->get_id()) ? $invoice->get_deposit() : $invoice->get_balance() - ($invoice->get_tax_total() + $invoice->get_tax2_total());
     $nvpData['PAYMENTREQUEST_0_ITEMAMT'] = si_get_number_format($item_amount);
     $nvpData['PAYMENTREQUEST_0_INVNUM'] = $invoice->get_id() . '#' . count($payments);
     // $nvpData['PAYMENTREQUEST_0_SHIPPINGAMT'] = si_get_number_format( $invoice->get_shipping_total() ); // FUTURE
     $tax_amount = si_has_invoice_deposit($invoice->get_id()) ? 0 : $invoice->get_tax_total() + $invoice->get_tax2_total();
     $nvpData['PAYMENTREQUEST_0_TAXAMT'] = si_get_number_format($tax_amount);
     $nvpData['BUTTONSOURCE'] = self::PLUGIN_NAME;
     $nvpData += self::payment_request_line_items($invoice);
     $nvpData = apply_filters('si_paypal_ec_nvp_data', $nvpData, $checkout, $i, $invoice);
     return $nvpData;
 }