-
Notifications
You must be signed in to change notification settings - Fork 47
[DTPP-142] PayPalWebPayments show stages of order #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GMALKHA
merged 22 commits into
main
from
DTPP-142_PayPalWebPayments_show_stages_of_order
Dec 6, 2024
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
61b222a
[DTPP-142] PayPalWebPayments show stages of order
GMALKHA 9381efa
Refactoring
GMALKHA d184d26
cleanup
GMALKHA ce78477
refactoring
GMALKHA c3188c3
refactoring
GMALKHA d60f6dd
Created individual views for each step of order process
GMALKHA 3409509
refactoring
GMALKHA 6b00a15
update the state in the main traid
GMALKHA 1aaa2ad
refactoring
GMALKHA 1f13d48
checking intent (authorize || capture)
GMALKHA aaf4ef6
refactoring
GMALKHA 625f5c7
removing PayPalWebOrderActionButton file
GMALKHA ba35d43
intent process
GMALKHA 5e2f5aa
refactoring
GMALKHA 88aeb2a
refactoring
GMALKHA 7504112
Refactoring
GMALKHA f8be52a
fixing lint format
GMALKHA 6df2558
fixing swift lint
GMALKHA 4fd409b
Fixing swiftlint
GMALKHA 90919c9
refactoring
GMALKHA 55f4a5e
PayPalWebPayments restructure
GMALKHA 06e4c80
refactoring
GMALKHA 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
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
30
Demo/Demo/PayPalWebPayments/PayPalWebPaymentsView/PayPalApprovalResultView.swift
This file contains hidden or 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,30 @@ | ||
import SwiftUI | ||
|
||
struct PayPalApprovalResultView: View { | ||
@ObservedObject var payPalWebViewModel: PayPalWebViewModel | ||
|
||
var body: some View { | ||
switch payPalWebViewModel.state.approveResultResponse { | ||
case .idle, .loading: | ||
EmptyView() | ||
case .error(let message): | ||
ErrorView(errorMessage: message) | ||
case .loaded(let approvalResult): | ||
getApprovalSuccessView(approvalResult: approvalResult) | ||
} | ||
} | ||
|
||
func getApprovalSuccessView(approvalResult: PayPalPaymentState.ApprovalResult) -> some View { | ||
VStack(spacing: 16) { | ||
Text("Approval Result") | ||
.font(.headline) | ||
LeadingText("Approval ID", weight: .bold) | ||
|
||
LeadingText(approvalResult.id) | ||
if let status = approvalResult.status { | ||
LeadingText("Status", weight: .bold) | ||
LeadingText(status) | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Demo/Demo/PayPalWebPayments/PayPalWebPaymentsView/PayPalOrderCompletionResultView.swift
This file contains hidden or 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,28 @@ | ||
import SwiftUI | ||
|
||
struct PayPalOrderCompletionResultView: View { | ||
@ObservedObject var payPalWebViewModel: PayPalWebViewModel | ||
|
||
var body: some View { | ||
VStack { | ||
if case .loaded(let authorizedOrder) = payPalWebViewModel.state.authorizedOrderResponse { | ||
getCompletionSuccessView(order: authorizedOrder, intent: "Authorized") | ||
} | ||
if case .loaded(let capturedOrder) = payPalWebViewModel.state.capturedOrderResponse { | ||
getCompletionSuccessView(order: capturedOrder, intent: "Captured") | ||
} | ||
} | ||
} | ||
|
||
func getCompletionSuccessView(order: Order, intent: String) -> some View { | ||
VStack(spacing: 16) { | ||
Text("Order \(intent) Successfully") | ||
.font(.headline) | ||
|
||
LeadingText("Order ID", weight: .bold) | ||
LeadingText(order.id) | ||
LeadingText("Status", weight: .bold) | ||
LeadingText(order.status) | ||
} | ||
} | ||
} |
27 changes: 12 additions & 15 deletions
27
...WebPaymentsView/PayPalWebResultView.swift → ...ntsView/PayPalOrderCreateResultView.swift
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
48 changes: 48 additions & 0 deletions
48
Demo/Demo/PayPalWebPayments/PayPalWebViewModel/PayPalPaymentState.swift
This file contains hidden or 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,48 @@ | ||
import Foundation | ||
import PayPalWebPayments | ||
|
||
struct PayPalPaymentState: Equatable { | ||
|
||
struct ApprovalResult: Decodable, Equatable { | ||
let id: String | ||
let status: String? | ||
|
||
} | ||
var createOrder: Order? | ||
var authorizedOrder: Order? | ||
var capturedOrder: Order? | ||
var intent: Intent = .authorize | ||
var approveResult: ApprovalResult? | ||
|
||
var createdOrderResponse: LoadingState<Order> = .idle { | ||
didSet { | ||
if case .loaded(let value) = createdOrderResponse { | ||
createOrder = value | ||
} | ||
} | ||
} | ||
|
||
var approveResultResponse: LoadingState<ApprovalResult> = .idle { | ||
didSet { | ||
if case .loaded(let value) = approveResultResponse { | ||
approveResult = value | ||
} | ||
} | ||
} | ||
|
||
var capturedOrderResponse: LoadingState<Order> = .idle { | ||
didSet { | ||
if case .loaded(let value) = capturedOrderResponse { | ||
capturedOrder = value | ||
} | ||
} | ||
} | ||
|
||
var authorizedOrderResponse: LoadingState<Order> = .idle { | ||
didSet { | ||
if case .loaded(let value) = authorizedOrderResponse { | ||
authorizedOrder = value | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.