Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMET-2078 && RMET-2095 ::: iOS ::: Using Stripe to Process End-2-End Payments #19

Merged
merged 2 commits into from
Dec 13, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The changes documented here do not include those from the original repository.

## [Unreleased]

### 2022-12-02
- Chore: [iOS] Remove all the `OSPaymentsLib` files and replace them by the new `OSPaymentsPluginLib` pod.
- Feat: [iOS] Update hook so that it checks if Stripe's is configured as the Payment Service Provider and update `plist` file accordingly (https://outsystemsrd.atlassian.net/browse/RMET-2078).

## [Version 1.0.1]

### 2022-11-08
Expand Down
38 changes: 37 additions & 1 deletion hooks/ios/iOSCopyPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = function (context) {
var payment_supported_card_countries = [];
var shipping_supported_contacts = [];
var billing_supported_contacts = [];
var payment_gateway = "";
var payment_request_url = "";
var stripe_publishable_key = "";

var appNamePath = path.join(projectRoot, 'config.xml');
var appNameParser = new ConfigParser(appNamePath);
Expand Down Expand Up @@ -71,7 +74,27 @@ module.exports = function (context) {

shipping_supported_contacts = configItem.shipping_supported_contacts;
billing_supported_contacts = configItem.billing_supported_contacts;
payment_supported_card_countries = configItem.payment_supported_card_countries;
payment_supported_card_countries = configItem.payment_supported_card_countries;

if (configItem.tokenization != null) {
if (configItem.tokenization.gateway != null && configItem.tokenization.gateway !== "") {
payment_gateway = configItem.tokenization.gateway;
} else {
error_list.push('Payment Gateway Name');
}

if (configItem.tokenization.requestURL != null && configItem.tokenization.requestURL !== "") {
payment_request_url = configItem.tokenization.requestURL;
} else {
error_list.push('Payment Request URL');
}

if (configItem.tokenization.stripePublishableKey != null && configItem.tokenization.stripePublishableKey !== "") {
stripe_publishable_key = configItem.tokenization.stripePublishableKey;
} else if (payment_gateway.toLowerCase() === "stripe") {
error_list.push('Stripe\'s Publishable Key');
}
}

if (error_list.length > 0) {
throw new Error("Configuration is missing the following fields: " + error_list);
Expand All @@ -95,6 +118,19 @@ module.exports = function (context) {
infoPlist['ApplePayPaymentSupportedCardCountries'] = payment_supported_card_countries;
infoPlist['ApplePayShippingSupportedContacts'] = shipping_supported_contacts;
infoPlist['ApplePayBillingSupportedContacts'] = billing_supported_contacts;
if (payment_gateway !== "") {
infoPlist['ApplePayPaymentGateway']['ApplePayPaymentGatewayName'] = payment_gateway;

if (payment_request_url !== "") {
infoPlist['ApplePayPaymentGateway']['ApplePayRequestURL'] = payment_request_url;
}

if (stripe_publishable_key !== "") {
infoPlist['ApplePayPaymentGateway']['ApplePayStripePublishableKey'] = stripe_publishable_key;
}
} else {
delete infoPlist['ApplePayPaymentGateway'];
}

fs.writeFileSync(infoPlistPath, plist.build(infoPlist, { indent: '\t' }));

Expand Down
41 changes: 15 additions & 26 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,20 @@
<array>APPLE_PAY_BILLING_SUPPORTED_CONTACTS</array>
</config-file>

<!-- iOS Source Files -->
<source-file src="src/ios/Error/OSPMTError.swift" />

<source-file src="src/ios/Extensions/PKContactField+Adapter.swift" />
<source-file src="src/ios/Extensions/PKMerchantCapability+Adapter.swift" />
<source-file src="src/ios/Extensions/PKPassLibrary+Adapter.swift" />
<source-file src="src/ios/Extensions/PKPayment+Adapter.swift" />
<source-file src="src/ios/Extensions/PKPaymentAuthorizationController+Adapter.swift" />
<source-file src="src/ios/Extensions/PKPaymentNetwork+Adapter.swift" />

<source-file src="src/ios/Models/OSPMTAddressModel.swift" />
<source-file src="src/ios/Models/OSPMTConfigurationModel.swift" />
<source-file src="src/ios/Models/OSPMTContactInfoModel.swift" />
<source-file src="src/ios/Models/OSPMTDataModel.swift" />
<source-file src="src/ios/Models/OSPMTDetailsModel.swift" />
<source-file src="src/ios/Models/OSPMTScopeModel.swift" />
<source-file src="src/ios/Models/OSPMTTokenInfoModel.swift" />

<source-file src="src/ios/Protocols/OSPMTActionDelegate.swift" />
<source-file src="src/ios/Protocols/OSPMTAvailabilityDelegate.swift" />
<source-file src="src/ios/Protocols/OSPMTCallbackDelegate.swift" />
<source-file src="src/ios/Protocols/OSPMTHandlerDelegate.swift" />
<source-file src="src/ios/Protocols/OSPMTRequestDelegate.swift" />

<source-file src="src/ios/OSPMTApplePayHandler.swift" />
<source-file src="src/ios/OSPMTPayments.swift" />
<config-file target="*-Info.plist" parent="ApplePayPaymentGateway">
<dict>
<key>ApplePayPaymentGatewayName</key>
<string>APPLE_PAY_PAYMENT_GATEWAY_NAME</string>

<key>ApplePayRequestURL</key>
<string>APPLE_PAY_PAYMENT_REQUEST_URL</string>

<key>ApplePayStripePublishableKey</key>
<string>APPLE_PAY_PAYMENT_STRIPE_PUBLISHABLE_KEY</string>
</dict>
</config-file>

<!-- iOS Source Files -->
<source-file src="src/ios/OSPayments.swift"/>

<podspec>
Expand All @@ -134,6 +121,8 @@
</config>
<pods use-frameworks="true">
<pod name="OSCommonPluginLib" spec="1.0.0" />
<!--pod name="OSPaymentsPluginLib" spec="1.1.0" /-->
<pod name="OSPaymentsPluginLib" git="https://github.com/OutSystems/OSPaymentsLib-iOS.git" branch="development" />
</pods>
</podspec>

Expand Down
33 changes: 0 additions & 33 deletions src/ios/Error/OSPMTError.swift

This file was deleted.

21 changes: 0 additions & 21 deletions src/ios/Extensions/PKContactField+Adapter.swift

This file was deleted.

21 changes: 0 additions & 21 deletions src/ios/Extensions/PKMerchantCapability+Adapter.swift

This file was deleted.

9 changes: 0 additions & 9 deletions src/ios/Extensions/PKPassLibrary+Adapter.swift

This file was deleted.

93 changes: 0 additions & 93 deletions src/ios/Extensions/PKPayment+Adapter.swift

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions src/ios/Extensions/PKPaymentNetwork+Adapter.swift

This file was deleted.

Loading