Skip to content

Commit

Permalink
feat: Update iOS Library
Browse files Browse the repository at this point in the history
Update iOS library so that it includes Stripe.
Add payment gateway configurations to Hook.
  • Loading branch information
OS-ricardomoreirasilva committed Dec 13, 2022
1 parent 1c7c0f2 commit 70fe443
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
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
14 changes: 14 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@
<array>APPLE_PAY_BILLING_SUPPORTED_CONTACTS</array>
</config-file>

<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"/>

Expand All @@ -109,6 +122,7 @@
<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

0 comments on commit 70fe443

Please sign in to comment.