Skip to content
Snippets Groups Projects
Commit 18482c73 authored by drastik's avatar drastik
Browse files

Update for CiviCRM 4.4

-Fix amount issue from github: https://github.com/drastik/civicrm_stripe/issues/18
-Fix BillingBlock.tpl issues (cvv image, credit cards image)
-New error message report if there was a silent error (can be found in stripe.com account logs)
parent a7f66ac7
Branches
Tags
No related merge requests found
......@@ -89,6 +89,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
function stripeCatchErrors($op = 'create_customer', &$params, $qfKey = '') {
// @TODO: Handle all calls through this using $op switching for sanity.
// Check for errors before trying to submit.
$return = FALSE;
try {
switch ($op) {
case 'create_customer':
......@@ -202,9 +203,8 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
Stripe::setApiKey($this->_paymentProcessor['user_name']);
// Stripe amount required in cents.
$amount = (int)preg_replace('/[^\d]/', '', strval($params['amount']));
// It would require 3 digits after the decimal for one to make it this far.
// CiviCRM prevents this, but let's be redundant.
$amount = number_format($params['amount'], 2, '.', '');
$amount = (int) preg_replace('/[^\d]/', '', strval($amount));
// Get Cardholder's full name.
/*
......@@ -245,7 +245,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
/****
* If for some reason you cannot use Stripe.js and you are aware of PCI Compliance issues,
* here is the alternative to Stripe.js:
* here is the alternative to Stripe.js (also need to uncomment lines 211-215 & 275):
****/
/*
......@@ -370,12 +370,25 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Fire away! Check for errors before trying to submit.
$stripe_response = CRM_Core_Payment_Stripe::stripeCatchErrors(
'charge', $stripe_charge, $params['qfKey']);
// Success! Return some values for CiviCRM.
$params['trxn_id'] = $stripe_response->id;
// Return fees & net amount for Civi reporting. Thanks Kevin!
$params['fee_amount'] = $stripe_response->fee / 100;
$params['net_amount'] = $params['amount'] - $params['fee_amount'];
if (!empty($stripe_response)) {
// Success! Return some values for CiviCRM.
$params['trxn_id'] = $stripe_response->id;
// Return fees & net amount for Civi reporting. Thanks Kevin!
$params['fee_amount'] = $stripe_response->fee / 100;
$params['net_amount'] = $params['amount'] - $params['fee_amount'];
}
else {
// There was no response from Stripe on the create charge command.
if(empty($params['selectMembership']) && empty($params['contributionPageID'])) {
$error_url = CRM_Utils_System::url('civicrm/event/register',
"_qf_Main_display=1&cancel=1&qfKey=" . $params['qfKey'], FALSE, NULL, FALSE);
}
else {
$error_url = CRM_Utils_System::url('civicrm/contribute/transact',
"_qf_Main_display=1&cancel=1&qfKey=" . $params['qfKey'], FALSE, NULL, FALSE);
}
CRM_Core_Error::statusBounce("Stripe transaction response not recieved! Check the Logs section of your stripe.com account.", $error_url);
}
return $params;
}
......@@ -432,13 +445,13 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
VALUES (%1)", $query_params);
}
// If a contact/customer has an existing active recurring
// If a contact/customer has an existing active recurring
// contribution/subscription, Stripe will update the existing subscription.
// If only the amount has changed not the installments/frequency, Stripe
// will not charge the card again until the next installment is due. This
// does not work well for CiviCRM, since CiviCRM creates a new recurring
// contribution along with a new initial contribution, so it expects the
// card to be charged immediately. So, since Stripe only supports one
// contribution along with a new initial contribution, so it expects the
// card to be charged immediately. So, since Stripe only supports one
// subscription per customer, we have to cancel the existing active
// subscription first.
if (!empty($stripe_customer->subscription) && $stripe_customer->subscription-> status == 'active') {
......
<?xml version="1.0"?>
<extension key="com.drastikbydesign.stripe" type="module">
<downloadUrl>http://drastikbydesign.com/files/downloads/com.drastikbydesign.stripe-4.3-1.7.zip</downloadUrl>
<downloadUrl>http://drastikbydesign.com/files/downloads/com.drastikbydesign.stripe-4.4-1.7.zip</downloadUrl>
<file>stripe</file>
<name>Stripe</name>
<description>Stripe Payment Processor</description>
......@@ -12,11 +12,11 @@
<author>Joshua Walker (drastik) - Drastik by Design</author>
<email>admin@drastikbydesign.com</email>
</maintainer>
<releaseDate>2013-08-28</releaseDate>
<releaseDate>2013-12-01</releaseDate>
<version>1.7</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.3</ver>
<ver>4.4</ver>
</compatibility>
<comments>http://drastikbydesign.com/blog-entry/civicrm-stripe-payment-processor</comments>
<civix>
......
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
......@@ -167,7 +167,10 @@
{else}
<div class="crm-section {$form.credit_card_type.name}-section">
<div class="label">{$form.credit_card_type.label} {$reqMark}</div>
<div class="content">{$form.credit_card_type.html}</div>
<div class="content">
{$form.credit_card_type.html}
<div class="crm-credit_card_type-icons"></div>
</div>
<div class="clear"></div>
</div>
<div class="crm-section {$form.credit_card_number.name}-section">
......@@ -179,7 +182,7 @@
<div class="label">{$form.cvv2.label} {$reqMark}</div>
<div class="content">
{$form.cvv2.html}
<img src="{$config->resourceBase}i/mini_cvv2.gif" alt="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}" style="vertical-align: text-bottom;" />
<span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span>
</div>
<div class="clear"></div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment