Skip to content

Commit

Permalink
Adds Payment Action option
Browse files Browse the repository at this point in the history
resolves #210
  • Loading branch information
Andrew Angell committed Jun 6, 2015
1 parent 3a6c02d commit 8c40f87
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
16 changes: 14 additions & 2 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function __construct() {
$this->use_wp_locale_code = isset($this->settings['use_wp_locale_code']) ? $this->settings['use_wp_locale_code'] : '';
$this->angelleye_skip_text = isset($this->settings['angelleye_skip_text']) ? $this->settings['angelleye_skip_text'] : '';
$this->skip_final_review = isset($this->settings['skip_final_review']) ? $this->settings['skip_final_review'] : '';
$this->payment_action = isset($this->settings['payment_action']) ? $this->settings['payment_action'] : 'Sale';
$this->billing_address = isset($this->settings['billing_address']) ? $this->settings['billing_address'] : 'no';
$this->send_items = isset($this->settings['send_items']) && $this->settings['send_items'] == 'yes' ? true : false;
$this->customer_id = get_current_user_id();
Expand Down Expand Up @@ -544,6 +545,17 @@ function init_form_fields() {
'type' => 'checkbox',
'default' => 'no'
),
'payment_action' => array(
'title' => __('Payment Action', 'paypal-for-woocommerce'),
'label' => __('Whether to process as a Sale or Authorization.', 'paypal-for-woocommerce'),
'description' => __('Sale will capture the funds immediately when the order is placed. Authorization will authorize the payment but will not capture the funds. You would need to capture funds through your PayPal account when you are ready to deliver.'),
'type' => 'select',
'options' => array(
'Sale' => 'Sale',
'Authorization' => 'Authorization',
),
'default' => 'Sale'
),
'billing_address' => array(
'title' => __('Billing Address', 'paypal-for-woocommerce'),
'label' => __('Set billing address in WooCommerce using the address returned by PayPal.', 'paypal-for-woocommerce'),
Expand Down Expand Up @@ -1345,7 +1357,7 @@ function CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayP
'shiptophonenum' => '', // Phone number for shipping address. 20 char max.
'notetext' => '', // Note to the merchant. 255 char max.
'allowedpaymentmethod' => '', // The payment method type. Specify the value InstantPaymentOnly.
'paymentaction' => 'Sale', // How you want to obtain the payment. When implementing parallel payments, this field is required and must be set to Order.
'paymentaction' => $this->payment_action == 'Authorization' ? 'Authorization' : 'Sale', // How you want to obtain the payment. When implementing parallel payments, this field is required and must be set to Order.
'paymentrequestid' => '', // A unique identifier of the specific payment request, which is required for parallel payments.
'sellerpaypalaccountid' => '' // A unique identifier for the merchant. For parallel payments, this field is required and must contain the Payer ID or the email address of the merchant.
);
Expand Down Expand Up @@ -1776,7 +1788,7 @@ function ConfirmPayment($FinalPaymentAmt) {
'shiptophonenum' => '', // Phone number for shipping address. 20 char max.
'notetext' => $this->get_session('customer_notes'), // Note to the merchant. 255 char max.
'allowedpaymentmethod' => '', // The payment method type. Specify the value InstantPaymentOnly.
'paymentaction' => 'Sale', // How you want to obtain the payment. When implementing parallel payments, this field is required and must be set to Order.
'paymentaction' => $this->payment_action == 'Authorization' ? 'Authorization' : 'Sale', // How you want to obtain the payment. When implementing parallel payments, this field is required and must be set to Order.
'paymentrequestid' => '', // A unique identifier of the specific payment request, which is required for parallel payments.
'sellerpaypalaccountid' => '', // A unique identifier for the merchant. For parallel payments, this field is required and must contain the Payer ID or the email address of the merchant.
'sellerid' => '', // The unique non-changing identifer for the seller at the marketplace site. This ID is not displayed.
Expand Down
14 changes: 13 additions & 1 deletion classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function __construct() {
$this->enable_3dsecure = isset( $this->settings['enable_3dsecure'] ) && $this->settings['enable_3dsecure'] == 'yes' ? true : false;
$this->liability_shift = isset( $this->settings['liability_shift'] ) && $this->settings['liability_shift'] == 'yes' ? true : false;
$this->debug = isset( $this->settings['debug'] ) && $this->settings['debug'] == 'yes' ? true : false;
$this->payment_action = isset($this->settings['payment_action']) ? $this->settings['payment_action'] : 'Sale';
$this->send_items = isset( $this->settings['send_items'] ) && $this->settings['send_items'] == 'yes' ? true : false;
// 3DS
if ( $this->enable_3dsecure ) {
Expand Down Expand Up @@ -246,6 +247,17 @@ function init_form_fields() {
'description' => __( 'Detailed displays actual errors returned from PayPal. Generic displays general errors that do not reveal details
and helps to prevent fraudulant activity on your site.' , 'paypal-for-woocommerce')
),
'payment_action' => array(
'title' => __('Payment Action', 'paypal-for-woocommerce'),
'label' => __('Whether to process as a Sale or Authorization.', 'paypal-for-woocommerce'),
'description' => __('Sale will capture the funds immediately when the order is placed. Authorization will authorize the payment but will not capture the funds. You would need to capture funds through your PayPal account when you are ready to deliver.'),
'type' => 'select',
'options' => array(
'Sale' => 'Sale',
'Authorization' => 'Authorization',
),
'default' => 'Sale'
),
'send_items' => array(
'title' => __( 'Send Item Details', 'paypal-for-woocommerce' ),
'label' => __( 'Send line item details to PayPal', 'paypal-for-woocommerce' ),
Expand Down Expand Up @@ -718,7 +730,7 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp
* Generate PayPal request
*/
$DPFields = array(
'paymentaction' => 'Sale', // How you want to obtain payment. Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. Sale indicates that this is a final sale for which you are requesting payment. Default is Sale.
'paymentaction' => $this->payment_action == 'Authorization' ? 'Auth' : 'Sale', // How you want to obtain payment. Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. Sale indicates that this is a final sale for which you are requesting payment. Default is Sale.
'ipaddress' => $this->get_user_ip(), // Required. IP address of the payer's browser.
'returnfmfdetails' => '' // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0.
);
Expand Down
16 changes: 14 additions & 2 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function __construct() {
$this->error_email_notify = isset($this->settings['error_email_notify']) && $this->settings['error_email_notify'] == 'yes' ? true : false;
$this->error_display_type = isset($this->settings['error_display_type']) ? $this->settings['error_display_type'] : '';
$this->send_items = isset( $this->settings['send_items'] ) && $this->settings['send_items'] == 'yes' ? true : false;
$this->payment_action = isset($this->settings['payment_action']) ? $this->settings['payment_action'] : 'Sale';

//fix ssl for image icon
$this->icon = ! empty($this->settings['card_icon']) ? $this->settings['card_icon'] : WP_PLUGIN_URL . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/assets/images/payflow-cards.png';
Expand Down Expand Up @@ -216,7 +217,18 @@ function init_form_fields() {
'description' => __( 'Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.', 'paypal-for-woocommerce' ),
'default' => 'yes'
),
);
'payment_action' => array(
'title' => __('Payment Action', 'paypal-for-woocommerce'),
'label' => __('Whether to process as a Sale or Authorization.', 'paypal-for-woocommerce'),
'description' => __('Sale will capture the funds immediately when the order is placed. Authorization will authorize the payment but will not capture the funds. You would need to capture funds through your PayPal account when you are ready to deliver.'),
'type' => 'select',
'options' => array(
'Sale' => 'Sale',
'Authorization' => 'Authorization',
),
'default' => 'Sale'
),
);
$this->form_fields = apply_filters( 'angelleye_fc_form_fields', $this->form_fields );
}

Expand Down Expand Up @@ -391,7 +403,7 @@ function do_payment( $order, $card_number, $card_exp, $card_csc, $centinelPAResS
*/
$PayPalRequestData = array(
'tender'=>'C', // Required. The method of payment. Values are: A = ACH, C = Credit Card, D = Pinless Debit, K = Telecheck, P = PayPal
'trxtype'=>'S', // Required. Indicates the type of transaction to perform. Values are: A = Authorization, B = Balance Inquiry, C = Credit, D = Delayed Capture, F = Voice Authorization, I = Inquiry, L = Data Upload, N = Duplicate Transaction, S = Sale, V = Void
'trxtype'=> $this->payment_action == 'Authorization' ? 'A' : 'S', // Required. Indicates the type of transaction to perform. Values are: A = Authorization, B = Balance Inquiry, C = Credit, D = Delayed Capture, F = Voice Authorization, I = Inquiry, L = Data Upload, N = Duplicate Transaction, S = Sale, V = Void
'acct'=>$card_number, // Required for credit card transaction. Credit card or purchase card number.
'expdate'=>$card_exp, // Required for credit card transaction. Expiration date of the credit card. Format: MMYY
'amt'=>$order->get_total(), // Required. Amount of the transaction. Must have 2 decimal places.
Expand Down

0 comments on commit 8c40f87

Please sign in to comment.