Skip to content

Commit

Permalink
Stripe changes after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sqlfusion2 committed Jul 4, 2012
1 parent e9c8c08 commit 04a69ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions class/Invoice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,7 @@ function eventProcessStripePayment(Eventcontroler $evtcl){
$error_code = $rr['error']['code'];
if(($error_code == 'invalid_expiry_month') || ($error_code == 'invalid_expiry_year') || ($error_code == 'expired_card') || ($error_code == 'missing')){
$goto = $error_page;
$_SESSION['updatecustomer'] = 'Yes';
}
$_SESSION['in_page_message'] = $r;
}
Expand Down
3 changes: 1 addition & 2 deletions class/Stripe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public function setAPIKey(){
*/
public function CreateCustomer($token,$name,$amount,$email="",$description=""){
$this->setAPIKey();

$customer = Stripe_Customer::create(array("card" => $token,"description" => $email));
$input = array("amount"=>$amount,"customer"=>$customer->id,"currency"=>"USD","description"=>$description);
$result = Stripe_Charge::create($input);
$result = Stripe_Charge::create($input);

if($result['paid'] === true){
$result_array = array("success"=>"1","customer_id"=>$customer->id);
Expand Down
36 changes: 30 additions & 6 deletions invoice_pay_stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
}else{$dis = "";}
}


/* $idcontact = $_SESSION['do_invoice']->idcontact;
if($_SESSION['updatecustomer'] <> 'Yes'){
$idcontact = $_SESSION['do_invoice']->idcontact;
$stripe_customer_id = $_SESSION['do_invoice']->getStripeCustomerId($_SESSION['do_invoice']->iduser,$idcontact);
echo $stripe_customer_id;die();
}
$_SESSION['updatecustomer'] = '';
//echo $stripe_customer_id;die();

if(empty($stripe_customer_id)){ */


if(empty($stripe_customer_id)){
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
Expand Down Expand Up @@ -127,7 +129,7 @@ function submit(form) {
// adding the input field names is the last step, in case an earlier step errors
addInputNames();
});
</script><?php //$do_feedback = new Feedback(); $do_feedback->createFeedbackBox(); ?>
</script><?php } //$do_feedback = new Feedback(); $do_feedback->createFeedbackBox(); ?>
<table class="layout_columns"><tr><td class="layout_lmargin"></td><td>
<div class="layout_content">
<?php include_once('includes/ofuz_navtabs_invoice.php'); ?>
Expand Down Expand Up @@ -158,10 +160,13 @@ function submit(form) {
?>
<div style="margin-left:0px;display:none;" id="msg_unauth"></div>
<?php

echo nl2br($_SESSION['do_invoice']->invoice_address);
//echo '<br />'. _('Total due :').'<b>$'. number_format($invoice_cal_data["total_due_amt"],2, '.', ',' ).'</b>';
echo '<br />'. _('Total due :').'<b>'. $_SESSION['do_invoice']->viewAmount($_SESSION['do_invoice']->amt_due).'</b>';
echo '<br /><br />';

if(empty($stripe_customer_id)){
$do_user_rel = new UserRelations();
$invoice_url = $GLOBALS['cfg_ofuz_site_http_base'].'inv/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idinvoice).'/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idcontact);
$do_payment = new Event("do_invoice->eventProcessStripePayment");
Expand All @@ -181,6 +186,25 @@ function submit(form) {
<span class="payment-errors"></span>
<script>if (window.Stripe) $("#do_invoice__eventProcessStripePayment").show()</script>
<noscript><p>JavaScript is required for the registration form.</p></noscript>
<?php } else {

$do_user_rel = new UserRelations();
$invoice_url = $GLOBALS['cfg_ofuz_site_http_base'].'inv/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idinvoice).'/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idcontact);
$do_payment = new Event("do_invoice->eventProcessStripePayment");
$do_payment->addParam("stripecustomer_id",$stripe_customer_id);
$do_payment->addParam("goto", $invoice_url); // send 0 if no CC else send 1
$do_payment->addParam("amt", $_SESSION['do_invoice']->amt_due);
$do_payment->addParam("error_page", "invoice_pay_stripe.php");
echo $do_payment->getFormHeader();
echo $do_payment->getFormEvent();
?> <table>
<tr>
<td><B><?php echo _('Total Amount') ?> : </B></td>
<td><input type="text" name="tot_amt" MAXLENGTH=16 value = "<?php echo $_SESSION['do_invoice']->amt_due; ?>"></td>
<td></td>
</tr>
</table>
<?php echo $do_payment->getFormFooter('Submit'); } ?>
</td></tr></table>
<div class="spacerblock_40"></div>
<div class="layout_footer"></div>
Expand Down
12 changes: 6 additions & 6 deletions invoice_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@
<?php }
} elseif($_SESSION['do_invoice']->payment_selection == 'stripe.com') {
if($_SESSION['do_invoice']->stripe_api_key != '' && $_SESSION['do_invoice']->stripe_publish_key != ''){
$idcontact = $_SESSION['do_invoice']->idcontact;
$stripe_customer_id = $_SESSION['do_invoice']->getStripeCustomerId($_SESSION['do_invoice']->iduser,$idcontact);
if(!empty($stripe_customer_id)){
$do_user_rel = new UserRelations();
//$idcontact = $_SESSION['do_invoice']->idcontact;
//$stripe_customer_id = $_SESSION['do_invoice']->getStripeCustomerId($_SESSION['do_invoice']->iduser,$idcontact);
//if(!empty($stripe_customer_id)){
/* $do_user_rel = new UserRelations();
$invoice_url = $GLOBALS['cfg_ofuz_site_http_base'].'inv/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idinvoice).'/'.$do_user_rel->encrypt($_SESSION['do_invoice']->idcontact);
$do_payment = new Event("do_invoice->eventProcessStripePayment");
$do_payment->addParam("stripecustomer_id",$stripe_customer_id);
Expand All @@ -244,10 +244,10 @@
?>
<?php echo $link; ?></a>&nbsp;<span class="sep3">|</span>&nbsp;
<?php
} else {
} else { */
?>
<a href="/invoice_pay_stripe.php"><?php echo _('Pay with Credit card'); ?></a>&nbsp;<span class="sep3">|</span>&nbsp;
<?php } ?>
<?php //} ?>
<?php } }?>
<?php } else { ?>
<?php if($_SESSION['do_invoice']->authnet_login != '' && $_SESSION['do_invoice']->authnet_merchant_id != ''){?>
Expand Down

0 comments on commit 04a69ce

Please sign in to comment.