Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

Unable to complete checkout with credit card & bogus gateway - invalid credit card #1160

Closed bartosz-treeline closed 3 years ago

bartosz-treeline commented 3 years ago

SDK Mobile Buy SDK iOS/2021-07/6.1.0

Issue description

I am trying to complete a checkout using MobileBuySDK's completeCheckoutWithCreditCardV2 method.

As a payment provider I currently use Bogus Gateway and it is set in the shopify admin panel.

Screenshot 2021-08-17 at 14 44 44

The app has its own UI with form for providing credit card details. Once the app has the details, the credit card info is sent to the vaulting service in order to receive a token. Here's the request that's is sent using MobileBuySDK (I am using test credit card details as stated here):

curl -H "Host: deposit.us.shopifycs.com" -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: CFNetwork/1237 Darwin/20.5.0" -H "Accept-Language: en-us" --data-binary "{\"credit_card\":{\"last_name\":\"Gateway\",\"year\":\"22\",\"number\":\"1\",\"month\":\"11\",\"first_name\":\"Bogus\"}}" --compressed "https://deposit.us.shopifycs.com/sessions"

I receive the following response from the vaulting service:

{
    "id": "east-b72c0ab6a74d94828c371328d637a365"
}

Then I use the received token to complete a checkout. I use MobileBuySDK, here's the body from the http proxy:

"mutation"{
   checkoutCompleteWithCreditCardV2("checkoutId":"Z2lkOi8vc2hvcGlmeS9DaGVja291dC81MzJkNDFhYjE5ODVkYzJjNTc0MGQ2YjM2NjhlY2YwNz9rZXk9ZGQ1ZmUxYTg1N2ZlOTU5YjMwZjFjYTg2Njk4MDdhYzI=",
   "payment":{
      "paymentAmount":{
         "amount":"675.68",
         "currencyCode":"USD"
      },
      "idempotencyKey":"8725EBFD-B56B-4E9B-A411-4EE63BC20DA8",
      "billingAddress":{
         "address1":"1150 South Beverly Drive",
         "address2":"",
         "city":"Los Angeles",
         "country":"United States",
         "firstName":"Bart",
         "lastName":"Olszanowski",
         "phone":null,
         "province":"California",
         "zip":"90035"
      },
      "vaultId":"east-b72c0ab6a74d94828c371328d637a365"
   }")"{
      "checkoutUserErrors"{
         "code",
         "field",
         "message"
      },
      "checkout"{
         "id"
      },
      "payment"{
         "id",
         "ready",
         "test",
         amountV2{
            "amount",
            "currencyCode"
         },
         "checkout"{
            "id",
            "ready",
            "requiresShipping",
            "taxesIncluded",
            "email",
            "webUrl",
            "note",
            "currencyCode",
            "shippingAddress"{
               "id",
               "firstName",
               "lastName",
               "phone",
               "company",
               address1,
               address2,
               "city",
               "zip",
               "country",
               "province",
               "provinceCode",
               countryCodeV2
            },
            "shippingLine"{
               "handle",
               "title",
               priceV2{
                  "amount",
                  "currencyCode"
               }
            },
            "lineItems(first":250){
               "edges"{
                  "cursor",
                  "node"{
                     "variant"{
                        "id",
                        priceV2{
                           "amount",
                           "currencyCode"
                        },
                        "image"{
                           "transformedSrc"
                        }
                     },
                     "title",
                     "quantity"
                  }
               }
            },
            "discountApplications(first":10){
               "edges"{
                  "node"{
                     "__typename",
                     "allocationMethod",
                     "targetSelection",
                     "targetType",
                     "value"{
                        "__typename",
                        ... on MoneyV2{
                           "amount",
                           "currencyCode"
                        },
                        "... on PricingPercentageValue"{
                           "percentage"
                        }
                     }
                  }
               }
            },
            "totalDuties"{
               "amount",
               "currencyCode"
            },
            subtotalPriceV2{
               "amount",
               "currencyCode"
            },
            totalTaxV2{
               "amount",
               "currencyCode"
            },
            totalPriceV2{
               "amount",
               "currencyCode"
            },
            paymentDueV2{
               "amount",
               "currencyCode"
            }
         },
         "creditCard"{
            "firstDigits",
            "lastDigits",
            "maskedNumber",
            "brand",
            "firstName",
            "lastName",
            "expiryMonth",
            "expiryYear"
         },
         "errorMessage",
         "nextActionUrl"
      }
   }
}

and I receive the following response:

{
    "data": {
        "checkoutCompleteWithCreditCardV2": {
            "checkoutUserErrors": [{
                "code": "INVALID",
                "field": ["payment", "creditCard"],
                "message": "Credit card is invalid"
            }],
            "checkout": {
                "id": "Z2lkOi8vc2hvcGlmeS9DaGVja291dC81MzJkNDFhYjE5ODVkYzJjNTc0MGQ2YjM2NjhlY2YwNz9rZXk9ZGQ1ZmUxYTg1N2ZlOTU5YjMwZjFjYTg2Njk4MDdhYzI="
            },
            "payment": null
        }
    }
}

Current result

Credit card invalid error message is received from completeCheckoutWithCreditCardV2 method. As a note I want to add, that I am able to place an order using Shopify store panel.

Expected result

I am able to use completeCheckoutWithCreditCardV2 method in order to place an order with a credit card using Bogus Gateway.

bartosz-treeline commented 3 years ago

After further investigation, everything seems to work fine. I passed a year taking only last two digits instead of the whole year and also forgot to pass verification code.

Closing the issue