Credit Card Flow | Magento Braintree | Paypal Payflow Pro | Pk Magento 2

Credit Card Flow | Magento Braintree | Paypal Payflow Pro 

 

  1. Users add products in cart then move on checkout. 

  1. User full fill all required fields then select shipping method and payment method 

  1. If payment is selected as Braintree credit card. Then user enters card details 

  1. Then Magento to validate all other field data like billing address, shipping address and shipping method etc.  

 

  1. Then User clicks on place order button.  

 

  1. Magento sends validation request to Braintree with Braintree (Merchant) credentials and Card Details. 

  1. After successful validation, Braintree sends back response token to Magento on real-time. 

  1. Magento now sends “Token, customer details & order details” to Braintree. 

*details like customer billing & shipping address, item total, discount., order ID etc. 

  1. Braintree validates the card details through token and charge the amount to customer and sends back response to Magento in real-time with below responses 

  1. Success – Response contains Success array  

  1. False– Response contains the Error details 

  1. Null – Blank Array with no details  

“Null” response is not handled currently which needs to be solutionized 

 

 

 

 

Request example in json. 

 

'request' =>  

  array ( 

    'customer' =>  

    array ( 

      'firstName' => 'xxrri-xxynn', 

      'lastName' => 'McKillop', 

      'company' => '', 

      'phone' => 'xxxxxxx', 

      'email' => 'xxxx@outlook.com', 

    ), 

    'amount' => '189.99', 

    'paymentMethodNonce' => 'tokencc_bd_wyn4wk_657vx3_gfkg9s_t85xkq_vr3', 

    'orderId' => 'xx171241xxx38921', 

    'channel' => 'MagxxxxxeneBT', 

    'options' =>  

    array ( 

      'skipAdvancedFraudChecking' => false, 

      'storeInVaultOnSuccess' => true, 

      'submitForSettlement' => true, 

    ), 

    'customFields' =>  

    array ( 

    ), 

    'billing' =>  

    array ( 

      'firstName' => 'Terri-Lynn', 

      'lastName' => 'McKillop', 

      'company' => '', 

      'streetAddress' => '724 xxxtherine Street', 

      'extendedAddress' => '', 

      'locality' => 'thunder bay', 

      'region' => 'ON', 

      'postalCode' => 'p7xxx', 

      'countryCodeAlpha2' => 'CA', 

    ), 

    'shipping' =>  

    array ( 

      'firstName' => 'Terri-Lynn', 

      'lastName' => 'McKillop', 

      'company' => NULL, 

      'streetAddress' => '724 Catherine Street', 

      'extendedAddress' => '', 

      'locality' => 'thunder bay', 

      'region' => 'ON', 

      'postalCode' => 'p7e1l5', 

      'countryCodeAlpha2' => 'CA', 

      'countryCodeAlpha3' => 'CAN', 

    ), 

    'purchaseOrderNumber' => 'xxx', 

    'taxAmount' => '21.86', 

    'discountAmount' => '137.57',     

           

 

Response sample 

 

 

Null 

 

Failed 

 

 

Response sample  

'client' => 'PayPal\\Braintree\\Gateway\\Http\\Client\\TransactionSale', 

  'response' =>  

  array ( 

    'success' => true, 

    '' . "\0" . 'Braintree\\Result\\Successful' . "\0" . '_returnObjectNames' =>  

    array ( 

      0 => 'transaction', 

    ), 

    '' . "\0" . '*' . "\0" . '_attributes' =>  

    array ( 

    ), 

    'transaction' =>  

    Braintree\Transaction::__set_state(array( 

       '_attributes' =>  

      array ( 

        'id' => 'xxxx', 

        'status' => 'submitted_for_settlement', 

        'type' => 'sale', 

        'currencyIsoCode' => 'USD', 

        'amount' => '19.95', 

        'amountRequested' => '19.95', 

        'merchantAccountId' => 'xxxxxx', 

        'subMerchantAccountId' => NULL, 

        'masterMerchantAccountId' => NULL, 

        'orderId' => 'xxxxx', 

        'createdAt' =>  

        DateTime::__set_state(array( 

           'date' => '2022-09-02 18:45:31.000000', 

           'timezone_type' => 3, 

           'timezone' => 'UTC', 

        )), 

        'updatedAt' =>  

        DateTime::__set_state(array( 

           'date' => '2022-09-02 18:45:32.000000', 

           'timezone_type' => 3, 

           'timezone' => 'UTC', 

        )), 

        'customer' =>  

        array ( 

          'id' => 'xxxx', 

          'firstName' => 'xxxx', 

          'lastName' => 'Wasserman', 

          'company' => NULL, 

          'email' => 'xxxxx@gmail.com', 

          'website' => NULL, 

          'phone' => 'xxxxxxx', 

          'fax' => NULL, 

          'globalId' => 'xxxxxx', 

        ), 

        'billing' =>  

        array ( 

          'id' => NULL, 

          'firstName' => 'Amanda', 

          'lastName' => 'xxxxx', 

          'company' => NULL, 

          'streetAddress' => '1008 xxxx Ave', 

          'extendedAddress' => NULL, 

          'locality' => 'Ann Arbor', 

          'region' => 'MI', 

          'postalCode' => 'xxx', 

          'countryName' => 'United States of America', 

          'countryCodeAlpha2' => 'US', 

          'countryCodeAlpha3' => 'USA', 

          'countryCodeNumeric' => '840', 

        ), 

        'refundId' => NULL, 

        'refundIds' =>  

        array ( 

        ), 

        'refundedTransactionId' => NULL, 

        'partialSettlementTransactionIds' =>  

        array ( 

        ), 

        'authorizedTransactionId' => NULL, 

        'settlementBatchId' => NULL, 

        'shipping' =>  

        array ( 

          'id' => NULL, 

          'firstName' => 'Amanda', 

          'lastName' => 'Wasserman', 

          'company' => NULL, 

          'streetAddress' => '1008 Oakland Ave', 

          'extendedAddress' => NULL, 

          'locality' => 'Ann Arbor', 

          'region' => 'MI', 

          'postalCode' => '48104', 

          'countryName' => 'United States of America', 

          'countryCodeAlpha2' => 'US', 

          'countryCodeAlpha3' => 'USA', 

          'countryCodeNumeric' => '840', 

        ), 

        'customFields' => NULL, 

        'accountFundingTransaction' => false, 

        'avsErrorResponseCode' => NULL, 

        'avsPostalCodeResponseCode' => 'N', 

        'avsStreetAddressResponseCode' => 'N', 

        'cvvResponseCode' => 'M', 

        'gatewayRejectionReason' => NULL, 

        'processorAuthorizationCode' => '006390', 

        'processorResponseCode' => '1000', 

        'processorResponseText' => 'Approved', 

        'additionalProcessorResponse' => NULL, 

        'voiceReferralNumber' => NULL, 

        'purchaseOrderNumber' => 'xxxx', 

        'taxAmount' => '0.00', 

        'taxExempt' => false, 

        'scaExemptionRequested' => NULL, 

        'processedWithNetworkToken' => false, 

        'creditCard' =>  

        array ( 

          'token' => 'xxxxx', 

          'bin' => '436618', 

          'last4' => '6871', 

          'cardType' => 'Visa', 

          'expirationMonth' => '08', 

          'expirationYear' => '2026', 

          'customerLocation' => 'US', 

          'cardholderName' => NULL, 

          'imageUrl' => 'https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=production', 

          'prepaid' => 'No', 

          'healthcare' => 'No', 

          'debit' => 'Yes', 

          'durbinRegulated' => 'Yes', 

          'commercial' => 'Unknown', 

          'payroll' => 'No', 

          'issuingBank' => 'U.S. Bank National Association', 

          'countryOfIssuance' => 'USA', 

          'productId' => 'F', 

          'globalId' => 'xxxxx', 

          'accountType' => 'credit', 

          'uniqueNumberIdentifier' => 'xxxx', 

          'venmoSdk' => false, 

          'accountBalance' => NULL, 

        ), 

        'statusHistory' =>  

        array ( 

          0 =>  

          Braintree\Transaction\StatusDetails::__set_state(array( 

             '_attributes' =>  

            array ( 

              'timestamp' =>  

              DateTime::__set_state(array( 

                 'date' => '2022-09-02 18:45:31.000000', 

                 'timezone_type' => 3, 

                 'timezone' => 'UTC', 

              )), 

              'status' => 'authorized', 

              'amount' => '19.95', 

              'user' => 'vivyx_bt', 

              'transactionSource' => 'api', 

            ), 

          )), 

          1 =>  

          Braintree\Transaction\StatusDetails::__set_state(array( 

             '_attributes' =>  

            array ( 

              'timestamp' =>  

              DateTime::__set_state(array( 

                 'date' => '2022-09-02 18:45:31.000000', 

                 'timezone_type' => 3, 

                 'timezone' => 'UTC', 

              )), 

              'status' => 'submitted_for_settlement', 

              'amount' => '19.95', 

              'user' => 'vivyx_bt', 

              'transactionSource' => 'api', 

            ), 

          )), 

        ), 

        'planId' => NULL, 

        'subscriptionId' => NULL, 

        'subscription' =>  

        array ( 

          'billingPeriodEndDate' => NULL, 

          'billingPeriodStartDate' => NULL, 

        ), 

        'addOns' =>  

        array ( 

        ), 

        'discounts' =>  

        array ( 

        ), 

        'descriptor' =>  

        Braintree\Descriptor::__set_state(array( 

           '_attributes' =>  

          array ( 

            'name' => NULL, 

            'phone' => NULL, 

            'url' => NULL, 

          ), 

        )), 

        'recurring' => false, 

        'channel' => 'Magento2GeneBT', 

        'serviceFeeAmount' => NULL, 

        'escrowStatus' => NULL, 

        'disbursementDetails' =>  

        Braintree\DisbursementDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'disbursementDate' => NULL, 

            'settlementAmount' => NULL, 

            'settlementCurrencyIsoCode' => NULL, 

            'settlementCurrencyExchangeRate' => NULL, 

            'settlementBaseCurrencyExchangeRate' => NULL, 

            'fundsHeld' => NULL, 

            'success' => NULL, 

          ), 

        )), 

        'disputes' =>  

        array ( 

        ), 

        'achReturnResponses' =>  

        array ( 

        ), 

        'authorizationAdjustments' =>  

        array ( 

        ), 

        'paymentInstrumentType' => 'credit_card', 

        'processorSettlementResponseCode' => NULL, 

        'processorSettlementResponseText' => NULL, 

        'networkResponseCode' => '00', 

        'networkResponseText' => 'Successful approval/completion or V.I.P. PIN verification is successful', 

        'threeDSecureInfo' => NULL, 

        'shipsFromPostalCode' => '30046', 

        'shippingAmount' => '0.00', 

        'discountAmount' => '0.00', 

        'networkTransactionId' => '462245675316191', 

        'processorResponseType' => 'approved', 

        'authorizationExpiresAt' =>  

        DateTime::__set_state(array( 

           'date' => '2022-09-09 18:45:31.000000', 

           'timezone_type' => 3, 

           'timezone' => 'UTC', 

        )), 

        'retryIds' =>  

        array ( 

        ), 

        'retriedTransactionId' => NULL, 

        'refundGlobalIds' =>  

        array ( 

        ), 

        'partialSettlementTransactionGlobalIds' =>  

        array ( 

        ), 

        'refundedTransactionGlobalId' => NULL, 

        'authorizedTransactionGlobalId' => NULL, 

        'globalId' => 'xxxxx', 

        'retryGlobalIds' =>  

        array ( 

        ), 

        'retriedTransactionGlobalId' => NULL, 

        'retrievalReferenceNumber' => NULL, 

        'installmentCount' => NULL, 

        'installments' =>  

        array ( 

        ), 

        'refundedInstallments' =>  

        array ( 

        ), 

        'responseEmvData' => NULL, 

        'acquirerReferenceNumber' => NULL, 

        'merchantIdentificationNumber' => 'xxxxx', 

        'terminalIdentificationNumber' => 'xxxxx', 

        'merchantName' => 'VIVYX PRINTING LLC', 

        'merchantAddress' =>  

        array ( 

          'streetAddress' => NULL, 

          'locality' => 'Phoenix', 

          'region' => 'AZ', 

          'postalCode' => '85034', 

          'phone' => '6786503559', 

        ), 

        'pinVerified' => false, 

        'debitNetwork' => NULL, 

        'processingMode' => NULL, 

        'paymentReceipt' =>  

        array ( 

          'id' => 'dxzfyakj', 

          'globalId' => 'dHJhbnNhY3Rpb25fZHh6Znlha2o', 

          'amount' => '19.95', 

          'currencyIsoCode' => 'USD', 

          'processorResponseCode' => '1000', 

          'processorResponseText' => 'Approved', 

          'processorAuthorizationCode' => '006390', 

          'merchantName' => 'VIVYX PRINTING LLC', 

          'merchantAddress' =>  

          array ( 

            'streetAddress' => NULL, 

            'locality' => 'Phoenix', 

            'region' => 'AZ', 

            'postalCode' => '85034', 

            'phone' => '6786503559', 

          ), 

          'merchantIdentificationNumber' => '4454xxxx96100998', 

          'terminalIdentificationNumber' => '00000001', 

          'type' => 'sale', 

          'pinVerified' => false, 

          'processingMode' => NULL, 

          'networkIdentificationCode' => NULL, 

          'cardType' => 'Visa', 

          'cardLast4' => '6871', 

          'accountBalance' => NULL, 

        ), 

        'creditCardDetails' =>  

        Braintree\Transaction\CreditCardDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'token' => '9cjbcfz', 

            'bin' => '436618', 

            'last4' => '6871', 

            'cardType' => 'Visa', 

            'expirationMonth' => '08', 

            'expirationYear' => '2026', 

            'customerLocation' => 'US', 

            'cardholderName' => NULL, 

            'imageUrl' => 'https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=production', 

            'prepaid' => 'No', 

            'healthcare' => 'No', 

            'debit' => 'Yes', 

            'durbinRegulated' => 'Yes', 

            'commercial' => 'Unknown', 

            'payroll' => 'No', 

            'issuingBank' => 'U.S. Bank National Association', 

            'countryOfIssuance' => 'USA', 

            'productId' => 'F', 

            'globalId' => 'cGF5bWVudG1ldGhvZF9jY185Y2piY2Z6', 

            'accountType' => 'credit', 

            'uniqueNumberIdentifier' => 'a5595b292d9ea1e711b4808e3677e4b2', 

            'venmoSdk' => false, 

            'accountBalance' => NULL, 

            'expirationDate' => '08/2026', 

            'maskedNumber' => '436618******6871', 

          ), 

        )), 

        'customerDetails' =>  

        Braintree\Transaction\CustomerDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'id' => 'ccg854cb', 

            'firstName' => 'Amanda', 

            'lastName' => 'Wasserman', 

            'company' => NULL, 

            'email' => 'awwasserman@gmail.com', 

            'website' => NULL, 

            'phone' => '8589253310', 

            'fax' => NULL, 

            'globalId' => 'Y3VzdG9tZXJfY2NnODU0Y2I', 

          ), 

        )), 

        'billingDetails' =>  

        Braintree\Transaction\AddressDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'id' => NULL, 

            'firstName' => 'Amanda', 

            'lastName' => 'Wasserman', 

            'company' => NULL, 

            'streetAddress' => '1008 Oakland Ave', 

            'extendedAddress' => NULL, 

            'locality' => 'Ann Arbor', 

            'region' => 'MI', 

            'postalCode' => '48104', 

            'countryName' => 'United States of America', 

            'countryCodeAlpha2' => 'US', 

            'countryCodeAlpha3' => 'USA', 

            'countryCodeNumeric' => '840', 

          ), 

        )), 

        'shippingDetails' =>  

        Braintree\Transaction\AddressDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'id' => NULL, 

            'firstName' => 'Amanda', 

            'lastName' => 'Wasserman', 

            'company' => NULL, 

            'streetAddress' => '1008 Oakland Ave', 

            'extendedAddress' => NULL, 

            'locality' => 'Ann Arbor', 

            'region' => 'MI', 

            'postalCode' => '48104', 

            'countryName' => 'United States of America', 

            'countryCodeAlpha2' => 'US', 

            'countryCodeAlpha3' => 'USA', 

            'countryCodeNumeric' => '840', 

          ), 

        )), 

        'subscriptionDetails' =>  

        Braintree\Transaction\SubscriptionDetails::__set_state(array( 

           '_attributes' =>  

          array ( 

            'billingPeriodEndDate' => NULL, 

            'billingPeriodStartDate' => NULL, 

          ), 

        )), 

      ), 

    )), 

  ), 

) [] [] 

 

 

 

  1. In case user selects “PayPal” as payment method and places order, then 

  1. It redirects on a controller and generate a redirect URL of Paypal which contains all information regarding payment & redirect URL.   

  1. user gets redirected to “PayPal” website. 

  1. After making payment on “PayPal” website, user is redirected back to Magento website using the redirect URL which also contains the response success and failed.   

  1. Magento will now generate order according to response received 

  1.  If payment is successful, then order will get generated  

  1.  In case payment is failed user gets redirected to cart page as received the failure object on the redirect URL response. 

 

 

 

How to check if Magento is running in production mode or developer mode

If you want to know. your Magento 2 website is running on which environment you can run below command on terminal and very easily you can kn...

Popular Posts

Posts