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
67 changes: 9 additions & 58 deletions .github/workflows/auto-merge-client-library-changes.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,22 @@
name: Auto-merge client-library changes

on:
schedule:
- cron: "0 * * * *"
workflow_dispatch: {}
on: pull_request_target

permissions:
pull-requests: write

jobs:
merge-if-ready:
merge:
runs-on: ubuntu-latest
if: ${{ github.actor == 'gocardless-ci-robot[bot]' && github.event.pull_request.head.ref == 'template-changes' }}
steps:
- name: Find open template-changes PR from gocardless-ci-robot
id: find-pr
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail

pr_number=$(gh pr list --repo "$GITHUB_REPOSITORY" --head template-changes --state open \
--json number,author --jq '.[] | select(.author.login | endswith("gocardless-ci-robot")) | .number')

if [ -z "$pr_number" ]; then
echo "No open template-changes PR from gocardless-ci-robot"
fi

echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"

# Approved by github-actions[bot] via the default token - a different actor to
# gocardless-ci-robot[bot], which merges below. This satisfies the repo's required
# approving review count through normal review mechanics, without needing any
# ruleset bypass for gocardless-ci-robot.
- name: Approve PR
if: steps.find-pr.outputs.pr_number != ''
run: gh pr review --approve "$PR_URL"
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail

pr_number="${{ steps.find-pr.outputs.pr_number }}"
already_approved=$(gh pr view "$pr_number" --repo "$GITHUB_REPOSITORY" --json reviews \
--jq '[.reviews[] | select(.author.login == "github-actions" and .state == "APPROVED")] | length')

if [ "$already_approved" -gt 0 ]; then
echo "Already approved by github-actions[bot], skipping"
exit 0
fi

gh pr review "$pr_number" --repo "$GITHUB_REPOSITORY" --approve

- name: Merge template-changes PR once it's been open 24h
if: steps.find-pr.outputs.pr_number != ''
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GOCARDLESS_CI_ROBOT_TOKEN }}
run: |
set -euo pipefail

pr_number="${{ steps.find-pr.outputs.pr_number }}"
last_commit_date=$(gh pr view "$pr_number" --repo "$GITHUB_REPOSITORY" --json commits --jq '.commits[-1].committedDate')
age_seconds=$(( $(date -u +%s) - $(date -u -d "$last_commit_date" +%s) ))

echo "PR #$pr_number last pushed to $((age_seconds / 3600))h ago"

if [ "$age_seconds" -lt $((24 * 3600)) ]; then
echo "Still within the 24h window, skipping"
exit 0
fi

gh pr merge "$pr_number" --repo "$GITHUB_REPOSITORY" --auto --merge
9 changes: 5 additions & 4 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag v${{ steps.version.outputs.version }}
git push origin v${{ steps.version.outputs.version }}
TAG="v${{ steps.version.outputs.version }}"
git tag "$TAG"
git push origin "$TAG"
NOTES="${{ steps.notes.outputs.notes }}"
if [ -n "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
gh release create v${{ steps.version.outputs.version }} --notes "$NOTES"
gh release create "$TAG" --title "$TAG" --notes "$NOTES"
else
gh release create v${{ steps.version.outputs.version }} --generate-notes
gh release create "$TAG" --title "$TAG" --generate-notes
fi
env:
GITHUB_TOKEN: ${{ secrets.GOCARDLESS_CI_ROBOT_TOKEN }}
11 changes: 11 additions & 0 deletions src/main/java/com/gocardless/resources/Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private Payment() {

private Integer amount;
private Integer amountRefunded;
private Integer appFee;
private String chargeDate;
private String createdAt;
private Currency currency;
Expand Down Expand Up @@ -61,6 +62,16 @@ public Integer getAmountRefunded() {
return amountRefunded;
}

/**
* The amount to be deducted from the payment as the OAuth app''s fee, in the lowest
* denomination for the currency (e.g. pence in GBP, cents in EUR).
*
* Only present if the payment was created via an app.
*/
public Integer getAppFee() {
return appFee;
}

/**
* A future date on which the payment should be collected. If not specified, the payment will be
* collected as soon as possible. If the value is before the <a href=
Expand Down