skipcash-reactnative 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,9 +20,10 @@ SkipCash React Native Package; This package facilitates SkipCash integration wit
|
|
|
20
20
|
# Example
|
|
21
21
|
|
|
22
22
|
```jsx
|
|
23
|
+
|
|
23
24
|
import { useEffect, useState } from 'react';
|
|
24
25
|
|
|
25
|
-
import { StyleSheet, View, NativeEventEmitter, NativeModules, Platform, Alert } from 'react-native';
|
|
26
|
+
import { StyleSheet, View, NativeEventEmitter, KeyboardAvoidingView, NativeModules, Platform, Alert } from 'react-native';
|
|
26
27
|
import { initiateApplePay, PaymentData, PaymentResponse,
|
|
27
28
|
isWalletHasCards, setupNewCard, initiatePaymentModel
|
|
28
29
|
} from 'skipcash-reactnative';
|
|
@@ -43,29 +44,12 @@ export default function App() {
|
|
|
43
44
|
/**********************************
|
|
44
45
|
- THIS PACKAGE PROVIDES TWO PAYMENT OPTIONS FOR YOUR CUSTOMER -
|
|
45
46
|
1. IN-APP APPLE PAY using 'initiateApplePay()' function.
|
|
46
|
-
2. IN-APP WEB VIEW (INCLUDES ALL PAYMENT OPTIONS THAT SKIPCASH OFFERS
|
|
47
|
+
2. IN-APP WEB VIEW (INCLUDES ALL PAYMENT OPTIONS THAT SKIPCASH OFFERS (visa, master, amex,
|
|
48
|
+
international cards, etc...) using 'initiatePaymentModel()' function.
|
|
47
49
|
- THIS EXAMPLE APP, DEMONESTRATES HOW TO USE THE DIFFERENT OPTIONS MENTIONED ABOVE
|
|
48
50
|
***********************************/
|
|
49
51
|
|
|
50
|
-
/*
|
|
51
|
-
Here In case if you want to implement IN-APP Apple Pay
|
|
52
|
-
you have to pass the name of the merchant identifier
|
|
53
|
-
(you need to create a new one from apple developer account of your app ).
|
|
54
|
-
please reachout to https://dev.skipcash.app/ mobile apple pay section to
|
|
55
|
-
know how to generate your merchant identifier and setup Xcode.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
paymentData.setMerchantIdentifier("");
|
|
59
|
-
/*
|
|
60
|
-
Add your payment endpoint; You need to create an endpoint for your merchant account.
|
|
61
|
-
For more information on how to request a new payment, Please refer to https://dev.skipcash.app/doc/api-integration/.
|
|
62
|
-
|
|
63
|
-
You will need to implement this functionality on your backend server to create an endpoint that requests a new payment and returns the details you receive from the SkipCash server to this package. Of course your endpoint will receive the customer's details from this package request, Upon receiving the details response from your server this package will use that details to process your customer's payment via Apple Pay.
|
|
64
52
|
|
|
65
|
-
Once you have completed setting up and testing your endpoint, please provide the link to the setPaymentLinkEndPoint below.
|
|
66
|
-
*/
|
|
67
|
-
paymentData.setPaymentLinkEndPoint("")
|
|
68
|
-
paymentData.setAuthorizationHeader("");
|
|
69
53
|
/* add authorizartion header; used to protect your endpoint from unathorized access */
|
|
70
54
|
|
|
71
55
|
useEffect(() => {
|
|
@@ -92,7 +76,7 @@ export default function App() {
|
|
|
92
76
|
}
|
|
93
77
|
));
|
|
94
78
|
|
|
95
|
-
// For In-App Apple Pay
|
|
79
|
+
// For In-App Apple Pay
|
|
96
80
|
subscriptions.push(new NativeEventEmitter(NativeModules.SkipcashReactnative).addListener(
|
|
97
81
|
'applepay_response',
|
|
98
82
|
(paymentResponse: any) => {
|
|
@@ -101,7 +85,7 @@ export default function App() {
|
|
|
101
85
|
let response: PaymentResponse = PaymentResponse.fromJson(paymentResponse);
|
|
102
86
|
|
|
103
87
|
|
|
104
|
-
Alert.alert(`isSuccess: ${response.isSuccess} | transactionId: ${response.transactionId}
|
|
88
|
+
Alert.alert(`isSuccess: ${response.isSuccess} | transactionId: ${response.transactionId}
|
|
105
89
|
| returnCode: ${response.returnCode} | errorMessage: ${response.errorMessage}`);
|
|
106
90
|
|
|
107
91
|
/*
|
|
@@ -118,6 +102,9 @@ export default function App() {
|
|
|
118
102
|
|
|
119
103
|
return () => {
|
|
120
104
|
// cleaning up after leaving the current app view
|
|
105
|
+
// make sure to block leaving the current view until the payment is
|
|
106
|
+
// finished or canceled by the client or you will not be able to
|
|
107
|
+
// record the callback event for the payment status.
|
|
121
108
|
new NativeEventEmitter().removeAllListeners("responseScPaymentData");
|
|
122
109
|
if(Platform.OS === 'ios'){
|
|
123
110
|
new NativeEventEmitter().removeAllListeners("applepay_response");
|
|
@@ -128,6 +115,34 @@ export default function App() {
|
|
|
128
115
|
}, []);
|
|
129
116
|
|
|
130
117
|
const initiateApplePayPayment = () => {
|
|
118
|
+
/*
|
|
119
|
+
you have to pass the name of the merchant identifier
|
|
120
|
+
(you need to create a new one from apple developer account of your app ).
|
|
121
|
+
please reachout to https://dev.skipcash.app/ mobile apple pay section to
|
|
122
|
+
know how to generate your merchant identifier and setup Xcode.
|
|
123
|
+
*/
|
|
124
|
+
paymentData.setMerchantIdentifier("");
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
Apple Pay Payments Processing endpoint.
|
|
128
|
+
|
|
129
|
+
You need to setup an endpoint to create a new payments.
|
|
130
|
+
For more information on how to request a new payment, Please refer to https://dev.skipcash.app/doc/api-integration/.
|
|
131
|
+
|
|
132
|
+
You will need to implement this functionality on your backend server to create an endpoint that requests and create new payment and process it
|
|
133
|
+
and returns the details you receive from the SkipCash server to this package.
|
|
134
|
+
|
|
135
|
+
Your endpoint will receive the customer's details and apple pay token once the customer authorizes the transaction after calling initiateApplePay()
|
|
136
|
+
then your endpoint should process the payment by calling skipcash API, once done your endpoint should return the response received from SkipCash API
|
|
137
|
+
you can find details about how to setup your endpoint at "https://dev.skipcash.app/" under applepay section "configure payment processing endpoint".
|
|
138
|
+
|
|
139
|
+
Once you have completed setting up and testing your endpoint, please provide the link to the setPaymentLinkEndPoint below.
|
|
140
|
+
*/
|
|
141
|
+
paymentData.setPaymentLinkEndPoint("");
|
|
142
|
+
|
|
143
|
+
// if your endpoint requires authorization header you can pass it below
|
|
144
|
+
paymentData.setAuthorizationHeader("");
|
|
145
|
+
|
|
131
146
|
paymentData.setSummaryItem('Tax', '0.0'); // set summary item
|
|
132
147
|
paymentData.setSummaryItem('Total', amount); // set summary item
|
|
133
148
|
|
|
@@ -137,9 +152,10 @@ export default function App() {
|
|
|
137
152
|
paymentData.setEmail(email); // required
|
|
138
153
|
paymentData.setAmount(amount); // required
|
|
139
154
|
paymentData.setTransactionId(""); // your internal order id, (Optional) - but very much recommended
|
|
140
|
-
paymentData.setWebhookUrl(""); // very much recommended
|
|
155
|
+
paymentData.setWebhookUrl(""); // very much recommended
|
|
141
156
|
// read about webhooks -> https://dev.skipcash.app/doc/api-integration/web-hooks/
|
|
142
|
-
paymentData.setMerchantName("");
|
|
157
|
+
paymentData.setMerchantName("Your official business name in appstore");
|
|
158
|
+
/*
|
|
143
159
|
Required - (if using in-app apple-pay set your official merchant/business name for apple payment sheet)
|
|
144
160
|
this is required by apple, it must match your official name in appstore
|
|
145
161
|
*/
|
|
@@ -152,6 +168,7 @@ export default function App() {
|
|
|
152
168
|
const paymentDataJson = JSON.stringify(paymentData); // convert paymentData to json string
|
|
153
169
|
|
|
154
170
|
if(firstName && lastName && phone && email) {
|
|
171
|
+
console.log(paymentDataJson);
|
|
155
172
|
initiateApplePay(paymentDataJson);
|
|
156
173
|
}else{
|
|
157
174
|
Alert.alert("please fill firstname, lastname, phone, email & amount");
|
|
@@ -159,6 +176,26 @@ export default function App() {
|
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
const startPaymentModel = () => {
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
Add your payment endpoint; You need to create an endpoint for your merchant account.
|
|
182
|
+
For more information on how to request a new payment, Please refer to https://dev.skipcash.app/doc/api-integration/.
|
|
183
|
+
|
|
184
|
+
You will need to implement this functionality at your backend server. Create an endpoint that requests a new payment and returns the response
|
|
185
|
+
received from the SkipCash API.
|
|
186
|
+
|
|
187
|
+
Your endpoint will receive the customer's details from this package request, Upon receiving the details call SkipCash API to create a new payment
|
|
188
|
+
as mentioned in the above documentation then your endpoint should return the response received from SkipCash API this package will use the response
|
|
189
|
+
to open the new payment a webview to show the online payment options to customer.
|
|
190
|
+
|
|
191
|
+
Once you have completed setting up and testing your endpoint, please provide the link to the setPaymentLinkEndPoint below.
|
|
192
|
+
*/
|
|
193
|
+
paymentData.setPaymentLinkEndPoint("");
|
|
194
|
+
|
|
195
|
+
// if your endpoint requires authorization header you can pass it below
|
|
196
|
+
paymentData.setAuthorizationHeader("");
|
|
197
|
+
|
|
198
|
+
|
|
162
199
|
paymentData.setFirstName(firstName); // required
|
|
163
200
|
paymentData.setLastName(lastName); // required
|
|
164
201
|
paymentData.setPhone(phone); // required
|
|
@@ -194,7 +231,7 @@ export default function App() {
|
|
|
194
231
|
}
|
|
195
232
|
|
|
196
233
|
return (
|
|
197
|
-
<
|
|
234
|
+
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.container}>
|
|
198
235
|
<Title style={styles.title}>Payment Details</Title>
|
|
199
236
|
|
|
200
237
|
<TextInput
|
|
@@ -302,7 +339,7 @@ export default function App() {
|
|
|
302
339
|
>
|
|
303
340
|
Setup A Card
|
|
304
341
|
</Button>
|
|
305
|
-
</
|
|
342
|
+
</KeyboardAvoidingView>
|
|
306
343
|
);
|
|
307
344
|
}
|
|
308
345
|
|