2. Plan
• Current status of payments in Drupal 8.
• Common developers mistakes.
• Drupal commerce 2.x payment
• Payment
• Payment offsite API
3. About me
• More than 100 implemented drupal projects.
• 15 years experience Backend developer
• 5 years experience Drupal developer
• Maintainer of commerce interkassa
• Maintainer of Payment platon
• Maintainer of commerce probokassa
• Maintainer of Payment offsite API
10. Known contrib issues
• Partitional payment not supported
• Support only one payment instance per payment module
• Not fixed result pages
• Success URL: checkout/ORDER_ID/payment/return/ORDER_PAYMENT_REDIRECT_KEY
• Fail URL: checkout/ORDER_ID/payment/back/ORDER_PAYMENT_REDIRECT_KEY
• Payment transaction created only on success
• Send order ID to payment system
• Custom result urls used
11. Drupal commerce 2.x plan
- The payment gateway config entity + UI
- The payment gateway plugin type
- The payment type YAML plugin
- The credit_card payment type
- The payment method content entity (for storing tokenized payment
information), which uses the payment types as bundles
- The payment content entity, which uses payment types as bundles
A payment would have a workflow:
New -> Pending -> Complete -> Cancelled | (Partially) Refunded.
https://www.drupal.org/node/2711013
17. Payment result pages
Payment module requirements
•Implement
• Routing
• Result pages controller
• Access controller
•Fallback support (optional)
Payment Offsite API module
PaymentMethod plugin
•Implement
• getResultPages()
• get<Result>Content()
• getSignature() (simple)
•Fallback call supports per result
page using getResultPages()
18. Payment IPN callback
Payment
system
IPN callback
Call IPN
Access check
Call IPN
Validate
Call IPN
Execute
Set order
internal status
according to
status mapping
Payment method plugin + configuration
19. Payment IPN callback
Payment module require
Implement
•Routing
•IPN controller
•IPN validator
•Access controller
Payment Offsite API module
Implement in PaymentMethod plugin
•ipnExecute()
•ipnValidate()
Also you could extend PaymentMethodOffsiteSimple and use
•validateEmpty()
•validateRequiredKeys()
•validateMerchant()
•validateSignature()
•validateTransactionId()
•validateAmount()
You must implement if going to use default validators:
•getMerchantIdName()
•getTransactionIdName()
•getAmountName()
•getSignatureName()
•getRequiredKeys()
20. Payment offsite API Interface
interface PaymentMethodOffsiteInterface {
public function ipnExecute();
public function ipnValidate();
public function getResultPages();
public function paymentForm();
public function isConfigured();
}
21. Payment offsite API
Simple Interface
interface PaymentMethodOffsiteSimpleInterface extends PaymentMethodOffsiteInterface {
const SIGN_IN = 'IN';
const SIGN_OUT = 'OUT';
public function getSignature($signature_type = self::SIGN_IN);
public function getMerchantIdName();
public function getTransactionIdName();
public function getAmountName();
public function getSignatureName();
public function getRequiredKeys();
}
22. Payment offsite API
• Fully compatible with Payment module
• Fallback mode support
• Multiple payment instances support
• Simplify payment method creation
• IPN and result pages callbacks
• Payment form
@Todo provide integration to commerce_payment
@see https://www.drupal.org/sandbox/niko/2685859