-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added payment sessions support (#131)
- Loading branch information
1 parent
ea42e02
commit 3362ce3
Showing
9 changed files
with
201 additions
and
105 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
lib/checkout_sdk/payments/sessions/payment_sessions_client.rb
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckoutSdk | ||
module Payments | ||
class PaymentSessionsClient < Client | ||
PAYMENT_SESSIONS = 'payment-sessions' | ||
|
||
# @param [ApiClient] api_client | ||
# @param [CheckoutConfiguration] configuration | ||
def initialize(api_client, configuration) | ||
super api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY | ||
end | ||
|
||
# @param [Hash] payment_sessions | ||
def create_payment_sessions(payment_sessions) | ||
api_client.invoke_post(PAYMENT_SESSIONS, sdk_authorization, payment_sessions) | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module PaymentSessionsHelper | ||
|
||
def create_payment_sessions | ||
request = { | ||
'amount' => 2000, | ||
'currency' => CheckoutSdk::Common::Currency::GBP, | ||
'reference' => 'ORD-123A', | ||
'billing' => { | ||
'address' => { | ||
'country' => CheckoutSdk::Common::Country::GB | ||
} | ||
}, | ||
'customer' => { | ||
'name' => 'John Smith', | ||
'email' => '[email protected]', | ||
}, | ||
'success_url' => 'https://example.com/payments/success', | ||
'failure_url' => 'https://example.com/payments/fail' | ||
} | ||
|
||
response = default_sdk.payment_sessions.create_payment_sessions(request) | ||
expect(response).not_to be nil | ||
|
||
response | ||
end | ||
|
||
end |
Oops, something went wrong.