user2423476
user2423476

Reputation: 2275

Verify Square transaction and get transaction ID

I am able to create a transaction like the following:

$result = $apiInstance->createPayment($body);

Now I am trying to verify that the payment went through and get a transaction ID.

I tried the following but it doesnt work:

$result->getTransaction()->getId();

How would I go on to approach this?

Upvotes: 0

Views: 234

Answers (1)

sjosey
sjosey

Reputation: 1348

The createPayment method returns a CreatePaymentResponse object, which doesn't contain a method called getTransaction(), but it does contain getPayment(). So you should change the last line to $result-getPayment()->getId() and it should work.

Reference: https://github.com/square/connect-php-sdk/blob/master/docs/Model/CreatePaymentResponse.md

Upvotes: 1

Related Questions