superbrave/

omnipay-docdata-payments

支持Omnipay支付处理库的Docdata Payments

3.2.3 2020-04-28 06:15 UTC

This package is auto-updated.

Last update: 2024-09-19 22:09:55 UTC


README

支持Omnipay支付处理库的Docdata/CM Payments。

本包针对Docdata Payments(现CM payments)中的Webdirect方法处理订单。

授权数据

通用

public function getAuthorizeData() {
    $card = new CreditCard(); // Omnipay CC model
    $card->setTitle(null);
    $card->setFirstName($invoice->getCustomerFirstname());
    $card->setLastName($invoice->getCustomerLastname());
    $card->setEmail($invoice->getCustomerEmailAddress());
    $card->setGender('U'); // U, F, M
    $card->setPhone(null);
    $card->setBillingFirstName($invoice->getCustomerFirstname());
    $card->setBillingLastName($invoice->getCustomerLastname());
    $card->setBillingAddress1($formatedAddress['street']);
    $card->setBillingAddress2($formatedAddress['houseNumber']);
    $card->setBillingPostcode($address->getPostalCode());
    $card->setBillingCity(mb_substr($address->getCity(), 0, 35)); // max 35
    $card->setBillingCountry(strtoupper($address->getCountry()));
    $card->setBillingTitle(null);
    $card->setBillingState(null);
    
    $data = [
        'description' => sprintf('Invoice #%s', $invoice->getReference()),
        'paymentProfile' => $this->getDocDataPaymentProfile(), // set in Docdata backoffice
        'paymentDays' => self::DOCDATA_INVOICE_VALIDITY_DAYS, // own choice
        'transactionId' => sprintf('%s _ %s', $invoice->getReference(), Uuid::uuid4()), // shown to customer. Needs to be unique
        'currency' => 'EUR', // capitalized
        'amount' => 100,
        'shopperId' => $invoice->getCustomerReference(),
        'language' => 'en', // lowercase
        'card' => $card,
        'houseNumberAddition' => $formatedAddress['houseNumberAddition'],
        'paymentMethod' => 'IDEAL',
    ];
    
    /* Payment methods (defined by docdata)
     * https://www.cmpayments.com/file_uploads/API_Integration_Manual.pdf #figure 9
     *
     * BanContact => 'MISTERCASH'
     * Bank_transfer => 'BANK_TRANSFER'
     * Elv => 'ELV'
     * Eps => 'EPS'
     * Giropay => 'GIROPAY'
     * Ideal => 'IDEAL'
     * Sofort => 'SOFORT_UEBERWEISUNG'
     */
     
     return $data;
 }

理想

理想有一些特殊之处。可以通过以下方式将发行者添加到getAuthorizeData方法中

    $data['paymentInputType'] = 'iDealPaymentInput';
    $data['paymentInput'] = [
        'issuerId' => $request['issuerId'],
    ];

IssuerId由Docdata设置,并在实现手册中没有记录。

      iban => docdata code  // bank name
----------------------------------------------------
'ABNANL2A' => 'ABNAMRO'     // ABN AMRO
'ASNBNL21' => 'ASN'         // ASN
'BUNQNL2A' => 'BUNQ'        // Bunq
'HANDNL2A' => 'HAND'        // Svenska Handelsbanken
'INGBNL2A' => 'ING'         // ING
'KNABNL2H' => 'KNAB'        // Knab
'MOYONL21' => 'MOYO'        // MoneYou
'RABONL2U' => 'RABO'        // RABO
'RBRBNL21' => 'REGIOBANK'   // Regiobank
'SNSBNL2A' => 'SNS'         // SNS
'TRIONL2U' => 'TRIODOS'     // Triodos
'FVLBNL22' => 'VANLANSCHOT' // Van Lanschot

完整授权

某些支付方式需要在授权调用中发送大量信息,因此获取相同的数据并添加交易参考是最高效的方法。

public function getCompleteAuthorizeData(): array {
    $data = $this->getAuthorizeData();
    $data['transactionReference'] = $paymentTransaction->getReference();
    $data['authorizationResultType'] = 'iDealAuthorizationResult'; // differs per payment method
    $data['authorizationResult'] = []; // same here
    return $data;
}

信用卡

如果你不想存储或处理用户输入(提示:不要处理),Docdata可以处理信用卡数据。在包中处理此功能时,应使用OnePageCheckoutGateway。这样代码仍然会在docdata中创建订单并尝试捕获,但不会要求你发送持卡人、信用卡号等。

Webdirect流程使用WebdirectGateway。