NikolaGavric94 / laravel-square

Square integration with Laravel/Lumen >=5.5
MIT License
31 stars 23 forks source link

How to add a title to the transaction #32

Closed ya-ya-it closed 4 years ago

ya-ya-it commented 4 years ago

Hello!

Thanks for your package, it's really useful! I'm building a booking system on Laravel and want to map orders on Square with data in my system. I'm using a simple code to charge a customer:

$options = [
          'amount' => $amount
          'source_id' => $request->input('nonce'),
          'location_id' => env('SQUARE_LOCATION_ID'),
          'currency' => 'CAD'
 ];

$transaction = Square::charge($options);

And on the dashboard, all the transactions have the title "Custom Amount".

Is there is a way to change it to some custom message, like in this example? (https://developer.squareup.com/docs/transactions-api/build-with-transactions)

$chargeBody->setReferenceId("Confirmation #12345");
$chargeBody->setNote("This is (not) a helpful note!");

I want to have a custom title to be "Order #123" to search on my system as well and map orders and payments.

Thanks!

NikolaGavric94 commented 4 years ago

Hmm, there isn't a possibility to add the name of the payment yet. I will add the possibility for you to do that and update the library, can't promise any time frames, but I will try to add it in the next few days. :)

ya-ya-it commented 4 years ago

Thanks for your reply! I made a quick fix in my app for that, but I think that might be a useful function to add. In SquareService inside charge method, I just added

$prepData = [
            'idempotency_key' => uniqid(),
            'amount_money'    => [
                'amount'   => $data['amount'],
                'currency' => $currency,
            ],
            'autocomplete' => true,
            'source_id' => $data['source_id'],
            'note' => $data['note'],
];

And pass the note with the options. Square use this note to make a title.

ya-ya-it commented 4 years ago

Also, I had to add

'location_id' => $data['location_id'],

to the $prepData, othervise the transaction went to the wrong location. We have a few locations with the same address connected to one account and without location_id, for some reasons, payments were made under the incorrect location.

NikolaGavric94 commented 4 years ago

@ya-ya-it it's up and live with v2.4.1. Don't forget to read up on the CHANGELOG.md because this release has some BREAKING CHANGES

ya-ya-it commented 4 years ago

Thank you for the quick response and fix!