Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies {
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation("com.paymob.sdk:Paymob-SDK:1.9.3"){
implementation("com.paymob.sdk:Paymob-SDK:1.9.5"){
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
exclude group: 'com.squareup.okio', module: 'okio'
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.paymob.sdk</groupId>
<artifactId>Paymob-SDK</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions android/libs/com/paymob/sdk/Paymob-SDK/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<groupId>com.paymob.sdk</groupId>
<artifactId>Paymob-SDK</artifactId>
<versioning>
<latest>1.9.3</latest>
<release>1.9.3</release>
<latest>1.9.5</latest>
<release>1.9.5</release>
<versions>
<version>1.9.3</version>
<version>1.9.5</version>
</versions>
<lastUpdated>20260719143255</lastUpdated>
<lastUpdated>20260818214641</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.WritableMap
import com.paymob.paymob_sdk.PaymobSdk
import com.paymob.paymob_sdk.FailureCallBackVersion
import com.paymob.paymob_sdk.domain.model.CreditCard
import com.paymob.paymob_sdk.domain.model.SavedCard
import com.paymob.paymob_sdk.ui.PaymobSdkListener
Expand All @@ -26,6 +27,7 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
private var showSaveCard: Boolean? = null
private var showResultsPage: Boolean? = null
private var showTransactionResult: Boolean? = null
private var failureCallBackVersion: FailureCallBackVersion? = null

override fun getName(): String {
return "PaymobReactnative"
Expand Down Expand Up @@ -120,6 +122,15 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
fun setKeyboardHandlingEnabled(isEnabled: Boolean) {
}

/**
* Sets the failure callback version used by the native SDK.
* Accepts values like "V1", "V2" (case-insensitive).
*/
@ReactMethod
fun setFailureCallbackVersion(version: String) {
failureCallBackVersion = if (version.equals("v2", true)) FailureCallBackVersion.V2 else FailureCallBackVersion.V1
}

/**
* Presents the payment view controller with the specified parameters.
*
Expand All @@ -144,6 +155,7 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
showSaveCard?.let { showSaveCard(it) }
showResultsPage?.let { showResultPage(it) }
showTransactionResult?.let { showTransactionResult(it) }
failureCallBackVersion?.let { setFailureCallbackVersion(it) }
}.build().start()
}

Expand All @@ -167,7 +179,7 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
* Called when the payment process fails.
*/
override fun onFailure(msg: String) {
emitTransactionStatus("Fail")
emitTransactionStatus("Fail", failureMessage = msg)
}

/**
Expand Down Expand Up @@ -199,7 +211,7 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
* @param status The status of the transaction.
* @param payResponse A map containing the payment response data (optional).
*/
private fun emitTransactionStatus(status: String, payResponse: HashMap<String, String?>? = null) {
private fun emitTransactionStatus(status: String, payResponse: HashMap<String, String?>? = null, failureMessage: String? = null) {
// Create a WritableMap to send to React Native
val statusMap: WritableMap = Arguments.createMap()

Expand All @@ -217,6 +229,9 @@ class PaymobReactnativeModule(reactContext: ReactApplicationContext) :
// If no payResponse, we can still send a null or empty details map
statusMap.putMap("details", Arguments.createMap())
}
if (failureMessage != null) {
statusMap.putString("message", failureMessage)
}

// Send the event with both status and details
sendEvent("onTransactionStatus", statusMap)
Expand Down
8 changes: 5 additions & 3 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
} from 'react-native';
import Paymob, {
PaymentStatus,
FailureCallBackVersion,
type PaymentResponse,
} from 'paymob-reactnative';
import PaymobEmbeddedView from './PaymobEmbeddedView';

export default function App() {
const [currentScreen, setCurrentScreen] = useState<'home' | 'embedded'>('home');

Check failure on line 21 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `'home'` with `⏎····'home'⏎··`
const [appName, setAppName] = useState<string>('');
const [isSaveCardEnabled, setSaveCardEnabled] = useState<boolean>(true);
const [isShowConfirmationPage, setShowConfirmationPage] =
Expand All @@ -38,12 +39,12 @@
switch (response.status) {
case PaymentStatus.SUCCESS:
requestAnimationFrame(() => {
Alert.alert('Payment result', PaymentStatus.SUCCESS);
Alert.alert(PaymentStatus.SUCCESS, (response.details || 'Unknown'));

Check failure on line 42 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `(response.details·||·'Unknown')` with `response.details·||·'Unknown'`
});
break;
case PaymentStatus.FAIL:
requestAnimationFrame(() => {
Alert.alert('Payment result', PaymentStatus.FAIL);
Alert.alert(PaymentStatus.FAIL , (response.message || 'Unknown'));

Check failure on line 47 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·,·(response.message·||·'Unknown')` with `,·response.message·||·'Unknown'`
});
break;
case PaymentStatus.CANCELLED:
Expand Down Expand Up @@ -71,20 +72,20 @@

return (
<View style={styles.container}>
<View style={{ flex: 1, justifyContent: 'center' }}>

Check warning on line 75 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { flex: 1, justifyContent: 'center' }
<Image
style={{

Check warning on line 77 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { height: 50, resizeMode: 'contain', marginBottom: 48 }
height: 50,
resizeMode: 'contain',
marginBottom: 48,
}}
source={{ uri: `data:image/png;base64,${base64Image}` }}
/>
<Text style={{ fontSize: 20, fontWeight: 'bold', marginBottom: 32 }}>

Check warning on line 84 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { fontSize: 20, fontWeight: 'bold', marginBottom: 32 }
Customizations
</Text>
<TextInput
style={{ marginBottom: 32, fontSize: 20 }}

Check warning on line 88 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { marginBottom: 32, fontSize: 20 }
onChangeText={(text: string) => {
setAppName(text);
Paymob.setAppName(text);
Expand All @@ -94,15 +95,15 @@
/>

<View
style={{

Check warning on line 98 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { flexDirection: 'row', alignItems: 'center', marginBottom: 32 }
flexDirection: 'row',
alignItems: 'center',
marginBottom: 32,
}}
>
<Text style={{ fontSize: 20 }}>Show save card</Text>

Check warning on line 104 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { fontSize: 20 }
<Switch
style={{ marginStart: 16 }}

Check warning on line 106 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { marginStart: 16 }
onValueChange={(flag: boolean) => {
setSaveCardEnabled(flag);
Paymob.setShowSaveCard(flag);
Expand All @@ -112,15 +113,15 @@
</View>

<View
style={{

Check warning on line 116 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { flexDirection: 'row', alignItems: 'center', marginBottom: 32 }
flexDirection: 'row',
alignItems: 'center',
marginBottom: 32,
}}
>
<Text style={{ fontSize: 20 }}>Show confirmation page</Text>

Check warning on line 122 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { fontSize: 20 }
<Switch
style={{ marginStart: 16 }}

Check warning on line 124 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { marginStart: 16 }
onValueChange={(flag: boolean) => {
setShowConfirmationPage(flag);
Paymob.setShowConfirmationPage(flag);
Expand Down Expand Up @@ -225,8 +226,9 @@

<Button
onPress={() => {
Paymob.setFailureCallbackVersion(FailureCallBackVersion.V2);
Paymob.presentPayVC(
'egy_csk_test_470ff99341ee584adf6ee587f7d199be',
'egy_csk_test_1ac79060ceabcf1fef3fea70d136cb42',
'egy_pk_test_huLoawdiICfwok1UVzEvQ4R3OajoyI1b'
);
}}
Expand Down
1 change: 1 addition & 0 deletions ios/PaymobReactNativeModule/PaymobReactnative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ @interface RCT_EXTERN_MODULE(PaymobReactnative, RCTEventEmitter)
RCT_EXTERN_METHOD(setShowSaveCard:(BOOL)isVisible)
RCT_EXTERN_METHOD(setShowConfirmationPage:(BOOL)isVisible)
RCT_EXTERN_METHOD(setShowTransactionResult:(BOOL)isVisible)
RCT_EXTERN_METHOD(setFailureCallbackVersion:(NSString *)version)
RCT_EXTERN_METHOD(setKeyboardHandlingEnabled:(BOOL)isEnabled)
RCT_EXTERN_METHOD(presentPayVC:(NSString *)clientSecret
publicKey:(NSString *)publicKey)
Expand Down
22 changes: 18 additions & 4 deletions ios/PaymobReactNativeModule/PaymobReactnative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PaymobReactnative: RCTEventEmitter, PaymobSDKDelegate {
private var showConfirmationPage: Bool? = nil
private var showTransactionResult: Bool? = nil
private var isKeyboardHandlingEnabled: Bool? = nil
private var failureCallBackVersion: FailureCallBackVersion? = nil

// MARK: - React Native Module
override static func moduleName() -> String {
Expand Down Expand Up @@ -76,6 +77,15 @@ class PaymobReactnative: RCTEventEmitter, PaymobSDKDelegate {
isKeyboardHandlingEnabled = isEnabled
}

@objc
func setFailureCallbackVersion(_ version: String) {
if version.lowercased() == "v2" {
failureCallBackVersion = .V2
} else {
failureCallBackVersion = .V1
}
}

@objc
func presentPayVC(_ clientSecret: String, publicKey: String) {
paymob.delegate = self
Expand All @@ -97,7 +107,7 @@ class PaymobReactnative: RCTEventEmitter, PaymobSDKDelegate {
public func transactionRejected(message: String) {
// Handle transaction rejection
print("Transaction Rejected")
let params: [String: Any] = ["status": "Fail"]
let params: [String: Any] = ["status": "Fail", "message": message]
emitEvent(eventName: "onTransactionStatus", params: params)
}

Expand Down Expand Up @@ -148,14 +158,18 @@ class PaymobReactnative: RCTEventEmitter, PaymobSDKDelegate {
paymob.paymobSDKCustomization.saveCardDefault = saveCardDefault
}

if let showConfirmationPage = self.showConfirmationPage {
paymob.paymobSDKCustomization.showConfirmationPage = showConfirmationPage
}
if let showConfirmationPage = self.showConfirmationPage {
paymob.paymobSDKCustomization.showConfirmationPage = showConfirmationPage
}

if let showTransactionResult = self.showTransactionResult {
paymob.paymobSDKCustomization.showTransactionResult = showTransactionResult
}

if let failureVersion = self.failureCallBackVersion {
paymob.paymobSDKCustomization.setFailureCallBackVersion = failureCallBackVersion
}

if let isKeyboardHandlingEnabled = self.isKeyboardHandlingEnabled {
paymob.paymobSDKCustomization.isKeyboardHandlingEnabled = isKeyboardHandlingEnabled
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, strong) NSBundle * _Nonnull Fl
@end

@class NSCoder;
SWIFT_CLASS("_TtC9PaymobSDK24CardInstallmentPlansView")
@interface CardInstallmentPlansView : UIView
- (void)awakeFromNib;
- (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER;
@end

@class UITableView;
@class NSIndexPath;
@class UITableViewCell;
@interface CardInstallmentPlansView (SWIFT_EXTENSION(PaymobSDK)) <UITableViewDataSource, UITableViewDelegate>
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section SWIFT_WARN_UNUSED_RESULT;
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath SWIFT_WARN_UNUSED_RESULT;
- (CGFloat)tableView:(UITableView * _Nonnull)tableView heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath SWIFT_WARN_UNUSED_RESULT;
- (CGFloat)tableView:(UITableView * _Nonnull)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath SWIFT_WARN_UNUSED_RESULT;
- (void)tableView:(UITableView * _Nonnull)tableView didSelectRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath;
@end

IB_DESIGNABLE
SWIFT_CLASS("_TtC9PaymobSDK23RadioCheckboxBaseButton")
@interface RadioCheckboxBaseButton : UIButton
Expand Down Expand Up @@ -494,13 +512,10 @@ SWIFT_CLASS("_TtC9PaymobSDK8DropDown")
- (void)touchAction;
@end

@class UITableView;
@class NSIndexPath;
@interface DropDown (SWIFT_EXTENSION(PaymobSDK)) <UITableViewDelegate>
- (void)tableView:(UITableView * _Nonnull)tableView didSelectRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath;
@end

@class UITableViewCell;
@interface DropDown (SWIFT_EXTENSION(PaymobSDK)) <UITableViewDataSource>
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section SWIFT_WARN_UNUSED_RESULT;
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath SWIFT_WARN_UNUSED_RESULT;
Expand Down Expand Up @@ -837,6 +852,31 @@ SWIFT_CLASS("_TtC9PaymobSDK24KeyboardLayoutConstraint") SWIFT_AVAILABILITY(tvos,
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

SWIFT_CLASS("_TtC9PaymobSDK8MenuView")
@interface MenuView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
@end

SWIFT_CLASS("_TtC9PaymobSDK15NibLoadableView")
@interface NibLoadableView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
@end

SWIFT_CLASS("_TtC9PaymobSDK18OneClickButtonView")
@interface OneClickButtonView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
- (void)layoutSubviews;
@end

SWIFT_CLASS("_TtC9PaymobSDK18OneClickHeaderView")
@interface OneClickHeaderView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
@end

SWIFT_CLASS("_TtC9PaymobSDK18PaymobCheckoutView")
@interface PaymobCheckoutView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading