mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 22:54:25 +01:00
Merge branch 'develop' of github.com:hillelcoren/invoice-ninja into develop
This commit is contained in:
commit
617ac98a75
@ -403,7 +403,6 @@ class AccountGatewayController extends BaseController
|
|||||||
'original_device' => \Request::server('HTTP_USER_AGENT'),
|
'original_device' => \Request::server('HTTP_USER_AGENT'),
|
||||||
'tos_acceptance_time' => time(),
|
'tos_acceptance_time' => time(),
|
||||||
'redirect_uri' => URL::to('gateways'),
|
'redirect_uri' => URL::to('gateways'),
|
||||||
'callback_uri' => URL::to(env('WEBHOOK_PREFIX','').'paymenthook/'.$account->account_key.'/'.GATEWAY_WEPAY),
|
|
||||||
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
|
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -418,6 +417,7 @@ class AccountGatewayController extends BaseController
|
|||||||
'name' => Input::get('company_name'),
|
'name' => Input::get('company_name'),
|
||||||
'description' => Input::get('description'),
|
'description' => Input::get('description'),
|
||||||
'theme_object' => json_decode(WEPAY_THEME),
|
'theme_object' => json_decode(WEPAY_THEME),
|
||||||
|
'callback_uri' => $accountGateway->getWebhookUrl(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (WEPAY_ENABLE_CANADA) {
|
if (WEPAY_ENABLE_CANADA) {
|
||||||
@ -453,6 +453,7 @@ class AccountGatewayController extends BaseController
|
|||||||
'tokenType' => $wepayUser->token_type,
|
'tokenType' => $wepayUser->token_type,
|
||||||
'tokenExpires' => $accessTokenExpires,
|
'tokenExpires' => $accessTokenExpires,
|
||||||
'accountId' => $wepayAccount->account_id,
|
'accountId' => $wepayAccount->account_id,
|
||||||
|
'state' => $wepayAccount->state,
|
||||||
'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE,
|
'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE,
|
||||||
'country' => WEPAY_ENABLE_CANADA ? Input::get('country') : 'US',
|
'country' => WEPAY_ENABLE_CANADA ? Input::get('country') : 'US',
|
||||||
));
|
));
|
||||||
|
@ -839,6 +839,53 @@ class PaymentController extends BaseController
|
|||||||
$this->paymentService->convertPaymentMethodFromWePay($source, null, $paymentMethod)->save();
|
$this->paymentService->convertPaymentMethodFromWePay($source, null, $paymentMethod)->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array('message' => 'Processed successfully');
|
||||||
|
} elseif ($objectType == 'account') {
|
||||||
|
$config = $accountGateway->getConfig();
|
||||||
|
if ($config->accountId != $objectId) {
|
||||||
|
return array('message' => 'Unknown account');
|
||||||
|
}
|
||||||
|
|
||||||
|
$wepay = \Utils::setupWePay($accountGateway);
|
||||||
|
$wepayAccount = $wepay->request('account', array(
|
||||||
|
'account_id' => intval($objectId),
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($wepayAccount->state == 'deleted') {
|
||||||
|
$accountGateway->delete();
|
||||||
|
} else {
|
||||||
|
$config->state = $wepayAccount->state;
|
||||||
|
$accountGateway->setConfig($config);
|
||||||
|
$accountGateway->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('message' => 'Processed successfully');
|
||||||
|
} elseif ($objectType == 'checkout') {
|
||||||
|
$payment = Payment::scope(false, $accountId)->where('transaction_reference', '=', $objectId)->first();
|
||||||
|
|
||||||
|
if (!$payment) {
|
||||||
|
return array('message' => 'Unknown payment');
|
||||||
|
}
|
||||||
|
|
||||||
|
$wepay = \Utils::setupWePay($accountGateway);
|
||||||
|
$checkout = $wepay->request('checkout', array(
|
||||||
|
'checkout_id' => intval($objectId),
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($checkout->state == 'refunded') {
|
||||||
|
$payment->recordRefund();
|
||||||
|
} elseif (!empty($checkout->refund) && !empty($checkout->refund->amount_refunded) && ($checkout->refund->amount_refunded - $payment->refunded) > 0) {
|
||||||
|
$payment->recordRefund($checkout->refund->amount_refunded - $payment->refunded);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($checkout->state == 'captured') {
|
||||||
|
$payment->markComplete();
|
||||||
|
} elseif ($checkout->state == 'cancelled') {
|
||||||
|
$payment->markCancelled();
|
||||||
|
} elseif ($checkout->state == 'failed') {
|
||||||
|
$payment->markFailed();
|
||||||
|
}
|
||||||
|
|
||||||
return array('message' => 'Processed successfully');
|
return array('message' => 'Processed successfully');
|
||||||
} else {
|
} else {
|
||||||
return array('message' => 'Ignoring event');
|
return array('message' => 'Ignoring event');
|
||||||
@ -904,6 +951,8 @@ class PaymentController extends BaseController
|
|||||||
}
|
}
|
||||||
} elseif ($eventType == 'charge.succeeded') {
|
} elseif ($eventType == 'charge.succeeded') {
|
||||||
$payment->markComplete();
|
$payment->markComplete();
|
||||||
|
} elseif ($eventType == 'charge.refunded') {
|
||||||
|
$payment->recordRefund($charge['amount_refunded'] / 100 - $payment->refunded);
|
||||||
}
|
}
|
||||||
} elseif($eventType == 'customer.source.updated' || $eventType == 'customer.source.deleted') {
|
} elseif($eventType == 'customer.source.updated' || $eventType == 'customer.source.deleted') {
|
||||||
$source = $eventDetails['data']['object'];
|
$source = $eventDetails['data']['object'];
|
||||||
|
@ -124,5 +124,11 @@ class AccountGateway extends EntityModel
|
|||||||
|
|
||||||
return substr(trim($stripe_key), 0, 8) == 'pk_test_' ? 'tartan' : 'production';
|
return substr(trim($stripe_key), 0, 8) == 'pk_test_' ? 'tartan' : 'production';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWebhookUrl()
|
||||||
|
{
|
||||||
|
$account = $this->account ? $this->account : Account::find($this->account_id);
|
||||||
|
return \URL::to(env('WEBHOOK_PREFIX','').'paymenthook/'.$account->account_key.'/'.$this->gateway_id.env('WEBHOOK_SUFFIX',''));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +48,17 @@ class AccountGatewayService extends BaseService
|
|||||||
return link_to("gateways/{$model->public_id}/edit", $model->name)->toHtml();
|
return link_to("gateways/{$model->public_id}/edit", $model->name)->toHtml();
|
||||||
} else {
|
} else {
|
||||||
$accountGateway = AccountGateway::find($model->id);
|
$accountGateway = AccountGateway::find($model->id);
|
||||||
|
$config = $accountGateway->getConfig();
|
||||||
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
||||||
$wepayAccountId = $accountGateway->getConfig()->accountId;
|
$wepayAccountId = $config->accountId;
|
||||||
|
$wepayState = isset($config->state)?$config->state:null;
|
||||||
$linkText = $model->name;
|
$linkText = $model->name;
|
||||||
$url = $endpoint.'account/'.$wepayAccountId;
|
$url = $endpoint.'account/'.$wepayAccountId;
|
||||||
$wepay = \Utils::setupWepay($accountGateway);
|
$wepay = \Utils::setupWepay($accountGateway);
|
||||||
$html = link_to($url, $linkText, array('target'=>'_blank'))->toHtml();
|
$html = link_to($url, $linkText, array('target'=>'_blank'))->toHtml();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$wepayAccount = $wepay->request('/account', array('account_id' => $wepayAccountId));
|
if ($wepayState == 'action_required') {
|
||||||
if ($wepayAccount->state == 'action_required') {
|
|
||||||
$updateUri = $wepay->request('/account/get_update_uri', array(
|
$updateUri = $wepay->request('/account/get_update_uri', array(
|
||||||
'account_id' => $wepayAccountId,
|
'account_id' => $wepayAccountId,
|
||||||
'redirect_uri' => URL::to('gateways'),
|
'redirect_uri' => URL::to('gateways'),
|
||||||
@ -67,7 +68,7 @@ class AccountGatewayService extends BaseService
|
|||||||
$url = $updateUri->uri;
|
$url = $updateUri->uri;
|
||||||
$html = "<a href=\"{$url}\">{$linkText}</a>";
|
$html = "<a href=\"{$url}\">{$linkText}</a>";
|
||||||
$model->setupUrl = $url;
|
$model->setupUrl = $url;
|
||||||
} elseif ($wepayAccount->state == 'pending') {
|
} elseif ($wepayState == 'pending') {
|
||||||
$linkText .= ' ('.trans('texts.resend_confirmation_email').')';
|
$linkText .= ' ('.trans('texts.resend_confirmation_email').')';
|
||||||
$model->resendConfirmationUrl = $url = URL::to("gateways/{$accountGateway->public_id}/resend_confirmation");
|
$model->resendConfirmationUrl = $url = URL::to("gateways/{$accountGateway->public_id}/resend_confirmation");
|
||||||
$html = link_to($url, $linkText)->toHtml();
|
$html = link_to($url, $linkText)->toHtml();
|
||||||
|
@ -413,7 +413,7 @@ class PaymentService extends BaseService
|
|||||||
'client_secret' => WEPAY_CLIENT_SECRET,
|
'client_secret' => WEPAY_CLIENT_SECRET,
|
||||||
'credit_card_id' => intval($details['token']),
|
'credit_card_id' => intval($details['token']),
|
||||||
'auto_update' => WEPAY_AUTO_UPDATE,
|
'auto_update' => WEPAY_AUTO_UPDATE,
|
||||||
'callback_uri' => URL::to(env('WEBHOOK_PREFIX','').'paymenthook/'.$client->account->account_key.'/'.GATEWAY_WEPAY),
|
'callback_uri' => $accountGateway->getWebhookUrl(),
|
||||||
));
|
));
|
||||||
$tokenResponse = $wepay->request('credit_card', array(
|
$tokenResponse = $wepay->request('credit_card', array(
|
||||||
'client_id' => WEPAY_CLIENT_ID,
|
'client_id' => WEPAY_CLIENT_ID,
|
||||||
@ -1199,6 +1199,7 @@ class PaymentService extends BaseService
|
|||||||
if ($accountGateway->gateway_id == GATEWAY_WEPAY) {
|
if ($accountGateway->gateway_id == GATEWAY_WEPAY) {
|
||||||
$details['applicationFee'] = $this->calculateApplicationFee($accountGateway, $details['amount']);
|
$details['applicationFee'] = $this->calculateApplicationFee($accountGateway, $details['amount']);
|
||||||
$details['feePayer'] = WEPAY_FEE_PAYER;
|
$details['feePayer'] = WEPAY_FEE_PAYER;
|
||||||
|
$details['callbackUri'] = $accountGateway->getWebhookUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $gateway->purchase($details)->send();
|
$response = $gateway->purchase($details)->send();
|
||||||
|
696
composer.lock
generated
696
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -77,9 +77,11 @@ $(function(){
|
|||||||
$('#wepay-country input').change(handleCountryChange)
|
$('#wepay-country input').change(handleCountryChange)
|
||||||
function handleCountryChange(){
|
function handleCountryChange(){
|
||||||
var country = $('#wepay-country input:checked').val();
|
var country = $('#wepay-country input:checked').val();
|
||||||
|
if(country) {
|
||||||
$('#wepay-accept-debit').toggle(country == 'CA');
|
$('#wepay-accept-debit').toggle(country == 'CA');
|
||||||
$('#wepay-tos-link').attr('href', 'https://go.wepay.com/terms-of-service-' + country.toLowerCase());
|
$('#wepay-tos-link').attr('href', 'https://go.wepay.com/terms-of-service-' + country.toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleCountryChange();
|
handleCountryChange();
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user