This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
New: Next Gen Stripe Gateway #11
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbca0d9
feature: scaffold NextGenStripeGateway using Stripes new payment elem…
486222e
refactor: move intent updates into createPayment
249c436
refactor: cleanup gateway transactions with repository trait methods
4d75913
refactor: replace axios with fetch
a62307d
fix: pass message key to setError
ae30638
feature: add a next gen gateway interface
8e305df
refactor: use same-origin mode in fetch
0f13c2e
refactor: use same-origin for credentials as well
fa730b4
refactor: update to use sessions on donate controller for current rec…
c53b022
refactor: replace Call invoke with native php
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Framework/PaymentGateways/Contracts/NextGenPaymentGatewayInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace Give\Framework\PaymentGateways\Contracts; | ||
|
||
use Give\Framework\EnqueueScript; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
interface NextGenPaymentGatewayInterface { | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function enqueueScript(): EnqueueScript; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function formSettings(int $formId): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/NextGen/DonationForm/Blocks/DonationFormBlock/app/utilities/postData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @unreleased | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#supplying_request_options | ||
*/ | ||
export default async function postData(url: string, data: object = {}) { | ||
// Default options are marked with * | ||
const response = await fetch(url, { | ||
method: 'POST', // *GET, POST, PUT, DELETE, etc. | ||
mode: 'same-origin', // no-cors, *cors, same-origin | ||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached | ||
credentials: 'same-origin', // include, *same-origin, omit | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
redirect: 'follow', // manual, *follow, error | ||
referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url | ||
body: JSON.stringify(data) // body data type must match "Content-Type" header | ||
}); | ||
|
||
return { | ||
response, | ||
data: response.json() | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more specific name we can give these? What are the gateways intended to do at these points? Perhaps this is fine. It's just not clear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was a specific name lol.
beforeCreatePayment()
fires before the gateway class methodcreatePayment()
.afterCreatePayment()
gets fired after the gateway class methodcreatePayment()
. This is where the gateway could return data to itself usingReturnToBrowser
/ json and do something with that response.In the case for Stripe it needs to return a stripe intent status to the front-end and do something with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it is a specific as it can be. Right now the naming caters towards the event — that is, the name is clear that it's happening at a point in time and when. That doesn't really inform the gateway as what it ought to be doing at that time. I don't know if this is actually accurate, but something like,
prepareForDonation
andfinishDonation
— the point being that it gently guides the gateway as what it ought to be doing.That said, perhaps what's being done at this event varies too much from gateway to gateway, in which case the current event-based naming is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotchya, I think I gravitated toward the event-based naming because it coincides with the backend api naming convention and was easier to conceptualize in what order they get triggered while writing the logic. I know what you're saying about guiding the intention of the methods but as you said, the intention could vary between gateways. Some Gateways might not even need to use these.
Some use cases I see for each:
beforeCreatePayment()
createPayment()
, validation, gateway object mounting, pre-fetching something/using custom routeafterCreatePayment()
createPayment()
, gateway confirmation, redirecting (the framework will probably have a general way of redirecting to receipt as well).