Skip to content
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

bump native sdk to v3 #544

Merged
merged 13 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) :

@ReactMethod
@Suppress("unused")
fun processPayment(paymentIntentId: String, promise: Promise) = withExceptionResolver(promise) {
fun confirmPaymentIntent(paymentIntentId: String, promise: Promise) = withExceptionResolver(promise) {
val paymentIntent = requireParam(paymentIntents[paymentIntentId]) {
"There is no associated paymentIntent with id $paymentIntentId"
}
Expand Down Expand Up @@ -641,7 +641,7 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) :

@ReactMethod
@Suppress("unused")
fun processRefund(promise: Promise) {
fun confirmRefund(promise: Promise) {
terminal.confirmRefund(RNRefundCallback(promise))
}

Expand Down
2 changes: 2 additions & 0 deletions dev-app/ios/StripeTerminalReactNativeDevApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
9 changes: 0 additions & 9 deletions dev-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import DiscoveryMethodScreen from './screens/DiscoveryMethodScreen';
import CollectCardPaymentScreen from './screens/CollectCardPaymentScreen';
import SetupIntentScreen from './screens/SetupIntentScreen';
import MerchantSelectScreen from './screens/MerchantSelectScreen';
import ReadReusableCardScreen from './screens/ReadReusableCardScreen';
import LogListScreen from './screens/LogListScreen';
import LogScreen from './screens/LogScreen';
import RegisterInternetReaderScreen from './screens/RegisterInternetReaderScreen';
Expand Down Expand Up @@ -268,14 +267,6 @@ export default function App() {
}}
component={SetupIntentScreen}
/>
<Stack.Screen
name="ReadReusableCardScreen"
options={{
headerTitle: 'Read reusable card',
headerBackAccessibilityLabel: 'payment-back',
}}
component={ReadReusableCardScreen}
/>
<Stack.Screen
name="LogListScreen"
options={({ navigation }) => ({
Expand Down
24 changes: 12 additions & 12 deletions dev-app/src/screens/CollectCardPaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function CollectCardPaymentScreen() {
const {
createPaymentIntent,
collectPaymentMethod,
processPayment,
confirmPaymentIntent,
retrievePaymentIntent,
cancelCollectPaymentMethod,
setSimulatedCard,
Expand Down Expand Up @@ -310,38 +310,38 @@ export default function CollectCardPaymentScreen() {
},
],
});
await _processPayment(paymentIntent);
await _confirmPaymentIntent(paymentIntent);
}
};

const _processPayment = async (
const _confirmPaymentIntent = async (
collectedPaymentIntent: PaymentIntent.Type
) => {
// @ts-ignore
setCancel((prev) => ({ ...prev, isDisabled: true }));
addLogs({
name: 'Process Payment',
name: 'Confirm Payment Intent',
events: [
{
name: 'Process',
description: 'terminal.processPayment',
description: 'terminal.confirmPaymentIntent',
metadata: { paymentIntentId: collectedPaymentIntent.id },
},
],
});

const { paymentIntent, error } = await processPayment(
const { paymentIntent, error } = await confirmPaymentIntent(
collectedPaymentIntent.id
);

if (error) {
const failedPI = await api.getPaymentIntent(collectedPaymentIntent.id);
addLogs({
name: 'Process Payment',
name: 'Confirm Payment Intent',
events: [
{
name: 'Failed',
description: 'terminal.processPayment',
description: 'terminal.confirmPaymentIntent',
metadata: {
errorCode: error.code,
errorMessage: error.message,
Expand All @@ -355,11 +355,11 @@ export default function CollectCardPaymentScreen() {

if (!paymentIntent) {
addLogs({
name: 'Process Payment',
name: 'Confirm Payment Intent',
events: [
{
name: 'Failed',
description: 'terminal.processPayment',
description: 'terminal.confirmPaymentIntent',
metadata: {
errorCode: 'no_code',
errorMessage: 'no payment intent id returned!',
Expand All @@ -371,11 +371,11 @@ export default function CollectCardPaymentScreen() {
}

addLogs({
name: 'Process Payment',
name: 'Confirm Payment Intent',
events: [
{
name: 'Processed',
description: 'terminal.processPayment',
description: 'terminal.confirmPaymentIntent',
metadata: {
paymententIntentId: paymentIntent.id,
chargeId: paymentIntent.charges[0].id,
Expand Down
135 changes: 0 additions & 135 deletions dev-app/src/screens/ReadReusableCardScreen.tsx

This file was deleted.

24 changes: 12 additions & 12 deletions dev-app/src/screens/RefundPaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function RefundPaymentScreen() {
const {
collectRefundPaymentMethod,
cancelCollectRefundPaymentMethod,
processRefund,
confirmRefund,
setSimulatedCard,
} = useStripeTerminal({
onDidRequestReaderInput: (input) => {
Expand Down Expand Up @@ -113,29 +113,29 @@ export default function RefundPaymentScreen() {
},
],
});
_processRefund();
_confirmRefund();
}
};

const _processRefund = async () => {
const _confirmRefund = async () => {
addLogs({
name: 'Process Refund',
name: 'Confirm Refund',
events: [
{
name: 'Processing',
description: 'terminal.processRefund',
description: 'terminal.confirmRefund',
metadata: _refundMetadata,
},
],
});
const { error, refund } = await processRefund();
const { error, refund } = await confirmRefund();
if (error) {
addLogs({
name: 'Process Refund',
name: 'Confirm Refund',
events: [
{
name: 'Failed',
description: 'terminal.processRefund',
description: 'terminal.confirmRefund',
metadata: {
errorCode: error.code,
errorMessage: error.message,
Expand All @@ -145,22 +145,22 @@ export default function RefundPaymentScreen() {
});
} else if (refund && refund.status === 'succeeded') {
addLogs({
name: 'Process Refund',
name: 'Confirm Refund',
events: [
{
name: 'Succeeded',
description: 'terminal.processRefund',
description: 'terminal.confirmRefund',
metadata: _refundMetadata,
},
],
});
} else {
addLogs({
name: 'Process Refund',
name: 'Confirm Refund',
events: [
{
name: 'Pending or unsuccessful',
description: 'terminal.processRefund',
description: 'terminal.confirmRefund',
metadata: _refundMetadata,
},
],
Expand Down
6 changes: 3 additions & 3 deletions dev-app/src/screens/SetupIntentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function SetupIntentScreen() {
},
});

const _processPayment = useCallback(
const _confirmPaymentIntent = useCallback(
async (setupIntentId: string) => {
addLogs({
name: 'Process Payment',
Expand Down Expand Up @@ -137,11 +137,11 @@ export default function SetupIntentScreen() {
},
],
});
await _processPayment(setupIntentId);
await _confirmPaymentIntent(setupIntentId);
}
},
[
_processPayment,
_confirmPaymentIntent,
addLogs,
cancelCollectSetupIntent,
collectSetupIntentPaymentMethod,
Expand Down
Loading