mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:04:41 -04:00
Working on stripe payments using Omnipay
This commit is contained in:
parent
f72bd34483
commit
31afd09a0f
@ -38,7 +38,8 @@ class BasePaymentDriver
|
|||||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stubbed in parent, but should never be initialized
|
/* Stubbed in parent.
|
||||||
|
*
|
||||||
* The boot method should be used in the superclass
|
* The boot method should be used in the superclass
|
||||||
* to initialize all the member variables for the
|
* to initialize all the member variables for the
|
||||||
* given driver / payment gateway
|
* given driver / payment gateway
|
||||||
@ -46,8 +47,7 @@ class BasePaymentDriver
|
|||||||
* ie.
|
* ie.
|
||||||
*
|
*
|
||||||
* ->gateway()
|
* ->gateway()
|
||||||
* ->setRefundable(true)
|
* ->boot()
|
||||||
* ->setTokenBilling(true)
|
|
||||||
*
|
*
|
||||||
* @return Instance
|
* @return Instance
|
||||||
*/
|
*/
|
||||||
@ -108,4 +108,39 @@ class BasePaymentDriver
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************* Omnipay ******************************************
|
||||||
|
authorize($options) - authorize an amount on the customer's card
|
||||||
|
completeAuthorize($options) - handle return from off-site gateways after authorization
|
||||||
|
capture($options) - capture an amount you have previously authorized
|
||||||
|
purchase($options) - authorize and immediately capture an amount on the customer's card
|
||||||
|
completePurchase($options) - handle return from off-site gateways after purchase
|
||||||
|
refund($options) - refund an already processed transaction
|
||||||
|
void($options) - generally can only be called up to 24 hours after submitting a transaction
|
||||||
|
acceptNotification() - convert an incoming request from an off-site gateway to a generic notification object for further processing
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function purchase($data, $items)
|
||||||
|
{
|
||||||
|
$response = $this->gateway
|
||||||
|
->purchase($data)
|
||||||
|
->setItems($items)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
|
||||||
|
if ($response->isRedirect()) {
|
||||||
|
// redirect to offsite payment gateway
|
||||||
|
$response->redirect();
|
||||||
|
} elseif ($response->isSuccessful()) {
|
||||||
|
// payment was successful: update database
|
||||||
|
print_r($response);
|
||||||
|
} else {
|
||||||
|
// payment failed: display message to customer
|
||||||
|
echo $response->getMessage();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
$this->purchaseResponse = (array)$response->getData();*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -15,7 +15,17 @@ use Stripe\Stripe;
|
|||||||
|
|
||||||
class StripePaymentDriver extends BasePaymentDriver
|
class StripePaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
protected $refundable = true;
|
||||||
|
|
||||||
|
protected $token_billing = true;
|
||||||
|
|
||||||
|
protected $customer_reference = 'customerReferenceParam';
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->setRefundable($this->refundable);
|
||||||
|
$this->setTokenBilling($this->token_billing);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Methods in this class are divided into
|
* Methods in this class are divided into
|
||||||
* two separate streams
|
* two separate streams
|
||||||
@ -38,7 +48,6 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************** Stripe API methods **********************************************************/
|
/************************************** Stripe API methods **********************************************************/
|
||||||
|
|
||||||
public function init($api_key)
|
public function init($api_key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user