{"id":17275300,"url":"https://github.com/jflinter/applepaystubs","last_synced_at":"2025-03-26T13:43:13.884Z","repository":{"id":21597898,"uuid":"24918045","full_name":"jflinter/ApplePayStubs","owner":"jflinter","description":null,"archived":false,"fork":false,"pushed_at":"2014-10-08T00:37:10.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T15:16:26.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jflinter.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-08T00:36:47.000Z","updated_at":"2014-10-08T00:37:10.000Z","dependencies_parsed_at":"2022-08-21T19:40:52.490Z","dependency_job_id":null,"html_url":"https://github.com/jflinter/ApplePayStubs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FApplePayStubs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FApplePayStubs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FApplePayStubs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jflinter%2FApplePayStubs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jflinter","download_url":"https://codeload.github.com/jflinter/ApplePayStubs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245667254,"owners_count":20652918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T08:55:53.439Z","updated_at":"2025-03-26T13:43:13.850Z","avatar_url":"https://github.com/jflinter.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"ApplePayStubs\n===\n\nWhat is this?\n---\n\nApplePay is awesome, and like many developers we're excited to work with it. However, testing and developing for it is currently difficult as Apple hasn't released any public versions of the iOS SDK with it enabled. Furthermore, even when it is released, it will require a new iPhone to actually see and test the UI.\n\nWe've created a replacement component for `PKPaymentAuthorizationViewController` (the primary class involved in ApplePay transactions) for businesses interested in working with ApplePay called `STPTestPaymentAuthorizationViewController`. These classes appear visually similar and behave almost identically. The primary difference is that `STPTestPaymentAuthorizationViewController` yields test credit cards and addresses instead of accessing actual information stored on a user's iPhone. You can use it to build and test all of your UI and application logic around ApplePay, and switch it out for the real thing once ApplePay is publicly released.\n\nPlease note that this is for *testing purposes only*.\n\nDependencies\n---\n- Xcode 6+\n- iOS 8+\n\nApplePayStubs also depends on the `PassKit` framework.\n\nInstallation\n---\nUse Cocoapods or manually add the files to your repository.\n\nUsage\n---\n\nYou create and use instances of `STPTestPaymentAuthorizationViewController` exactly the same way as with \n`PKPaymentAuthorizationViewController`.\n\n//ViewController.m\n\nPKPaymentRequest *request = ...;\nUIViewController *controller;\n#if DEBUG\n  controller = [[STPPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];\n  controller.delegate = self;\n#else\n  controller = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];\n  controller.delegate = self;\n#endif\n[self presentViewController:controller];\n\n`STPTestPaymentAuthorizationViewController` will trigger the same `PKPaymentAuthorizationViewControllerDelegate` callbacks at the appropriate time on its delegate.\n\n- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingAddress:(ABRecordRef)address\n                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *shippingMethods, NSArray *summaryItems))completion {\n    [self fetchShippingCostsForAddress:address completion:^(NSArray *shippingMethods, NSError *error) {\n        if (error) {\n            completion(PKPaymentAuthorizationStatusFailure, nil, nil);\n            return;\n        }\n        completion(PKPaymentAuthorizationStatusSuccess, shippingMethods, [self summaryItemsForShippingMethod:shippingMethods.firstObject]);\n    }];\n}\n\n- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller\n                   didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus, NSArray *summaryItems))completion {\n    completion(PKPaymentAuthorizationStatusSuccess, [self summaryItemsForShippingMethod:shippingMethod]);\n}\n\n\n- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller {\n    [self dismissViewControllerAnimated:YES completion:nil];\n}\n\nWhen the user finishes selecting a card, as usual `STPTestPaymentAuthorizationViewController` will call `paymentAuthorizationViewController:didAuthorizePayment:completion` on its delegate.\n This usually includes a `PKPayment` that contains encrypted credit card data that you'd pass off to your payment processor (such as Stripe). To approximate this functionality, we attach a credit card number to the `PKPayment` under the `stp_testCardNumber` property. If you're using Stripe to handle this token, you can use our existing card APIs to turn this into a token:\n\n - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller\n                        didAuthorizePayment:(PKPayment *)payment\n                                 completion:(void (^)(PKPaymentAuthorizationStatus))completion {\n     void(^tokenBlock)(STPToken *token, NSError *error) = ^void(STPToken *token, NSError *error) {\n         if (error) {\n             completion(PKPaymentAuthorizationStatusFailure);\n         }\n         else {\n             [self createBackendChargeWithToken:token completion:completion];\n         }\n     };\n #if DEBUG\n     STPCard *card = [STPCard new];\n     card.number = payment.stp_testCardNumber;\n     card.expMonth = 12;\n     card.expYear = 2020;\n     card.cvc = @\"123\";\n     [Stripe createTokenWithCard:card completion:tokenBlock];\n #else\n     [Stripe createTokenWithPayment:payment\n                     operationQueue:[NSOperationQueue mainQueue]\n                         completion:tokenBlock];\n #endif\n }\n\n(Note: Stripe tokens created from Apple Pay work interchangably with those created using manually-collected credit card details).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjflinter%2Fapplepaystubs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjflinter%2Fapplepaystubs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjflinter%2Fapplepaystubs/lists"}