コード例 #1
0
 /**
  * Set a purchase action since it's a bit convoluted.
  * @param  integer $invoice_id
  * @return string
  */
 public static function show_payment_options($invoice_id = 0, $payment_string = '')
 {
     if (!$invoice_id) {
         $invoice_id = get_the_id();
     }
     if ('' === $payment_string) {
         $payment_string = si_has_invoice_deposit($invoice_id) ? __('Pay Deposit', 'sprout-invoices') : __('Pay Invoice', 'sprout-invoices');
     }
     self::load_view('templates/invoice/payment-options', array('id' => $invoice_id, 'payment_options' => si_payment_options(), 'payment_string' => $payment_string), false);
 }
コード例 #2
0
}
?>

		</ol>

		<footer id="line_items_footer" class="si_clearfix">
			
			<section id="doc_payment_wrap" class="si_clearfix">

				<?php 
if (si_get_invoice_balance() && si_get_invoice_status() != 'write-off') {
    ?>
					
					<?php 
    $payment_options = si_payment_options();
    $payment_string = si_has_invoice_deposit() ? __('Pay Deposit', 'sprout-invoices') : __('Pay Invoice', 'sprout-invoices');
    ?>
					<?php 
    if (count($payment_options) === 0) {
        ?>
						<!-- no payment options -->
					<?php 
    } elseif (count($payment_options) === 1) {
        ?>
						<?php 
        foreach ($payment_options as $slug => $options) {
            ?>
							<?php 
            if (isset($options['purchase_button_callback'])) {
                ?>
								<?php 
コード例 #3
0
ファイル: invoice.php プロジェクト: aldoyh/library
</span></dt>
									<dd><?php 
    si_invoice_due_date();
    ?>
</dd>
								</dl>
							<?php 
}
?>

							<?php 
do_action('si_document_details_totals');
?>

							<?php 
if (si_has_invoice_deposit()) {
    ?>
								<dl class="doc_total_with_deposit">
									<dt><span class="dt_heading"><?php 
    _e('Invoice Total', 'sprout-invoices');
    ?>
</span></dt>
									<dd><?php 
    sa_formatted_money(si_get_invoice_total());
    ?>
</dd>
								</dl>

								<dl class="doc_total">
									<dt><span class="dt_heading"><?php 
    _e('Deposit Total', 'sprout-invoices');
コード例 #4
0
 function test_si_has_invoice_deposit()
 {
     $this->invoice->set_deposit(500);
     // minimum total 1000
     $this->assertTrue(si_has_invoice_deposit($this->invoice_id));
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 /**
  * Create the recurring payment profile.
  */
 private function add_customer_to_plan(SI_Checkouts $checkout, SI_Invoice $invoice)
 {
     $invoice_id = $invoice->get_id();
     self::setup_stripe();
     try {
         $user = si_who_is_paying($invoice);
         $purchase_data = $this->purchase_data($checkout, $invoice);
         if (!$purchase_data) {
             return false;
         }
         $price = SI_Subscription_Payments::get_renew_price($invoice_id);
         $amount_in_cents = self::convert_money_to_cents(sprintf('%0.2f', $price));
         $balance = si_has_invoice_deposit($invoice_id) ? $invoice->get_deposit() : $invoice->get_balance();
         $subscribe = Stripe_Customer::create(array('card' => $purchase_data, 'plan' => $invoice_id . $amount_in_cents, 'email' => $user->user_email, 'account_balance' => self::convert_money_to_cents(sprintf('%0.2f', $balance - $price))));
         $subscribe = array('id' => $subscribe->id, 'subscription_id' => $subscribe->subscriptions->data[0]->id, 'amount' => $amount_in_cents, 'plan' => $invoice_id . $amount_in_cents, 'card' => $purchase_data, 'email' => $user->user_email);
         // Payment
         $payment_id = SI_Payment::new_payment(array('payment_method' => self::PAYMENT_METHOD, 'invoice' => $invoice_id, 'amount' => $price, 'data' => array('live' => self::MODE_LIVE === self::$api_mode, 'api_response' => $subscribe)), SI_Payment::STATUS_RECURRING);
         do_action('si_stripe_recurring_payment_profile_created', $payment_id);
         // Passed back to create the initial payment
         $response = $subscribe;
         $response['amount'] = $amount_in_cents;
         $response['plan'] = $invoice_id . $amount_in_cents;
         return $response;
     } catch (Exception $e) {
         self::set_error_messages($e->getMessage());
         return false;
     }
 }