# Marking payment as complete with a hook

**URL:** <https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023>\
**Category:** Get Help\
**Tags:** custom, payment-status, gfpaymentaddon, payments\
**Created:** [April 26, 2023, 7:45am UTC](https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023 "2023-04-26T07:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sllbakkbone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sllbakkbone/32/6921_2.png) [@sllbakkbone](https://community.gravityforms.com/u/sllbakkbone)\
**Post date:** [April 26, 2023, 7:45am UTC](https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023/1 "2023-04-26T07:45:13Z")

</div>

Hi all

I’m bouncing around the docs and honestly having trouble understanding the way some of it is written 😕

I’m working on an add-on that processes direct debit (non-US equivalent of ACH) payments. Intended flow is this:

- Payment submitted, defaults to `add_pending_payment`
- Add-on schedules an action to check with the bank nightly on the status of the debit
- When transaction is no longer pending, status is changed to either `complete_payment` or `fail_payment`

I’m struggling with what hooks to get my scheduled action to call, to change the status of the payment after the fact ???

Could someone please point me to the right hook to use?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [April 26, 2023, 8:52pm UTC](https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023/2 "2023-04-26T20:52:38Z")

</div>

Take a look at `GFAPI::update_entry_property`:

> **[Updating Entries with the GFAPI](https://docs.gravityforms.com/updating-entries-with-the-gfapi/#update-entry-property)**
>
> The GFAPI::update\_entry(), GFAPI::update\_entries(), GFAPI::update\_entry\_property(), and GFAPI::update\_entry\_field() methods are used to update entries in the database.

You would call that function whenever you want to update the payment status.

---

<div class="post-metadata">

**Author:** ![sllbakkbone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sllbakkbone/32/6921_2.png) [@sllbakkbone](https://community.gravityforms.com/u/sllbakkbone)\
**Post date:** [April 28, 2023, 4:16pm UTC](https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023/3 "2023-04-28T16:16:55Z")

</div>

Perfect, thanks! The only other thing along this line I’m struggling with is in my `authorize()` function, rendering the payment as pending rather than complete.  
Currently, for a pending payment I’m returning this array:

```auto
$result = array(
			'is_authorized' => true,
			'error_message' => $responseMessage,
			'transaction_id'	=> $transactionID,
            'captured_payment' => array(
				'is_success' => true,
				'error_message' => $responseMessage,
				'transaction_id'	=> $transactionID,
				'amount' => $transactionAmount
			);
		);

```

But it seems that if `is_authorized` or `is_success` are `false`, the payment is marked as failed, and there’s no in between…?  
Whereas if i mark them as `true` then change the payment status, I’m going to trigger both the payment complete and payment pending notification actions… I think?  
I hope I’m making sense

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [May 28, 2023, 4:17pm UTC](https://community.gravityforms.com/t/marking-payment-as-complete-with-a-hook/15023/4 "2023-05-28T16:17:10Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
