Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -116,41 +116,47 @@ class _generateRenewalInvoices extends \IPS\Task
|
||||
/* Charge to card */
|
||||
if ( $invoice->status !== $invoice::STATUS_PAID )
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
{
|
||||
$amountToPay = $invoice->amountToPay();
|
||||
$gateway = $card->method;
|
||||
|
||||
$transaction = new \IPS\nexus\Transaction;
|
||||
$transaction->member = $member;
|
||||
$transaction->invoice = $invoice;
|
||||
$transaction->method = $gateway;
|
||||
$transaction->amount = $amountToPay;
|
||||
$transaction->currency = $currency;
|
||||
$transaction->extra = array( 'automatic' => TRUE );
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
{
|
||||
$transaction->auth = $gateway->auth( $transaction, array(
|
||||
( $gateway->id . '_card' ) => $card
|
||||
) );
|
||||
$transaction->capture();
|
||||
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'paid',
|
||||
'status' => \IPS\nexus\Transaction::STATUS_PAID,
|
||||
'id' => $transaction->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'invoice_title' => $invoice->title,
|
||||
'automatic' => TRUE,
|
||||
), FALSE );
|
||||
|
||||
$transaction->approve();
|
||||
$amountToPay = $invoice->amountToPay();
|
||||
$gateway = $card->method;
|
||||
|
||||
$transaction = new \IPS\nexus\Transaction;
|
||||
$transaction->member = $member;
|
||||
$transaction->invoice = $invoice;
|
||||
$transaction->method = $gateway;
|
||||
$transaction->amount = $amountToPay;
|
||||
$transaction->currency = $currency;
|
||||
$transaction->extra = array( 'automatic' => TRUE );
|
||||
|
||||
try
|
||||
{
|
||||
$transaction->auth = $gateway->auth( $transaction, array(
|
||||
( $gateway->id . '_card' ) => $card
|
||||
) );
|
||||
$transaction->capture();
|
||||
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'paid',
|
||||
'status' => \IPS\nexus\Transaction::STATUS_PAID,
|
||||
'id' => $transaction->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'invoice_title' => $invoice->title,
|
||||
'automatic' => TRUE,
|
||||
), FALSE );
|
||||
|
||||
$transaction->approve();
|
||||
}
|
||||
catch ( \Exception $e ){}
|
||||
|
||||
$invoice->status = $transaction->invoice->status;
|
||||
}
|
||||
catch ( \Exception $e ){}
|
||||
|
||||
$invoice->status = $transaction->invoice->status;
|
||||
}
|
||||
// credit card doesn't exist anymore , move on
|
||||
catch ( \OutOfRangeException $e ){}
|
||||
|
||||
}
|
||||
|
||||
/* Update the purchase */
|
||||
|
||||
Reference in new issue
Block a user