### Complete Front-End Checkout Example
Source: https://docs.geidea.net/docs/express-checkout-wallets
A full HTML example demonstrating the integration of the Geidea Express Checkout, including SDK loading, container setup, session ID injection, and initialization with callback handlers.
```html
Checkout
```
--------------------------------
### Get Subscription API Request Example
Source: https://docs.geidea.net/docs/get-subscription-1
Use this cURL command to make a GET request to retrieve subscription details. Ensure you replace the placeholder subscription ID and authorization header with your actual values. The `data-raw` field includes the signature for the request.
```curl
curl --request GET \
--url https://api.merchant.geidea.net/subscriptions/api/v1/direct/subscription/8a055aa4-13d9-4f74-421d-08dc3cbb381c \
--header 'accept: application/json' \
--header 'authorization: Basic YTA4N2Y0Y2EtOTg5MC00MDdiLTljMmYtNzYzMDgzNmNjMDIwOjI2ZDMxOTE3LTcxNWUtNDhhYy1iMDcyLWRhOTczODAxNmFmNQ==' \
--data-raw '{
"signature":"1KeVT7QumxpsWY8SnWN8WzTBlKdwz1EGBaANIEoh5mg="
}'
```
--------------------------------
### GDPaymentSDK API Reference
Source: https://docs.geidea.net/docs/flutter-1
The main entry point for interacting with the payment SDK. Use `sharedInstance()` to get the singleton instance and `start()` to initiate a payment.
```dart
class GDPaymentSDK {
static GDPaymentSDK sharedInstance();
Future start({
required GDPaymentSDKConfiguration configuration,
SDKPresentationStyle presentationStyle = const PushStyle(),
});
}
```
--------------------------------
### Initialize and Start Payment (Popup Mode)
Source: https://docs.geidea.net/docs/geidea-checkout-v2
Initializes the GeideaCheckout library and starts the payment process in popup mode. This method should be triggered by a user action, such as clicking a 'Pay' button.
```javascript
const payment = new GeideaCheckout(onSuccess, onError, onCancel);
payment.startPayment(sessionId);
```
--------------------------------
### Payment Session Response Example
Source: https://docs.geidea.net/docs/android-sdk
This is an example of a successful response when creating a payment session. The 'session.id' is crucial for initiating the client-side SDK.
```json
{
"session": {
"id": "b90e8b08-178e-4a8e-0b6c-08dde9fbe245",
// ...
},
"responseMessage": "Success",
"detailedResponseMessage": "The operation was successful",
// ...
}
```
--------------------------------
### Start Payment with Push Activity Style
Source: https://docs.geidea.net/docs/android-sdk
Initiates the payment flow using a full-screen push activity presentation style.
```APIDOC
## Start Payment with Push Activity Style
### Description
Starts the Geidea payment flow using the `Push` presentation style, which takes over the full screen.
### Method
`GDPaymentSDK.sharedInstance().start(configuration, context, presentationStyle)`
### Parameters
#### Request Body
- **configuration** (GDPaymentSDKConfiguration) - Required - SDK configuration object.
- **context** (Context) - Required - The application or activity context.
- **presentationStyle** (SDKPresentationStyle.Push) - Required - Specifies the push activity presentation style.
### Request Example
```kotlin
GDPaymentSDK.sharedInstance().start(
configuration,
context = this@MainActivity,
presentationStyle = SDKPresentationStyle.Push(),
)
```
```
--------------------------------
### Start Payment with Fragment Integration
Source: https://docs.geidea.net/docs/android-sdk
Integrates the payment flow as a fragment within an existing screen.
```APIDOC
## Start Payment with Fragment Integration
### Description
Integrates the Geidea payment flow as a fragment within your existing activity layout. This is suitable for inline payment forms.
### Method
`GDPaymentSDK.sharedInstance().start(configuration, context, presentationStyle)`
### Parameters
#### Request Body
- **configuration** (GDPaymentSDKConfiguration) - Required - SDK configuration object.
- **context** (Context) - Required - The application or activity context.
- **presentationStyle** (SDKPresentationStyle.Present.PresentationType.Fragment) - Required - Specifies the fragment presentation style, including `fragmentManager` and `containerId`.
### Request Example
```kotlin
GDPaymentSDK.sharedInstance().start(
configuration,
context = this@MainActivity,
presentationStyle = SDKPresentationStyle.Present(
presentationType = SDKPresentationStyle.Present.PresentationType.Fragment(
fragmentManager = supportFragmentManager,
containerId = R.id.payment_container
)
),
)
```
### Layout Example
```xml
```
```
--------------------------------
### Start Payment with Push Activity Style
Source: https://docs.geidea.net/docs/android-sdk
Initiate the payment flow using the 'Push' presentation style for a full-screen experience. This is ideal for dedicated payment screens.
```kotlin
GDPaymentSDK.sharedInstance().start(
configuration,
context = this@MainActivity,
presentationStyle = SDKPresentationStyle.Push(),
)
```
--------------------------------
### Run flutter pub get
Source: https://docs.geidea.net/docs/flutter-1
After updating pubspec.yaml, run this command to fetch the SDK.
```bash
flutter pub get
```
--------------------------------
### Create React Native App
Source: https://docs.geidea.net/docs/react-native-1
Use the React Native CLI to initialize a new project. Ensure you have Node.js 18+ and the React Native CLI installed.
```bash
npx @react-native-community/cli init GeideaPaymentDemo
cd GeideaPaymentDemo
```
--------------------------------
### Create Payment Link Response
Source: https://docs.geidea.net/docs/pay-by-link-apis
Example response after successfully creating a payment link. It includes the payment link and customer details.
```json
{
"paymentIntent": {
"link": "https://merchant.geidea.net/payByLink/GeideaGatewayKSA/w23-ctb-8y9-78o",
"customer": {
"customerId": "938e6122-c42a-4ee1-4634-08dc400e9226",
"email": "test2@gmail.com",
"phoneNumber": "8003030083",
"phoneCountryCode": "+20",
"name": "John",
"updatedBy": null,
"updatedDate": "2024-03-18T12:36:20.6459781Z",
"addresses": [],
"customValue": null
},
"eInvoiceDetails": {
"type": "Detailed",
"collectCustomersBillingShippingAddress": false,
"preAuthorizeAmount": false,
"subtotalWithoutTax": 20,
"subtotalTax": 0,
"subtotal": 20,
"grandTotal": 20,
"extraCharges": 0,
"extraChargesType": "Amount",
"extraChargesLabel": null,
"chargeDescription": "charge amount",
"merchantReferenceId": "ref123",
"invoiceDiscount": 0,
"invoiceDiscountType": "Amount",
"language": "EN",
"eInvoiceItems": [
{
"eInvoiceItemId": "e77e4795-8d14-4899-855b-08dc4011fb90",
"description": "Subscription for tech",
"price": 10,
"priceWithDiscount": 10,
"priceTax": 0,
"priceTotal": 10,
"quantity": 2,
"sku": "1245",
"itemDiscount": 0,
"itemDiscountType": "Amount",
"tax": 0,
"taxType": "Amount",
"totalWithoutTax": 20,
"totalTax": 0,
"total": 20
}
],
"callbackUrl": "https://webhook.site/eb350004-1c84-48ef-8436-55c5a734cce4",
"addOnFees": null,
```
--------------------------------
### SDKTheme Initialization
Source: https://docs.geidea.net/docs/ios-sdk
Demonstrates how to initialize the SDKTheme with custom styling for the Geidea SDK. This allows you to match the SDK's appearance to your brand.
```APIDOC
## SDKTheme Initialization
### Description
Initialize the `SDKTheme` struct to customize the visual appearance of the Geidea SDK, including colors and fonts.
### Parameters
#### Initializer Parameters
- **style** (ThemeStyle) - Optional - The overall theme style, defaults to `.light`.
- **primaryColor** (String) - Optional - The primary color for UI elements, defaults to "#0036FF".
- **secondaryColor** (String) - Optional - The secondary color for UI elements, defaults to "#F5F5F6".
- **merchantLogo** (UIImage) - Required - The logo of the merchant to be displayed.
### Request Example
```swift
let theme = SDKTheme(
style: .light,
primaryColor: "#FF4D00",
secondaryColor: "#F5F5F6",
merchantLogo: UIImage(named: "your_logo")! // Replace with your actual logo UIImage
)
```
```
--------------------------------
### Retrieve Order ID API Request Example
Source: https://docs.geidea.net/docs/meeza-qr-apis
This is an example of a GET API request to retrieve the Order ID. It requires a Payment Intent ID as a path parameter.
```http
https://api.merchant.geidea.net/payment-intent/api/v1/paymentIntent/{Payment Intent ID}
```
--------------------------------
### SDK Initialization (Jetpack Compose)
Source: https://docs.geidea.net/docs/android-sdk
Shows how to initialize the Geidea SDK with configuration within a Jetpack Compose UI.
```APIDOC
## SDK Initialization (Jetpack Compose)
### Description
Initialize the Geidea SDK with configuration details within a Jetpack Compose screen. This example uses `LocalContext.current` for context.
### Method
`GDPaymentSDK.sharedInstance().start(configuration, context)`
### Parameters
#### Request Body
- **configuration** (GDPaymentSDKConfiguration) - Required - SDK configuration object.
- **context** (Context) - Required - The application or activity context.
### Request Example
```kotlin
import net.geidea.sdk.GDPaymentSDK
import net.geidea.sdk.sdk.*
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
@Composable
fun PaymentScreen() {
val context = LocalContext.current
// Initialize SDK
val configuration = remember {
GDPaymentSDKConfiguration(
sessionId = "your_session_id", // From Step 1
region = REGION.EGY, // or UAE, KSA
isSandbox = true, // for pre-production
language = SDKLanguage.ENGLISH, // or ARABIC
theme = SDKTheme(
primaryColor = "#667eea",
secondaryColor = "#764ba2",
merchantLogo = ContextCompat.getDrawable(context, R.drawable.logo)
)
)
}
Button(
onClick = {
GDPaymentSDK.sharedInstance().apply {
start(configuration, context)
}
}
) {
Text("Pay Now")
}
}
```
```
--------------------------------
### GDPaymentSDK.start
Source: https://docs.geidea.net/docs/flutter-1
Initiates the payment process with the provided configuration and presentation style.
```APIDOC
## GDPaymentSDK.start
### Description
Initiates the payment process with the provided configuration and presentation style.
### Method Signature
```dart
Future start({
required GDPaymentSDKConfiguration configuration,
SDKPresentationStyle presentationStyle = const PushStyle(),
});
```
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (PaymentResponse)
- **status** (PaymentStatus) - The status of the payment.
- **result** (GDPaymentResult?) - The result of the payment if successful.
- **error** (GDPaymentError?) - The error details if the payment failed.
#### Response Example
None
```
--------------------------------
### Retrieve Order Details API Request URL
Source: https://docs.geidea.net/docs/meeza-qr-apis
This is an example of a GET API request URL for retrieving order details. It requires the Payment Intent ID and Order ID as path parameters.
```http
https://api.merchant.geidea.net/pgw/api/v1/order/{Payment Intent ID}/{Order ID}
```
--------------------------------
### Initialize SDK in Jetpack Compose
Source: https://docs.geidea.net/docs/android-sdk
Set up the Geidea SDK configuration and initiate the payment process within a Jetpack Compose UI. The `isSandbox` flag is useful for pre-production testing.
```kotlin
import net.geidea.sdk.GDPaymentSDK
import net.geidea.sdk.sdk.*
@Composable
fun PaymentScreen() {
val context = LocalContext.current
// Initialize SDK
val configuration = remember {
GDPaymentSDKConfiguration(
sessionId = "your_session_id", // From Step 1
region = REGION.EGY, // or UAE, KSA
isSandbox = true, // for pre-production
language = SDKLanguage.ENGLISH, // or ARABIC
theme = SDKTheme(
primaryColor = "#667eea",
secondaryColor = "#764ba2",
merchantLogo = ContextCompat.getDrawable(context, R.drawable.logo)
)
)
}
Button(
onClick = {
GDPaymentSDK.sharedInstance().apply {
start(configuration, context)
}
}
) {
Text("Pay Now")
}
}
```
--------------------------------
### SDK Initialization (XML View)
Source: https://docs.geidea.net/docs/android-sdk
Demonstrates how to initialize the Geidea SDK with configuration in an Android Activity using XML layouts.
```APIDOC
## SDK Initialization (XML View)
### Description
Initialize the Geidea SDK with configuration details such as session ID, region, language, and theme. This example uses an Activity context.
### Method
`GDPaymentSDK.sharedInstance().start(configuration, activityContext)`
### Parameters
#### Request Body
- **configuration** (GDPaymentSDKConfiguration) - Required - SDK configuration object.
- **activityContext** (AppCompatActivity) - Required - The activity context.
### Request Example
```kotlin
import net.geidea.sdk.GDPaymentSDK
import net.geidea.sdk.sdk.*
class PaymentActivity : AppCompatActivity() {
private lateinit var paymentSDK: GDPaymentSDK
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_payment)
// Create SDK configuration
val configuration = GDPaymentSDKConfiguration(
sessionId = "your_session_id", // From Step 1
region = REGION.EGY, // or UAE, KSA
language = SDKLanguage.ENGLISH, // or ARABIC
theme = SDKTheme( // optional
primaryColor = "#667eea",
secondaryColor = "#764ba2",
merchantLogo = ContextCompat.getDrawable(this, R.drawable.logo)
)
)
// Initialize SDK
paymentSDK = GDPaymentSDK.sharedInstance()
paymentSDK.start(configuration, this@PaymentActivity)
}
}
```
```
--------------------------------
### Example Response for Payment Link Update
Source: https://docs.geidea.net/docs/pay-by-link-apis
This is an example of a successful response after updating a payment link. It includes details about the payment intent and transaction status.
```json
{
"paymentIntent": {
"link": "https://merchant.geidea.net/payByLink/GeideaGatewayKSA/w23-ctb-8y9-78o",
"customer": {
"customerId": "938e6122-c42a-4ee1-4634-08dc400e9226",
"email": "test2@gmail.com",
"phoneNumber": "8003030083",
"phoneCountryCode": "+20",
"name": "John",
"updatedBy": "PGW",
"updatedDate": "2024-03-19T09:23:31.4158777Z",
"addresses": [],
"customValue": null
},
"eInvoiceDetails": {
"type": "Detailed",
"collectCustomersBillingShippingAddress": false,
"preAuthorizeAmount": true,
"subtotalWithoutTax": 20,
"subtotalTax": 0,
"subtotal": 20,
"grandTotal": 20,
"extraCharges": 0,
"extraChargesType": "Amount",
"extraChargesLabel": null,
"chargeDescription": "charge amount update",
"merchantReferenceId": "ref123",
"invoiceDiscount": 0,
"invoiceDiscountType": "Amount",
"language": "EN",
"eInvoiceItems": [
{
"eInvoiceItemId": "7ca2efb5-8721-4539-b43f-08dc40161532",
"description": "Subscription for tech1",
"price": 10,
"priceWithDiscount": 10,
"priceTax": 0,
"priceTotal": 10,
"quantity": 2,
"sku": "12456",
"itemDiscount": 0,
"itemDiscountType": "Amount",
"tax": 0,
"taxType": "Amount",
"totalWithoutTax": 20,
"totalTax": 0,
"total": 20
}
],
"callbackUrl": "https://webhook.site/eb350004-1c84-48ef-8436-55c5a734cce4",
"addOnFees": null,
"addOnFeesType": null,
"addOnFeesLabel": null
},
"eInvoiceSentLinks": [],
"customFields": null,
"paymentIntentId": "8f67f208-7a6d-4e5c-741e-08dc400e92f5",
"parentPaymentIntentId": null,
"number": "956638821339",
"urlSlug": "w23-ctb-8y9-78o",
"type": "EInvoice",
"amount": 20,
"currency": "SAR",
"merchantId": "e80ece7e-fb2a-4c0b-de94-08d8a29a107b",
"merchantPublicKey": "a087f4ca-9890-407b-9c2f-7630836cc020",
"expiryDate": "2024-05-10T00:00:00Z",
"activationDate": "2024-03-18T00:00:00Z",
"status": "SentToCustomer",
"customerId": "938e6122-c42a-4ee1-4634-08dc400e9226",
"eInvoiceUploadId": null,
"staticPaylinkId": null,
"subscriptionId": null,
"subscriptionOccurrenceId": null,
"orders": [],
"isPending": true,
"createdDate": "2024-03-18T12:41:39.74096Z",
"createdBy": "e80ece7e-fb2a-4c0b-de94-08d8a29a107b",
"updatedDate": "2024-03-19T09:23:31.3091588Z",
"updatedBy": "e80ece7e-fb2a-4c0b-de94-08d8a29a107b"
},
"termsAndConditions": null,
"responseMessage": "Success",
"detailedResponseMessage": "The operation was successful",
"language": "EN",
"responseCode": "000",
"detailedResponseCode": "000"
}
```
--------------------------------
### Payment Session Response Example
Source: https://docs.geidea.net/docs/ios-sdk
This is an example of a successful response from the Geidea API after creating a payment session. The 'session.id' is crucial for initiating the payment on the client-side.
```json
{
"session": {
"id": "b90e8b08-178e-4a8e-0b6c-08dde9fbe245",
// ...
},
"responseMessage": "Success",
"detailedResponseMessage": "The operation was successful",
// ...
}
```
--------------------------------
### Cancel Order API Response Example
Source: https://docs.geidea.net/docs/cancel-order-1
This is an example of a successful response from the Cancel Order API. It confirms the order cancellation with a response message and code.
```json
{
"orderId": "c64d3090-2531-454a-5dca-08db15bcae4b",
"responseMessage": "Cancelled",
"detailedResponseMessage": "Order cancelled by user",
"language": "en",
"responseCode": "010",
"detailedResponseCode": "001"
}
```
--------------------------------
### Start Metro Bundler for React Native
Source: https://docs.geidea.net/docs/react-native-1
Run this command in a terminal to start the Metro bundler, which is essential for serving your React Native application during development.
```bash
npx react-native start
```
--------------------------------
### Initiate Payment with Geidea SDK
Source: https://docs.geidea.net/docs/react-native-1
Use the `payWithGeidea` function from the SDK to start a payment process. Provide necessary details like session ID, merchant ID, language, environment, region, and branding colors. Handle the result status to determine payment success or cancellation.
```typescript
import { payWithGeidea } from '@geidea/payment-sdk-react-native';
import type { GeideaResult } from '@geidea/payment-sdk-react-native';
const primaryColor = '#fcba03';
const secondaryColor = '#03c6fc';
const merchantLogo = 'chalhoub';
async function startPayment() {
const result: GeideaResult = await payWithGeidea({
sessionId: 'YOUR_SESSION_ID',
merchantId: 'YOUR_APPLE_PAY_MERCHANT_ID',
language: 'en',
environment: 'prod',
region: 'egypt',
primaryColor,
secondaryColor,
merchantLogo,
});
if (result.status === 'completed') {
console.log('Payment successful:', result.result);
} else if (result.status === 'canceled') {
console.log('Payment canceled');
}
}
```
--------------------------------
### Authenticate Payer Response Example
Source: https://docs.geidea.net/docs/authenticate-payer-v2
This is an example of a successful response from the Authenticate Payer API. It includes details for handling 3D Secure challenges if required by the gateway decision.
```json
{
"orderId": "8362c98b-967b-4426-0496-08dc400ca7ad",
"threeDSecureId": "e4fcb9fe-c4c0-4449-adbb-08dc400ca7dc",
"htmlBodyContent": "
",
"gatewayDecision": "ContinueToPay",
"responseMessage": "Success",
"detailedResponseMessage": "The operation was successful",
"language": "en",
"responseCode": "000",
"detailedResponseCode": "000"
}
```
--------------------------------
### Start Payment with Fragment Integration
Source: https://docs.geidea.net/docs/android-sdk
Integrate the payment flow as a Fragment within an existing screen. Specify the fragment manager and container ID for embedding the payment form.
```kotlin
GDPaymentSDK.sharedInstance().start(
configuration,
context = this@MainActivity,
presentationStyle = SDKPresentationStyle.Present(
presentationType = SDKPresentationStyle.Present.PresentationType.Fragment(
fragmentManager = supportFragmentManager,
containerId = R.id.payment_container
)
),
)
```
--------------------------------
### Get Subscription
Source: https://docs.geidea.net/docs/get-subscription-1
Fetches detailed information for a given subscription ID.
```APIDOC
## GET /subscriptions/api/v1/direct/subscription/{subscriptionid}
### Description
Retrieves comprehensive information about a specific subscription.
### Method
GET
### Endpoint
/subscriptions/api/v1/direct/subscription/{subscriptionid}
### Parameters
#### Path Parameters
- **subscriptionid** (string) - Required - The id generated on the subscription creation.
### Request Example
```curl
curl --request GET \
--url https://api.merchant.geidea.net/subscriptions/api/v1/direct/subscription/8a055aa4-13d9-4f74-421d-08dc3cbb381c \
--header 'accept: application/json' \
--header 'authorization: Basic YTA4N2Y0Y2EtOTg5MC00MDdiLTljMmYtNzYzMDgzNmNjMDIwOjI2ZDMxOTE3LTcxNWUtNDhhYy1iMDcyLWRhOTczODAxNmFmNQ==' \
--data-raw '{
"signature":"1KeVT7QumxpsWY8SnWN8WzTBlKdwz1EGBaANIEoh5mg="
}'
```
### Response
#### Success Response (200)
- **field1** (type) - Description
#### Response Example
```json
#TODO
```
```
--------------------------------
### Initiate Apple Pay Flow in Swift
Source: https://docs.geidea.net/docs/apple-pay-direct-api
Use this code to set up and present the Apple Pay payment sheet. Ensure supported networks and merchant capabilities are correctly configured. The completion handler must be called exactly once.
```swift
import PassKit
import UIKit
final class CheckoutCoordinator: NSObject {
private var authController: PKPaymentAuthorizationController?
func beginApplePayFlow(total: Decimal) {
let networks: [PKPaymentNetwork] = [.visa, .masterCard, .amex, .mada]
guard PKPaymentAuthorizationController.canMakePayments(usingNetworks: networks) else {
return
}
let req = PKPaymentRequest()
req.merchantIdentifier = "merchant.com.example.app"
req.countryCode = "SA"
req.currencyCode = "SAR"
req.supportedNetworks = networks
req.merchantCapabilities = [.capability3DS]
let amount = NSDecimalNumber(decimal: (total as NSDecimalNumber.DecimalType))
req.paymentSummaryItems = [
PKPaymentSummaryItem(label: "Order Total", amount: amount)
]
let controller = PKPaymentAuthorizationController(paymentRequest: req)
controller.delegate = self
self.authController = controller
controller.present { presented in
if !presented {
}
}
}
}
extension CheckoutCoordinator: PKPaymentAuthorizationControllerDelegate {
func paymentAuthorizationController(_ controller: PKPaymentAuthorizationController,
didAuthorizePayment payment: PKPayment,
completion: @escaping (PKPaymentAuthorizationResult) -> Void) {
do {
let tokenData = payment.token.paymentData
let tokenJSON = try JSONSerialization.jsonObject(with: tokenData, options: [])
let payload: [String: Any] = [
"applePayToken": tokenJSON,
"amount": "100.00",
"currency": "SAR",
"merchantReference": "ORDER-12345"
]
sendToBackend(json: payload) { ok in
completion(PKPaymentAuthorizationResult(status: ok ? .success : .failure, errors: nil))
}
} catch {
completion(PKPaymentAuthorizationResult(status: .failure, errors: nil))
}
}
func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) {
controller.dismiss(completion: nil)
self.authController = nil
}
private func sendToBackend(json: [String: Any], completion: @escaping (Bool) -> Void) {
guard let url = URL(string: "https://api.your-backend.example/payments/applepay") else {
completion(false); return
}
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = try? JSONSerialization.data(withJSONObject: json, options: [])
URLSession.shared.dataTask(with: req) { _, resp, err in
guard err == nil,
let http = resp as? HTTPURLResponse,
200..<300 ~= http.statusCode else { completion(false); return }
completion(True)
}.resume()
}
}
```