Coin Purse for Craft CMS

Configuration

Settings live at Coin Purse → Settings. Anything that holds a secret or differs between environments accepts an environment variable, written $APPLE_PAY_MERCHANT_ID.

Gateway and driver

SettingDefaultWhat it does
GatewaynoneThe Commerce gateway express payments are charged through.
DriverAutomaticAutomatic uses Stripe's Express Checkout Element when the gateway is Stripe and speaks Apple Pay and Google Pay directly for everything else. You can force either.

Wallets

SettingDefault
Apple PayOn
Google PayOn
Link, PayPal, Amazon Pay, KlarnaOff
Let Stripe chooseOff

The second group only applies to the Stripe driver, whose Express Checkout Element can show them from the same button. They are off by default, because a PayPal button appearing on a product page nobody configured is a support ticket, not a feature.

With Let Stripe choose off, Coin Purse filters the element down to exactly the wallets switched on here. Turn it on to let Stripe decide per browser.

The sheet

SettingDefaultWhat it does
Merchant nameCraft's system nameThe name shown in the wallet sheet.
Merchant countryUSYour own country, as an ISO 3166-1 code. The wallets require it.
Allowed shipping countriesemptyCountries the wallet may ship to. Empty means wherever Commerce will.
Require nameOn
Require emailOnCommerce cannot complete an order without one, so this is always collected.
Require phoneOff

Button defaults

SettingDefaultOptions
Typebuydefault, buy, donate, book, checkout, pay
Themedarkdark, light, light-outline
Height48Pixels. Apple's guidelines allow 30 to 64.

Any of these can be overridden per button with the style option.

Apple Pay (direct driver)

Only needed when the gateway is not Stripe.

SettingWhat it is
Merchant IDe.g. merchant.com.example.store, from your Apple developer account
Certificate pathYour merchant identity certificate, as a PEM file
Key pathIts private key, as a PEM file
Key passwordIf the key has one
Domain associationThe contents of Apple's domain association file, or a path to it

Coin Purse serves the domain association file at /.well-known/apple-developer-merchantid-domain-association, so there is nothing to upload to your web root. Register the domain in your Apple developer account once it is live.

Keep the certificate and key outside the web root and point to them with environment variables.

Google Pay (direct driver)

SettingDefaultWhat it is
EnvironmentTESTTEST or PRODUCTION
Merchant IDnoneYour Google Pay merchant ID. Only needed in PRODUCTION.
GatewaynoneThe identifier Google should encrypt the token for, e.g. braintree
Gateway merchant IDnoneYour merchant ID at that gateway
Card networksAmex, Discover, Mastercard, Visa
Auth methodsPAN_ONLY, CRYPTOGRAM_3DS

Google Pay needs no certificate. Both wallets encrypt their token to the gateway, so it passes through your site opaque.

Wallet token

Gateway plugins disagree about what the field holding a wallet token is called.

SettingDefaultWhat it does
Token fieldemptyThe attribute on the gateway's payment form that receives the token. Empty means Coin Purse looks for a known name.
Token encodingrawraw, json or base64, whichever the gateway expects

Diagnostics reports which field it found. Name it explicitly if the guess is wrong.

Logging and sessions

SettingDefaultWhat it does
LoggingOnRecords each express step to Coin Purse → Log.
Log payloadsOffKeeps request and response bodies. They contain addresses, which is why this is off.
Log retention30 daysApplied by coinpurse/log/prune.
Session lifetime30 minutesHow long a wallet sheet may stay open before its session is refused.

Web Payments alias

SettingDefault
Register craft.webPayments.button()On

Lets templates written for ether/web-payments keep working. It is skipped automatically if that plugin is still installed.

Config file

Every setting can be set in config/coinpurse.php, which takes precedence over the control panel:

<?php

use craft\helpers\App;

return [
    '*' => [
        'buttonHeight' => 44,
        'allowedShippingCountries' => ['US', 'CA'],
    ],
    'production' => [
        'googlePayEnvironment' => 'PRODUCTION',
        'applePayMerchantId' => App::env('APPLE_PAY_MERCHANT_ID'),
        'applePayCertPath' => App::env('APPLE_PAY_CERT_PATH'),
        'applePayKeyPath' => App::env('APPLE_PAY_KEY_PATH'),
    ],
];