Skip to content

Commit

Permalink
Add guidline
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudElmoghazy committed May 10, 2022
1 parent 954ef2a commit 088a591
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ npm install react-native-payfort
## Usage

```js
import { multiply } from "react-native-payfort";
import { Pay } from "react-native-payfort";

// ...

const result = await multiply(3, 7);
const result = Pay({
isLive: true | false,
device_fingerprint: "{Device UDID}";
command: "PURCHASE" | "AUTHORIZATION",
currency: "{SAR | USD | etc...}";
amount: "{1000}";
sdk_token: "{SDK token} you can get it from api request check the example";
customer_email: "{customer email}";
merchant_reference: "{Order id}";
customer_ip: "{User customer IP}";
language: "{en | ar}";
merchant_extra?: "{This is order...}";
})
```

## Contributing
Expand Down
33 changes: 24 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@ const LINKING_ERROR =
const Payfort = NativeModules.Payfort
? NativeModules.Payfort
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

export function multiply(a: number, b: number): Promise<number> {
return Payfort.multiply(a, b);

interface Props {
isLive: boolean;
device_fingerprint: string;
command: "PURCHASE" | "AUTHORIZATION",
currency: string;
amount: string;
sdk_token: string;
customer_email: string;
merchant_reference: string;
customer_ip: string;
language: string;
merchant_extra?: string;
}

export function Pay(data: Props, successCallback: () => void, failCallback: () => void) {
return Payfort.Pay(data, successCallback, failCallback);
}

0 comments on commit 088a591

Please sign in to comment.