0

I have been working on an app were I try to implement the requestPaymentIntent. It was working first, but at some point it started doing the Bing search, and at some point just saying it found a mistake and doing nothing after that. This has been pointed out also in the topic: Payment domain intent is showing internet result instead of intent UI or intent confirmation using Sirikit.

One solution marked as good was provided there by William Hindenburg: "We have found that you need to add a paymentRecord to the INSendPaymentIntentResponse, before returning it from the confirm and handle methods in the Payment Intent Handler. Give this a shot and see if that fixes it for you."

I have tried to do this, but I can't figure it out. I have mainly problems with defining the status.

So in my handle method I first define the userActivity. Then I initialise the response object.

let response = INRequestPaymentIntentResponse (code: .success, userActivity: userActivity)

Then I want to add a paymentRecord to the response object:

response.paymentRecord = INPaymentRecord(payee: nil, payer: nil, currencyAmount: intent.currencyAmount, paymentMethod: nil, note: intent.note, status: ???)

Some parameters I do not need/use, so I filled in nil. Two things I would like to have in my app, the amount that needs to be paid, and for what this needs to be paid (the note). On the place of the ??? I have to fill in a status, I tried several things, but I can't figure it out. Since multiple people got this working already, can you please help me to explain how this works? Thanks a lot!

HSmilde
  • 1
  • 2

1 Answers1

0

Apple really doesn't specify what status to use for confirm, but this works for me currently.

Confirm call:

response.paymentRecord = [self makePaymentRecordForIntent:intent withStatus:INPaymentStatusPending];

Send call:

intentResponse.paymentRecord = [self makePaymentRecordForIntent:intent withStatus:INPaymentStatusCompleted];

Genericized code:

-(INPaymentRecord *)makePaymentRecordForIntent:(INSendPaymentIntent *)intent withStatus:(INPaymentStatus)status {

INPaymentMethod *payMethod = [[INPaymentMethod alloc] initWithType:INPaymentMethodTypeChecking
                                                              name:@"Gold Star Checking"
                                                identificationHint:@"1234"
                                                              icon:nil];

INPersonHandle *senderHandle = [[INPersonHandle alloc] initWithValue:@"first.last@example.com" type:INPersonHandleTypeEmailAddress];
NSPersonNameComponents *senderNameComp = [[NSPersonNameComponents alloc] init];
senderNameComp.givenName = @"First";
senderNameComp.familyName = @"Last";
INPerson *senderPerson = [[INPerson alloc] initWithPersonHandle:senderHandle
                                           nameComponents:senderNameComp
                                              displayName:@"First Last"
                                                    image:nil
                                        contactIdentifier:nil
                                         customIdentifier:nil];

INPaymentRecord *paymentRecord = [[INPaymentRecord alloc] initWithPayee:intent.payee
                                                                  payer:senderPerson
                                                 currencyAmount:intent.currencyAmount
                                                  paymentMethod:payMethod
                                                           note:intent.note
                                                         status:status];
return paymentRecord;

}

Fresh One
  • 150
  • 1
  • 9