Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
nikolag/square [![Latest Unstable Version](https://poser.pugx.org/nikolag/square/v/unstable)](https://packagist.org/packages/nikolag/square) [![Latest Stable Version](https://poser.pugx.org/nikolag/square/v/stable)](https://packagist.org/packages/nikolag/square) [![Total Downloads](https://poser.pugx.org/nikolag/square/downloads)](https://packagist.org/packages/nikolag/square) [![License](https://poser.pugx.org/nikolag/square/license)](https://packagist.org/packages/nikolag/square) [![Build Status](https://travis-ci.org/NikolaGavric94/laravel-square.svg?branch=develop)](https://travis-ci.org/NikolaGavric94/laravel-square)
nikolag/square
[![Build Status](https://travis-ci.org/NikolaGavric94/laravel-square.svg?branch=develop)](https://travis-ci.org/NikolaGavric94/laravel-square)
[![Latest Stable Version](https://poser.pugx.org/nikolag/square/v/stable)](https://packagist.org/packages/nikolag/square)
[![Total Downloads](https://poser.pugx.org/nikolag/square/downloads)](https://packagist.org/packages/nikolag/square)
[![License](https://poser.pugx.org/nikolag/square/license)](https://packagist.org/packages/nikolag/square)
=========
Square integration with laravel 5.4.x

Expand Down Expand Up @@ -96,7 +100,7 @@ $merchant->openedTransactions();
#### Charge customers with merchant as a seller
Charging a customer that doesn't exist and connecting it with a merchant and a transaction.
```javascript
public function chargeCustomerAsArray(Request $request) {
public function charge(Request $request) {
//$amount is in USD currency and is in cents. ($amount = 200 == 2 Dollars)
$amount = 5000;
//nonce reference => https://docs.connect.squareup.com/articles/adding-payment-form
Expand All @@ -118,7 +122,7 @@ public function chargeCustomerAsArray(Request $request) {
```
Charging already existing customer and connecting both transaction and merchant with it
```javascript
public function chargeCustomerAsArray(Request $request) {
public function charge(Request $request) {
//$amount is in USD currency and is in cents. ($amount = 200 == 2 Dollars)
$amount = 5000;
//nonce reference => https://docs.connect.squareup.com/articles/adding-payment-form
Expand All @@ -133,7 +137,7 @@ public function chargeCustomerAsArray(Request $request) {
```
Charging a customer without saving the customer, but connecting the transaction with the merchant.
```javascript
public function chargeCustomerAsArray(Request $request) {
public function charge(Request $request) {
//$amount is in USD currency and is in cents. ($amount = 200 == 2 Dollars)
$amount = 5000;
//nonce reference => https://docs.connect.squareup.com/articles/adding-payment-form
Expand Down Expand Up @@ -267,4 +271,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
7 changes: 4 additions & 3 deletions src/SquareCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ public function save()
* @param float $amount
* @param string $card_nonce
* @param string $location_id
* @param string|'USD' $currency
* @return \Nikolag\Square\Models\Transaction
* @throws \Nikolag\Square\Exception on non-2xx response
*/
public function charge(float $amount, string $card_nonce, string $location_id)
public function charge(float $amount, string $card_nonce, string $location_id, string $currency = 'USD')
{
$transaction = new Transaction(['status' => Constants::TRANSACTION_STATUS_OPENED, 'amount' => $amount]);
if($this->getMerchant())
Expand All @@ -125,7 +126,7 @@ public function charge(float $amount, string $card_nonce, string $location_id)
'idempotency_key' => uniqid(),
'amount_money' => array(
'amount' => $amount,
'currency' => 'USD'
'currency' => $currency
),
'card_nonce' => $card_nonce,
))->getTransaction();
Expand Down Expand Up @@ -241,4 +242,4 @@ public function setSquareConfig(SquareConfig $squareConfig)

return $this;
}
}
}
2 changes: 1 addition & 1 deletion src/contracts/SquareContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ interface SquareContract
{
public function locations();
public function save();
public function charge(float $amount, string $nonce, string $location_id);
public function charge(float $amount, string $nonce, string $location_id, string $currency = 'USD');
public function transactions(string $location_id, $begin_time = null, $end_time = null, $cursor = null, $sort_order = 'desc');
}
5 changes: 3 additions & 2 deletions src/traits/HasCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ public function scopeFailedTransactions($query)
* @param float $amount
* @param string $nonce
* @param string $location_id
* @param string|'USD' $currency
* @param any $customer
* @return \Nikolag\Square\Models\Transaction
*/
public function charge(float $amount, string $nonce, string $location_id, $customer = null)
public function charge(float $amount, string $nonce, string $location_id, string $currency = 'USD', $customer = null)
{
return Square::setMerchant($this)->setCustomer($customer)->charge($amount, $nonce, $location_id, $this->attributes[config('nikolag.user.identifier')]);
return Square::setMerchant($this)->setCustomer($customer)->charge($amount, $nonce, $location_id, $currency, $this->attributes[config('nikolag.user.identifier')]);
}

/**
Expand Down