Skip to content

Commit

Permalink
0.8 refactor (#250)
Browse files Browse the repository at this point in the history
* Add ios react native directory to header search paths (for pods)

* Make the ios search path recursive

* Bump to 0.7.2

* Update ReactNativePayments.m

Add support for MADA payment Saudi Arabia

* sync from react-native-easy-payments

* fixed this on the intents branch which isn’t quite ready yet, so I’ll commit here

* bugfix - incompatible export of PKPaymentButton

* update readme linking to iOS example project

* update organization name format

* delete old stripe project so people don't get confused

* also delete braintree, the iOS example project explains clearly how to use it

Co-authored-by: rkaartikeyan <rkaartikeyan@gmail.com>
  • Loading branch information
nabilfreeman and rkaartikeyan committed Nov 18, 2020
1 parent 8c36fad commit 8e160e7
Show file tree
Hide file tree
Showing 438 changed files with 12,094 additions and 29,685 deletions.
File renamed without changes.
65 changes: 65 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const IGNORE = 0;
const WARN = 1;
const ERROR = 2;

module.exports = {
"extends": "airbnb-base",
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"rules": {
"import/no-named-as-default-member": IGNORE,
"import/no-named-as-default": IGNORE,
"no-tabs": IGNORE,
"camelcase": IGNORE,
"no-console": IGNORE,
"no-param-reassign": IGNORE,
"import/prefer-default-export": IGNORE,
"consistent-return": IGNORE,
"max-len": IGNORE,
"no-continue": IGNORE,
'no-case-declarations': IGNORE,
"indent": [ERROR, 2, { "SwitchCase": 1, "VariableDeclarator": 1, "ignoredNodes": ["TemplateLiteral > *"] }],
"class-methods-use-this": IGNORE,
"no-restricted-syntax": IGNORE,
"prefer-template": IGNORE,
"no-plusplus": IGNORE,
"default-case": IGNORE,
"no-useless-constructor": IGNORE,
"jsx-a11y/accessible-emoji": IGNORE,
"no-use-before-define": IGNORE,
"curly": IGNORE,
"no-unused-expressions": [ERROR, { "allowShortCircuit": true }],
"prefer-destructuring": IGNORE,
"no-await-in-loop": IGNORE,
"global-require": IGNORE,
"func-names": IGNORE,
"linebreak-style": IGNORE,
"no-empty-function": IGNORE,
"no-labels": IGNORE,
"func-names": IGNORE,
"guard-for-in": IGNORE,
"radix": IGNORE,
"import/no-dynamic-require": IGNORE,
"quote-props": IGNORE,
"no-shadow": IGNORE,
"no-extra-label": IGNORE,
"arrow-parens": IGNORE,
"quotes": IGNORE,
"prefer-rest-params": IGNORE,
"no-nested-ternary": IGNORE,
"newline-per-chained-call": IGNORE,
"no-restricted-globals": IGNORE,
"dot-notation": IGNORE,
"arrow-body-style": IGNORE,
"no-loop-func": IGNORE,
"no-useless-escape": IGNORE,
"no-trailing-spaces": IGNORE,
"import/order": IGNORE,
"no-lonely-if": IGNORE,
},
"env": {
"jest": true
},
};
File renamed without changes.
46 changes: 44 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# System
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android
**/android/**/.idea
**/android/**/*.iml
**/android/**/gradlew*
**/android/**/*.properties
**/android/**/.gradle
**/android/**/gradle
**/android/**/.settings
**/android/**/.project

# npm
#
node_modules/
npm-debug.log
lerna-debug.log

# editors
#
jsconfig.json
.vscode/*

# project
#
coverage
File renamed without changes.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: node_js
node_js:
- "node"
env:
- TEST_DIR=packages/react-native-payments
script: cd $TEST_DIR && yarn && yarn test -- --verbose --coverage
script: npm test -- --verbose --coverage
127 changes: 121 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
# react-native-payments

[![Build Status](https://travis-ci.org/naoufal/react-native-payments.svg?branch=master)](https://travis-ci.org/naoufal/react-native-payments) [![Codeship Status for freeman-industries/react-native-payments](https://app.codeship.com/projects/d6d17e65-23f0-4154-b7ce-33ce59471b08/status?branch=master)](https://app.codeship.com/projects/418096)

Welcome to the best and most comprehensive library for integrating payments like Apple Pay and Google Pay into your React Native app.

This library is designed to be fully compatible with React Native 0.61 and onwards.

<div>
<img width="200px" src="https://user-images.githubusercontent.com/1627824/27758096-9fc6bf9a-5dc1-11e7-9d8f-b2d409302fc7.gif" />
<img width="200px" src="https://user-images.githubusercontent.com/1627824/30039983-d75d1b3e-91d8-11e7-9ac9-71d2ed12958c.png" />
</div>

# Installation

```
npm install --save react-native-payments
```

You'll need to autolink on each platform:

### Android

```
npx jetify
```

### iOS

```
cd ios
pod install
```

# Guides

## Example projects

- [iOS](https://github.com/freeman-industries/react-native-payments-example-ios)

## Live demo

For a step by step guide, check out this talk by @naoufal.

https://www.youtube.com/watch?v=XrmUuir9OHc&t=652

## API Spec

Down below we have a detailed specification for PaymentRequest and instructions for configuring Apple Pay and Google Pay, which is hopefully enough to get you started.

We also have some legacy example projects in the `examples` directory that will be rewritten soon and linked above.

Bear with us while we organize things a bit.

# Roadmap

## Completed

- Apple Pay Stripe

## Completed, untested

- Apple Pay Braintree
- Google Pay (Stripe, Braintree)
- Web

## In progress

- Stripe: Payment Intents (for SCA)

## Planned

- Tutorial docs

Naoufal, the original author of this library, has done a lot of the hard work integrating iOS, Android, Web platforms and Stripe and Braintree gateways.

The library has fallen out of regular maintenance and we're working to test and update all parts to be compatible for RN in the 2020s.

If you're feeling brave give the untested platforms a try and let us know how it worked.

# Contributors

Many people have contributed to the development of `react-native-payments` over time. The people below are currently available to help.

- [@nabilfreeman](https://github.com/nabilfreeman) ⚙️ ✏️
- [@runticle](https://github.com/runticle) ✏️

---
Merge PRs: ⚙️ | Review issues: ✏️

## Join us!

All contributions, big or small are welcomed.

For large PRs, please open an issue and have a discussion with us first before you dive in.

Our plan for this library is for it to be useful to all React Native developers so we want to architect it carefully.

# In the wild

These amazing people use `react-native-payments` in their projects.

- [LeSalon (@lesalonapp)](https://github.com/lesalonapp)

To add your organization, open a PR updating this list.

---

🚧

🚧

🚧

🚧

🚧

---

> This project is currently in __beta and APIs are subject to change.__
# React Native Payments
Expand All @@ -15,11 +135,6 @@ __Features__
- __Cross-platform__. Share payments code between your iOS, Android, and web apps.
- __Add-ons__. Easily enable support for Stripe or Braintree via add-ons.

<div>
<img width="280px" src="https://user-images.githubusercontent.com/1627824/27758096-9fc6bf9a-5dc1-11e7-9d8f-b2d409302fc7.gif" />
<img width="280px" src="https://user-images.githubusercontent.com/1627824/30039983-d75d1b3e-91d8-11e7-9ac9-71d2ed12958c.png" />
</div>

---

## Table of Contents
Expand Down Expand Up @@ -493,4 +608,4 @@ Here's a list of Payment Processors that you can enable via add-ons:
# License
Licensed under the MIT License, Copyright © 2017, [Naoufal Kadhom](https://twitter.com/naoufal).
See [LICENSE](https://github.com/naoufal/react-native-payments/blob/master/LICENSE) for more information.
See [LICENSE](https://github.com/naoufal/react-native-payments/blob/master/LICENSE) for more information.
27 changes: 27 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation 'com.google.android.gms:play-services-wallet:17.0.0'
implementation 'com.android.support:support-v4:23.0.1'
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ NativePayments

</details>

---

### show()
Displays Apple Pay/Android Pay to the user.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ - (NSArray *_Nonnull)getSupportedNetworksFromMethodData:(NSDictionary *_Nonnull)
if (iOSVersion >= 11) {
[supportedNetworksMapping setObject:PKPaymentNetworkCarteBancaires forKey:@"cartebancaires"];
}

if (iOSVersion >= 12.1) {
[supportedNetworksMapping setObject:PKPaymentNetworkMada forKey:@"mada"];
}

if (iOSVersion >= 12.1) {
[supportedNetworksMapping setObject:PKPaymentNetworkMada forKey:@"mada"];
Expand Down Expand Up @@ -417,6 +421,14 @@ - (void)handleUserAccept:(PKPayment *_Nonnull)payment
if (token) {
[paymentResponse setObject:token forKey:@"paymentToken"];
}

if (payment.billingContact) {
paymentResponse[@"billingContact"] = [self contactToString:payment.billingContact];
}

if (payment.shippingContact) {
paymentResponse[@"shippingContact"] = [self contactToString:payment.shippingContact];
}

if (payment.billingContact) {
paymentResponse[@"billingContact"] = [self contactToString:payment.billingContact];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)setCornerRadius:(CGFloat) value {

/**
* PKPayment button cannot be modified. Due to this limitation, we have to
* unmount existint button and create new one whenever it's style and/or
* unmount existing button and create a new one whenever its style and/or
* type is changed.
*/
- (void)setButtonType:(NSString *) buttonType andStyle:(NSString *) buttonStyle withRadius:(CGFloat) cornerRadius {
Expand Down Expand Up @@ -90,6 +90,9 @@ - (void)setButtonType:(NSString *) buttonType andStyle:(NSString *) buttonStyle
_button.layer.cornerRadius = cornerRadius;
_button.layer.masksToBounds = true;

_button.layer.cornerRadius = cornerRadius;
_button.layer.masksToBounds = true;

[self addSubview:_button];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const NativePayments: {
});
},

// TODO based on Naoufal's talk on YouTube the intention of canMakePayments is for it to work like this, so I'm thinking we can integrate Yegor's code into canMakePayments.
// NF 2020-11-18
canMakePaymentsUsingNetworks(usingNetworks: []) {
// IOS method to check that user has available cards at Apple Pay
// https://developer.apple.com/documentation/passkit/pkpaymentauthorizationviewcontroller/1616187-canmakepaymentsusingnetworks?language=occ
Expand Down
File renamed without changes.

0 comments on commit 8e160e7

Please sign in to comment.